Does compositor 'input previous' inputs the depth buffer?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Posts: 3
Joined: Mon Jan 09, 2012 12:43 am

Does compositor 'input previous' inputs the depth buffer?

Post by nihongasukidesu »


I have 2 objects. Water surface (visibility_mask 2) and solid cylindrical object (visibility_mask 1).
I want to render to a texture only the portion of the object that appear under the water surface, so I wrote this composition.
The composition is used for a RenderTarget texture that is latter used in the shader of water surface for refraction effect.
I thought I could do the following:
1st Set the viewport visibility_mask to 1
2nd The composition 1st pass will render the fluid surface but it will not clear the depth buffer, so the fluid surface that is hidden by the cylinder would not be rendered, now I should have in rt0 only the water surface that is not hidden by the cylinder with alpha 1 and the rest of texture alpha 0.
3rd Use rt0 with render_quad, and the material should mask out from input previous all parts that coincide with rt0 alpha 0.

But unfortunately the output of the whole process is alpha 0 and black background.

Code: Select all

compositor FluidBG
		texture rt0 target_width target_height PF_R8G8B8A8
		target rt0
			visibility_mask 2

			input previous

			// Clear frame and stencil buffer but not depth
			pass clear
				buffers stencil color
				stencil_value 0.0
				color 0 0 0 0
			pass render_scene
			input previous
			pass render_quad
				input 0 rt0
				material shader/FluidBG
Any help is much appreciated, thanks for advance.

User avatar
Posts: 511
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 66

Re: Does compositor 'input previous' inputs the depth buffer

Post by lingfors »


Don't use a compositor for this kind of task. Instead, just create a separate render texture, camera, viewport etc. in your main application. Then set a custom clip plane on this camera (Camera::enableCustomNearClipPlane) at the same level as your water. This will result in your scene being rendered to the texture with everything above the water being cut off, i.e. you will only render what is under the water surface.

This texture can then be referenced in the material and shader you set on your water plane (or whatever geometry you use for water).

If you want to see how to do this in source, feel free to check out my project OgreWater:

Good luck!

Posts: 424
Joined: Wed Aug 01, 2007 8:13 pm
Location: Venice, CA, USA
x 7

Re: Does compositor 'input previous' inputs the depth buffer

Post by cyrfer »

FYI: In my experience "input previous" causes a clear to occur. You can see this if you put a breakpoint in the RSClearOperation::execute function. That function will get hit for a 'pass clear' too.

Post Reply