Jump to content
  • Advertisement
Sign in to follow this  
ReaVeR-Andrey

No-render volume

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What if I want to create a volume in which nothing would render. I mean: I have a character (mesh) in front of the camera (the camera is locked to it) and I want nothing to render between the mesh and the camera. It's like I have an area of the screen where nothing with Z less than X cannot render. Maybe it could be done with stencil. I don't want to use pixel shaders. !EDIT! and I want all in one pass.

Share this post


Link to post
Share on other sites
Advertisement
Make a z-fill pass, then render your volume and let it write 1 to stencil. Finally when you're going to render your scene set the stencil test to EQUAL and the reference value to 1.

Share this post


Link to post
Share on other sites
With a Z-fill pass I meant to render your whole scene to(and only to, so turn of color writing) Z-buffer, then render(color write still off) your volume to the stencil buffer with z-test on, but z-write off. Where the stencil is non-zero(so the volume got rendered) is the invisible part of the scene.

pseudo-code:

D3DRS_STENCILENABLE = false
D3DRS_COLORWRITEENABLE = False
D3DRS_ZENABLE = true

Render_Scene


D3DRS_STENCILENABLE = true
D3DRS_STENCILREF = 1
D3DRS_STENCILFUNC = D3DCMP_ALWAYS
D3DRS_STENCILPASS = D3DSTENCILOP_REPLACE
D3DRS_ZWRITEENABLE = False

Render_Volume

D3DRS_COLORWRITEENABLE = true
D3DRS_STENCILFUNC = D3DCMP_EQUAL

Render_Scene

Share this post


Link to post
Share on other sites
Hmm. I still don't get you. If a volume takes up only part of the screen then with your code only a small rect in the center of the screen will get rendered.

Share this post


Link to post
Share on other sites
It's the same idea as in shadow-volume rendering. Basically where is the shadow, there's no light->no scene is visible.
The code snippet is from my shadow-volume rendering algorhitm and it works

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!