public InputManager(Window window, Camera camera) { windowCopy = window; cameraCopy = camera; lastMousePos = new Vector2(OpenTK.Input.Mouse.GetCursorState().X, OpenTK.Input.Mouse.GetCursorState().Y); windowCopy.KeyDown += HandleKeyDown; windowCopy.KeyUp += HandleKeyUp; }
private void uploadParameters(Vector3 lightPosition, Camera camera, Matrix4 projectionMatrix, Matrix4 depthViewProjectionMatrix) { GL.Uniform1(depthTextureLocation, 0); GL.Uniform1(shadowTextureLocation, 1); GL.Uniform1(noiseTextureLocation, 2); Matrix4 invVP = camera.viewMatrix * projectionMatrix; inverse(ref invVP); GL.UniformMatrix4(inverseViewProjectionMatrixLocation, false, ref invVP); GL.Uniform3(viewPosLocation, camera.Position); // Compute the MVP matrix from the light's point of view (and add a bias) Matrix4 depthMVP = depthViewProjectionMatrix * biasMatrix; GL.UniformMatrix4(depthBiasMVPLocation, false, ref depthMVP); Vector2 noiseOffset = new Vector2(intNoiseOffsetX, intNoiseOffsetY); GL.Uniform2(noiseOffsetLocation, noiseOffset); GL.Uniform1(enumScatteringTechniqueLocation, enumScatteringTechnique); }
public void render(Vector3 lightPosition, Camera camera, Matrix4 projectionMatrix, int depthMapTexture, int shadowMapTexture, Matrix4 depthViewProjectionMatrix) { // Set some settings GL.BindVertexArray(vertexArrayObject); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, depthMapTexture); GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, shadowMapTexture); GL.ActiveTexture(TextureUnit.Texture2); GL.BindTexture(TextureTarget.Texture2D, noiseTexture); // Enable Position Attribute GL.EnableVertexAttribArray(positionLocation); GL.EnableVertexAttribArray(texcoordsLocation); // Upload Parameters uploadParameters(lightPosition, camera, projectionMatrix, depthViewProjectionMatrix); // Enable Texture and set Blending GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendEquation(BlendEquationMode.FuncAdd); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One); // Render the Quad GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); // Clean up and set Blending GL.DisableVertexAttribArray(positionLocation); GL.DisableVertexAttribArray(texcoordsLocation); GL.BindVertexArray(0); GL.BindTexture(TextureTarget.Texture2D, -1); GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, -1); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, -1); GL.Disable(EnableCap.Blend); GL.BlendEquation(BlendEquationMode.FuncAdd); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); }