Original Post
how can i simulate another depth buffer?
Quote:Yup, I saw that but I followed some phrases via searching and found this page. However on re-reading it now it's just an ideas page. Oops.
The presentation mentions specifically that there's no "double depth buffer" in OpenGL
Quote:From the looks for things, you'll need to at least in part manually implement a second depth buffer - something along the lines of how shadow mapping works.
should i create a surface to store the depth value? but how can i compare the depth value stored in the created surface?
Quote:Your favourite search engine might be a good start [wink]. Otherwise check out the AMD/ATI or Nvidia developer SDK's - they're crammed full of cool samples and whitepapers.
where can i find the directx examples?
Quote:
Original post by swordyijian
then how to use directx to do the "depth peeling"? should i create a surface to store the depth value? but how can i compare the depth value stored in the created surface? where can i find the directx examples?
(Initialization)(1) Create 2 offscreen render targets (R32F works well) --> note, I've found you need 2 of them for ping-ponging purposes--> these two render targets are referred to as "RT_1" and "RT_2" in the below pseudo-code(Render Code)(1) Set ping RT = RT_1, pong RT = RT_2(2) Clear the main DB to 0.0f(3) Clear the 2 offscreen RT's to 1.0f(3) Set ZFunc to Greater (want the pixel furthest from the eye-pt)do{ (4) SetRendetTaget(0, ping RT) (5) SetTexture(0, pong RT) (6) DrawScene() (7) swap( ping RT, pong RT )}while( Pixels are drawn );(In your Depth Peeling shader)(1) Compare fragments depth to depth in the 'pong' render target(2) If 'this fragments depth' >= 'depth stored in pong RT' discard Else light and shade pixelQuote:
Original post by wyrzy
Hope that helps. I'd post my code but its quite a mess at the moment and I don't really have the time to clean it up and make a nice example demo right now.
Quote:
Original post by swordyijian
then how to write the depth value into the texture, and how to compare the depth value in texture and the cureent depth value, i mean how to write the shader.
in the dx sdk sample of shadow map. the depth value seems just equal to positiion.z/position.w
glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_MIN);glFrag.r=depthValue0;glFrag.b=depthValue1; //first clear the offscreen buffer with the values (1,1,1)glClearColor(1,1,1);glClear(GL_COLOR_BUFFER_BIT);glEnable(GL_BLEND); //for transluscent object we do multiplicative blending://we let New_pixel= gl_Frag*old_pixelglBlendFunc(GL_DST_COLOR, GL_ZERO); glBlendEquation(GL_FUNC_ADD);//disable clamping...glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE);glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);glClampColorARB(GL_CLAMP_READ_COLOR_ARB, GL_FALSE);glDepthMask(GL_FALSE);glEnable(GL_DEPTH_TEST);//draw all transparent objectsThis topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more