Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Backface Rendering

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011

    Backface Rendering


    I write a Volume Renderer and want to implement Empty Space Leaping for a better performance. I have seperate my volume in several minivolumes where my visible parts are. Now I have many cubes and want to render the backfaces of the scene and in a second part I want to render the frontface of the scene.

    For rendering the frontface you have to render it like a normal scene. (DepthFunc Lequal, DepthValue 1.0, Cullface Back)

    My problem is when i try to render the backface, i don't get the result I want to see. My idea is to turn all the setting for frontface rendering (DepthFunc, DepthValue 0.0, Cullface Front). Is there any failure in my renderpipeline? Maybe a false order of the functions? Or is my idea for backface rendering false?

    What I don't understand is that when I change the DepthFunc I have no change in de result of the image. At the moment I have no pictures to demonstrate the problem, but maybe somebody can help me. I try to get some screenshots.

    My Renderfunction can you see here:
    Code :
    private void RenderPass2(int tex_coordBuffer, Vector2 wh, Vector3 eyePos)
       GL.BindFramebuffer(FramebufferTarget.Framebuffer, p2_fboID);
       GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
       GL.ClearColor(0.0f, 1.0f, 0.0f, 1.0f);
       // setup texture for depth buffer
       GL.BindTexture(TextureTarget.Texture2D, tex_coordBuffer);
       GL.Uniform1(p2_coordBuffer, 0);
       // create transform matrix for volume cs
       Vector3 x_dir = new KTC_Geometrie_Source.Vectors.Vector3(_volume.x_dir.X, _volume.x_dir.Y, _volume.x_dir.Z);
       Vector3 y_dir = new KTC_Geometrie_Source.Vectors.Vector3(_volume.y_dir.X, _volume.y_dir.Y, _volume.y_dir.Z);
       Vector3 z_dir = new KTC_Geometrie_Source.Vectors.Vector3(_volume.z_dir.X, _volume.z_dir.Y, _volume.z_dir.Z);
       Vector3 origin = new KTC_Geometrie_Source.Vectors.Vector3(_volume.origin.X, _volume.origin.Y, _volume.origin.Z);
       Matrix4X4 m = Matrix4X4.ChangeKS(x_dir, y_dir, z_dir, origin);
       Matrix4 transform = new Matrix4(1.0f / m.A11, m.A12, m.A13, m.A14,
                                                  m.A21, 1.0f / m.A22, m.A23, m.A24,
                                                  m.A31, m.A32, 1.0f / m.A33, m.A34,
                                                  m.A41, m.A42, m.A43, m.A44);
        Vector4 eye = Vector4.Transform(new Vector4(eyePos), transform);
        GL.Uniform4(p2_camPos, eye);
        GL.Uniform2(p2_wh, wh);
        GL.UniformMatrix4(p2_changeCS, false, ref transform);
        GL.BindBuffer(BufferTarget.ArrayBuffer, DEBUG_verticeID);
        GL.BindBuffer(BufferTarget.ElementArrayBuffer, DEBUG_indiceID);
        GL.VertexAttribPointer(p2_inVertex, 3, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);
        GL.DrawElements(BeginMode.Quads, DEBUG_COUNT, DrawElementsType.UnsignedInt, IntPtr.Zero);
        GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Karachi, Pakistan
    I assume you are trying to do object order empty space skipping for multi pass ray casting. If that is the case, for the front face texture, you can just cull back faces of all cubes and render the scene. For the back face texture, you cull the front faces and render all of the cubes.

    Have a look at this set of tutorials and the book realtime volume graphics which has a chapter on this.

    See if this helps.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2011
    Thank you for the help. I have the book Real Time Volume Graphics.
    I've found the problem and my code is correct. During the initialization of FBO I have set the wrong DepthComponentent.

    Know everything works well.

    But there ist another problem. When I render the scene an look for example in positive x direction everthing renders with a good performance, but if I look in negative x direction the performance become very slow.
    Is this a problem with the caching of the 3D texture? Or what could this problem be. I didn't found any explanation about this error in my literature.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts