WebGPU: Sample environment#719
Conversation
| // environment | ||
| envMap: texture_2d<f32>, | ||
| envMapSampler: sampler, | ||
| envMapRotation: mat3x3f, | ||
| envMapIntensity: f32, | ||
| envMapBlur: f32, | ||
|
|
||
| globalId: vec3u | ||
| ) -> void { | ||
|
|
||
| let env = EnvironmentInfo( | ||
| envMapRotation, | ||
| envMapIntensity, | ||
| envMapBlur, | ||
| ); |
There was a problem hiding this comment.
Would it make sense to pack these fields into a struct uniform rather than merging them into a struct after the fact?
There was a problem hiding this comment.
I would love to do that, but haven't managed to.
uniform( { ... } ), uniform( environmentInfoStruct( ... ) ), environmentInfoStruct( ... ) as values in paramters did not work for me. note: environmentInfoStruct = struct( { ... }, 'EnvironmentInfo' );
Maybe you know how to do that?
There was a problem hiding this comment.
It seems to not be supported 😅 According to here it should be possible. Might be time to make another three.js issue.
There was a problem hiding this comment.
Just so it's clear - would you like to make the issue? Otherwise I can make one.
There was a problem hiding this comment.
Honestly I was going to ask at the forum first if its truly impossible to do now. Maybe there is an example that I missed. You think its fine to make an issue at this point?
There was a problem hiding this comment.
I would make an issue. I don't see structs used as uniforms in any example and the uniform node seems to imply it only takes math types and there are no other "uniform" nodes that seem to be applicable. If it turns out to be possible then it should be made more clear in the documentation.
src/webgpu/WebGPUPathTracer.js
Outdated
| pathTracer.setEnvironment( environment, | ||
| scene.environment !== null ? ( scene.environmentIntensity ?? 1 ) : 0, | ||
| scene.environmentRotation, | ||
| scene.backgroundBlurriness ?? 0, | ||
| ); |
There was a problem hiding this comment.
I'm seeing that setting "backgroundBlurriness" seems to have no effect on the background appearance. Is there another setting I need to toggle?
There was a problem hiding this comment.
Fixed that. It turns out that ndcToCameraRay generates non-normalized ray directions which lessened the impact of blurriness.
There was a problem hiding this comment.
Maybe that commit hasn't been pushed? I'm still seeing that blur doesn't work.
It turns out that ndcToCameraRay generates non-normalized ray directions
It's technically not needed in a lot of places but maybe it may make sense to just normalize the camera rays for convenience?
There was a problem hiding this comment.
Ah, yes. Megakernel version did not work because code moved and I forgot to move the fix. Pushed it.
And yeah, camera rays are just normalized after the generation. I figured modifying that in a library will limit people who do not actually need a normalized direction.
…r Color and null in those fields.



Adds support to sample environment texture by reusing
EquirectHdrInfoUniform. This allows us to easily reuse code for weight calculation when implementing MIS