Hello,
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:
private void RenderPass2(int tex_coordBuffer, Vector2 wh, Vector3 eyePos)
{
GL.BindFramebuffer(FramebufferTarget.Framebuffer, p2_fboID);
GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
GL.DepthFunc(DepthFunction.Greater);
GL.Enable(EnableCap.DepthTest);
GL.ClearDepth(0.0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.ClearColor(0.0f, 1.0f, 0.0f, 1.0f);
GL.Enable(EnableCap.CullFace);
GL.CullFace(Front);
_manager.ActivateShader(p2_shaderID);
GL.MatrixMode(MatrixMode.Modelview);
GL.PushMatrix();
GL.MultMatrix(_volume.transform[0]);
// setup texture for depth buffer
GL.Enable(EnableCap.Texture2D);
GL.ActiveTexture(TextureUnit.Texture0);
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.EnableVertexAttribArray(p2_inVertex);
GL.VertexAttribPointer(p2_inVertex, 3, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);
GL.DrawElements(BeginMode.Quads, DEBUG_COUNT, DrawElementsType.UnsignedInt, IntPtr.Zero);
GL.DisableVertexAttribArray(p2_inVertex);
GL.PopMatrix();
_manager.DeactivateShader();
GL.Disable(EnableCap.Texture2D);
GL.Disable(EnableCap.DepthTest);
GL.Disable(EnableCap.CullFace);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
}