[SOLVED] Prevent rendering scene multiple times using MRT

But you can render stuff not in the queues, eh?

Once the queues are rendered then they are flushed… that was always my understanding. I could be mistaken about what I’m talking about. Hopefully @nehon will correct me.

This is the part I haven’t understood so far. Why can’t the water surface be rendered over the whole scene up to that point? Why must you mask out the part above the water?

But this way it is only possible to render an additional pre-pass but not a post-pass :confused:

Because I need the depth values from the water surface and from the ground below the water surface. So you have not many options. One way is to render the world without water and render the water on the top of it, but then there is a problem with overwritten depth values…or you render the world with water but then you occlude the pixels below the water surface => this also needs an additional render pass.

edit: the next problems is that all other gemetries should occlude the water surface. I don’t want to see the water shader through translucent objects or something else like particles and otehr post filters

I don’t understand why this won’t work:
-render the scene
-in a post shader, render the water geometry… which now has access to both the depth of the water, and the depth of the scene at that point.

…that’s basically how the built in water filter works.

It is not so easy for my situation. I have a block like world and therefore I need to hold the object count as low as possible. The water is part of the mesh of the world and there are only 2 usefull render buckets: opaque and translucent. I need to put the water in one of these. But there are other objects such as translucent windows and I don’t want the water shader on that windows. On the basis of this my idea was to create a mask for the water.

You can create whatever meshes you like and use your own buckets, basically. Generate the mesh for the surface of the water separately… make sure your filter has it.

Render your scene once. In your filter, render the water mesh.

Is your water surface at a constant elevation or do you not bother with reflections?

I want to prevent that the water has a separate geometry because the object count would be increased by 1/3 in worst case. The water level has different heights. You can place the water where you like. My goal is have ScreenSpaceReflections because it is not possible to handle several reflection planes while it looks good and runs smoothly performance wise. The water already works like described above.

edit: the performance is really good now. I have a speedUp of 2.02

MRT + glow + water = 101 fps
MRT - glow - water = 110 fps
no MRT + glow + water = 50 fps
no MRT - glow - water = 108 fps

3 Likes

Nice. I’m happy you sorted it out
@pspeed about flushing queues. The thing is, it’s supposed to flush them, so that they are empty for next the frame. Because we assume we don’t need them anymore since we have rendered their content.
But here alrik has a point… In case of a post process you may need their content to make additional passes in the postFrame… Though that’s the first time the case occurs.
But still, IMO we’d need a more flexible rendering pipeline to allow users to do what alarik did without changing the core.

In the end…we should clear the queues at the beginning of the next frame instead of at the end of the current one…

One thing that bugs me here is that you are concerned with object count - don’t you batch your blocks into bigger chunks whenever possible to keep object count low? And it should not be even batching but generation of whole chunk geometry at once.

Yes I am generating chunk meshes on my own. But the object count is still important. There are a lot more chunks, NPCs, Players, shaders, particles and so on.

I agree with you or you could clear the queues at the very end of the frame…after all filters were applied