private void renderDepthMap(Window window, Camera camera, Scene scene) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float)Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float)Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes(); for (Mesh mesh : mapMeshes.keySet()) { mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> { Matrix4f modelLightViewMatrix = transformation.buildModelViewMatrix(gameItem, lightViewMatrix); depthShaderProgram.setUniform("modelLightViewMatrix", modelLightViewMatrix); } ); } // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
private void renderDepthMap(Window window, Camera camera, Scene scene) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float)Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float)Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes(); for (Mesh mesh : mapMeshes.keySet()) { mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> { Matrix4f modelLightViewMatrix = transformation.buildModelViewMatrix(gameItem, lightViewMatrix); depthShaderProgram.setUniform("modelLightViewMatrix", modelLightViewMatrix); } ); } // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
private void renderDepthMap(Window window, Camera camera, Scene scene) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float)Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float)Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes(); for (Mesh mesh : mapMeshes.keySet()) { mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> { Matrix4f modelLightViewMatrix = transformation.buildModelViewMatrix(gameItem, lightViewMatrix); depthShaderProgram.setUniform("modelLightViewMatrix", modelLightViewMatrix); } ); } // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
private void renderDepthMap(Window window, Camera camera, Scene scene) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float)Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float)Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes(); for (Mesh mesh : mapMeshes.keySet()) { mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> { Matrix4f modelLightViewMatrix = transformation.buildModelViewMatrix(gameItem, lightViewMatrix); depthShaderProgram.setUniform("modelLightViewMatrix", modelLightViewMatrix); } ); } // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, true, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, true, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { if (scene.isRenderShadows()) { // Setup view port to match the texture size glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT); depthShaderProgram.bind(); DirectionalLight light = scene.getSceneLight().getDirectionalLight(); Vector3f lightDirection = light.getDirection(); float lightAngleX = (float) Math.toDegrees(Math.acos(lightDirection.z)); float lightAngleY = (float) Math.toDegrees(Math.asin(lightDirection.x)); float lightAngleZ = 0; Matrix4f lightViewMatrix = transformation.updateLightViewMatrix(new Vector3f(lightDirection).mul(light.getShadowPosMult()), new Vector3f(lightAngleX, lightAngleY, lightAngleZ)); DirectionalLight.OrthoCoords orthCoords = light.getOrthoCoords(); Matrix4f orthoProjMatrix = transformation.updateOrthoProjectionMatrix(orthCoords.left, orthCoords.right, orthCoords.bottom, orthCoords.top, orthCoords.near, orthCoords.far); depthShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix); renderNonInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); renderInstancedMeshes(scene, depthShaderProgram, null, lightViewMatrix); // Unbind depthShaderProgram.unbind(); glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
private void renderDepthMap(Window window, Camera camera, Scene scene) { glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT);
private void renderDepthMap(Window window, Camera camera, Scene scene) { glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT);
private void renderDepthMap(Window window, Camera camera, Scene scene) { glBindFramebuffer(GL_FRAMEBUFFER, shadowMap.getDepthMapFBO()); glViewport(0, 0, ShadowMap.SHADOW_MAP_WIDTH, ShadowMap.SHADOW_MAP_HEIGHT); glClear(GL_DEPTH_BUFFER_BIT);