/// <summary> /// aseta texturematriisit shadowmapping shaderia varten /// </summary> static void SetTextureMatrix() { Matrix4 projMatrix = GLExt.ProjectionMatrix, modelMatrix = GLExt.ModelViewMatrix; GLExt.MatrixMode(MatrixMode.Texture); GLExt.LoadIdentity(); GLExt.Translate(0.5f, 0.5f, 0.5f); // remap from [-1,1]^2 to [0,1]^2 GLExt.Scale(0.5f, 0.5f, 0.5f); GLExt.MultMatrix(ref projMatrix); GLExt.MultMatrix(ref modelMatrix); GLExt.MatrixMode(MatrixMode.Modelview); }
public void RenderMesh() { if (Vbo == null) { return; } if (DoubleSided) { GL.Disable(EnableCap.CullFace); } if (VBO.FastRenderPass) { if (CastShadow) { Vbo.Render(); } } else { Material.SetMaterial(); if (WorldMatrix != null) { GLExt.MatrixMode(MatrixMode.Texture); GLExt.PushMatrix(); GLExt.MultMatrix(ref WorldMatrix); GLExt.MatrixMode(MatrixMode.Modelview); } Vbo.Render(); if (WorldMatrix != null) { GLExt.MatrixMode(MatrixMode.Texture); GLExt.PopMatrix(); GLExt.MatrixMode(MatrixMode.Modelview); } } if (DoubleSided) { GL.Enable(EnableCap.CullFace); } }
public void RenderMesh() { if (DoubleSided) { GL.Disable(EnableCap.CullFace); } if (VBO.FastRenderPass == false) { Material.SetMaterial(); GLExt.MatrixMode(MatrixMode.Texture); GL.ActiveTexture(TextureUnit.Texture0 + Settings.SHADOW_TEXUNIT); GLExt.PushMatrix(); if (WorldMatrix != null) { GLExt.MultMatrix(ref WorldMatrix); } GLExt.RotateX(-90); GLExt.MatrixMode(MatrixMode.Modelview); } if (VBO.FastRenderPass == false || CastShadow == true) { GLExt.RotateX(-90); for (int i = 0; i < model.Length; i++) { if (model[i].vbo == null) { continue; } if (VBO.FastRenderPass == false) { model[i].texture.Bind(0); } // lasketaanko uusi asento (jos ei olla laskettu jo shadowpassis) if (animCalculated == false) { // Interpolate skeletons between two frames InterpolateSkeletons(ref curAnim.skelFrames, curAnim.curFrame, curAnim.nextFrame, curAnim.numJoints, curAnim.lastTime * curAnim.frameRate); PrepareMesh(); animCalculated = true; } model[i].vbo.Render(); } if (VBO.FastRenderPass == false) { GLExt.MatrixMode(MatrixMode.Texture); GL.ActiveTexture(TextureUnit.Texture0 + Settings.SHADOW_TEXUNIT); GLExt.PopMatrix(); GLExt.MatrixMode(MatrixMode.Modelview); animCalculated = false; } } if (DoubleSided) { GL.Enable(EnableCap.CullFace); } }