How can I send structs from positionNode wgsl shader to the colorNode wgsl shader?

I took a look at it straight away. In the forum someone recently asked about a blur effect, the new node is a better solution than the old way.

I see in both examples you use a geometry for this. I imagine that a PostFXNode would be quite good with addable materials. This PostFXNode would then always be fullscreen so that you don’t need to create any geometries yourself. I also think it’s good that you don’t have to have a composer render after the scene has been rendered. I think the post-processing setup in webgl has stopped many people from ever having to deal with it. The nodes are much easier to care for.

Another reason for a PostFXNode or ComposerNode would be the easy stackability of post-processing effects.

PostFXNode.add(myFirstPostEffectMaterial);
PostFXNode.add(mySecondPostEffectMaterial);
PostFXNode.add(myThirdPostEffectMaterial);

scene.add(PostFXNode);

One of my first attempts where I dealt with it. For the clouds I had to greatly reduce the ray tracing depth so that it would run on my tablet, hence the poor quality of the clouds (to few integration steps).

What I’m getting at is, I first use a cloud post-processing and because clouds are also influenced by the atmosphere, I use atmospheric post-processing on top of that. I would have later written a particle emitter for the engine, but I thought another post-processing shader would look better. I haven’t done any cloud shadows yet either. But that would be part of the cloud shader.
On the horizon you can clearly see how the atmosphere strongly scatters the light from the clouds so that they can hardly be seen

Same here, you can clearly see the overlay effect of the two post-processing shaders.
By the way, that’s also the reason why I started with an ocean. Just a boring blue surface is not nice.
On my desktop with my XTX 7900 Readon I can render the clouds with excellent quality, but the trick is to be able to get by with little resources. I can fly through the clouds and I really like the effect.

I don’t know whether a separate material class would be practical for this. My post-processing fragment shaders are very extensive and complex but the vertex shader is always very simple

export const atmosphereVS =`
		
  out vec2 vUv;
 
  void main() { 
	vUv = uv;  
	gl_Position = vec4( (uv - 0.5)*2.0, 0.0, 1.0 ); 
  }
`;

That’s why I always got the warning about the missing normal attribute with the MeshBasicNodeMaterial when I used it with the composer because the MeshBasicNodeMaterial has a normal attribute, but the composer doesn’t offer it because it’s not necessary in postprocessing.
The stackability and the fact that no geometry was needed are good features of the composer. I think it’s worth adopting.

I hope you don’t mind if I often go into a little more detail. Three.js offers very extensive possibilities and I’m probably one of the few people who uses it so extensively. But it’s all these powerful tools that I find so exciting about three.js.

2 Likes

Creating a post-processing class is within the roadmap, I just wanted to ensure that some effect could be done with NodeMaterial in WebGPURenderer, which would have been impossible to do without RenderTargets in WebGLRenderer.

In node-oriented post-processing, it wouldn’t be much different from what we currently see in NodeMaterial.

const post = new PostProcessing();
post.outputNode = passTexture().saturation( 1.1 ).vibrance( 1.5 ).contrast( 2 )

For example, in WebGPURenderer we can use scene.backgroundNode to create atmosphere effect instead of using an additional pass or a new static mesh.

As soon as possible I will make some new related examples

2 Likes

If you have a realistic atmosphere as big as the earth that takes the terrain into account and etc. I have nothing against it, but as far as I’m concerned you don’t need to do that. Just being able to do that is enough for me.
“As soon as possible”…
There is a saying in german but I don’t no the correct translation. “The strength lays in the calm”
But if you get the urge for action I don’t want to slow you down :smile:

Just to line up expectations, the atmosphere I imagined is something like this but instead of creating a new mesh for this use just scene.backgroundNode = sky( { ...params } );

I believe that the examples tend to be as simple as possible, just to show the possibilities.

1 Like

This is certainly true :slight_smile:

I created a very simple codePen on the subject of depthTexture.
With line 40 the red box disappears, the shader no longer works. If you delete line 40 then it works. So there lies the problem somewhere.

I have now uploaded a repository to github. If you’re interested, you can see how much the previous expansions have brought. That’s a very good result so far.

But with the future extensions like mipmaps, bilinear filter, anisotropy, postprocessing, …

it will get much better. The question has come up a few times in the forum as to whether more complex landscapes are possible with 3js. The project shows the possibilities well.

Thank you for example. I think that this PR should fix this issue TSL: Fix texture_depth_2d in wgslFn by sunag · Pull Request #27323 · mrdoob/three.js · GitHub

1 Like