Early Z Pass occlusion

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Early Z Pass occlusion

Post by omaremad »

There is allot of talk about saving fillrate with portals, occlusion culling and deffered rending.

How about an early z-only pass? its very easy to implement in irrlicht. If you have transform time to waste, you can redner the scene with a z write only which is extremely fast since there is no fragment processing and most of the vertex processing is shutdown(like interpolation of colours and tcoords). Then without clearing the depth buffer render the scene again with colour write on, all the new rendering is z compared and any occluded fragments are killed early, thats per pixel occlusion culling with 0 overdraw!.

I have tried this on a quake map with parallax mapping and made a considerable diffrence to the framerate (not much of a framerate diffrence using the normal shading).

The only trouble i see is if some one activates this method where they use a shader that modifies fragment depth, the fragment shader is off during the z only pass hence the fragment will not use the depth made from the pixel shader. In that case the early z pass can be a SMaterial flag which can be true for most scenenodes. Similar to the HW buffers hints.

I rendered the objects with this flag in the scenemanger near the shadow pass and made the setMaterial method in the video driver read the SMaterial flag and disable colour writes when needed.

Is there any hope for this going into irrlicht?
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Check out the latest SVN/trunk version from Irrlicht. It has an OverrideMaterial in the scene manager and can disable the color rendering via SMaterial settings. That way you can easily make a complete render loop with the desired settings.
For making it an essential part of Irrlicht it would require some more thoughts on the render pipeline since we don't have enough means to define such renderpasses in the API.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

cool have you actually made that???

I'd love to use it!
9YkKsvXM
Posts: 64
Joined: Tue Mar 11, 2008 11:45 pm

Post by 9YkKsvXM »

-
Last edited by 9YkKsvXM on Mon Jun 08, 2020 1:22 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You don't "retrieve the depth buffer". Basically:

- When you render some objects, their z-depth gets written to the zbuffer.
- When you render something else that is behind them, or partially behind them, the graphics card doesn't have to shade anything that's got a higher zbuffer value, because it's already occluded.

So say you have 2 spheres. First you render them to the zbuffer in a very "cheap" way (No shading, no color writes, just transformation etc...) and now you have the z values of the sphere pixels written to the zbuffer. Now you can only see one side of one of the spheres, the spheres are not transparent, so only one of them is visible. What you do after that is render the exact same spheres again, this time with the complex shading etc, and you won't have to shade in the sphere in the back because it will get z-rejected because you already have the zvalues of the sphere in front written to the zbuffer, and you did not have to perform any complex shading (E.g. Parallax mapping, which is where this method excels because it trades an extra transformation pass for less shading).

Cheers I hope that explains it more or less.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

After reading this i've come to a question. Does Irrlicht render the objects sorting them front to back? because that way, the far objects have a higher chance of getting Z occluded faster than just sending them to render randomly. It is almost the same idea we are speaking here, in certain way, and you don't really have to render a Z pass first.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
9YkKsvXM
Posts: 64
Joined: Tue Mar 11, 2008 11:45 pm

Post by 9YkKsvXM »

-
Last edited by 9YkKsvXM on Mon Jun 08, 2020 1:22 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Then you are quite offtopic Nate_D as that was not mentioned anywhere in this thread :P
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Re: Early Z Pass occlusion

Post by vivekSivamRP »

hi BlindSide i'm new to irrlicht. Can you pls explain me how to create DEPTH TEXTURE using irrlicht ? as i'm looking for shadow mapping i dono how to obtain depth texture ? there is no books too refer so sad
Thanks in advance
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Early Z Pass occlusion

Post by mongoose7 »

Ha-ha - didn't Blindside write XEffects? Look at Ex 1 in XEffects where Blindside has done all the work.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Early Z Pass occlusion

Post by devsh »

you can very easily help yourself to a DEPTH texture of ANY Render Target in OGL

just modify COpenGLTexture.cpp and make sure your depth attachment is not a Renderbuffer but a Texture2D

then you can setTexture using the COpenGLDepthFBO
Post Reply