private void setupLights() { SceneLight sceneLight = new SceneLight(); scene.setSceneLight(sceneLight); // Ambient Light sceneLight.setAmbientLight(new Vector3f(0.3f, 0.3f, 0.3f)); sceneLight.setSkyBoxLight(new Vector3f(1.0f, 1.0f, 1.0f)); // Directional Light float lightIntensity = 1.0f; Vector3f lightDirection = new Vector3f(0, 1, 1); DirectionalLight directionalLight = new DirectionalLight(new Vector3f(1, 1, 1), lightDirection, lightIntensity); sceneLight.setDirectionalLight(directionalLight); }
DirectionalLight directionalLight = sceneLight.getDirectionalLight(); lightAngle += 1.1f; if (lightAngle > 90) { lightAngle = -90; sceneLight.getAmbientLight().set(0.3f, 0.3f, 0.4f); } else if (lightAngle <= -80 || lightAngle >= 80) { float factor = 1 - (float) (Math.abs(lightAngle) - 80) / 10.0f; sceneLight.getAmbientLight().set(factor, factor, factor); directionalLight.setIntensity(factor); directionalLight.getColor().y = Math.max(factor, 0.9f); directionalLight.getColor().z = Math.max(factor, 0.5f); } else { sceneLight.getAmbientLight().set(1, 1, 1); directionalLight.setIntensity(1); directionalLight.getColor().x = 1;
private void setupLights() { SceneLight sceneLight = new SceneLight(); scene.setSceneLight(sceneLight); // Ambient Light sceneLight.setAmbientLight(new Vector3f(1.0f, 1.0f, 1.0f)); // Directional Light float lightIntensity = 1.0f; Vector3f lightPosition = new Vector3f(-1, 0, 0); sceneLight.setDirectionalLight(new DirectionalLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity)); }
private void renderLights(Matrix4f viewMatrix, SceneLight sceneLight) { sceneShaderProgram.setUniform("ambientLight", sceneLight.getAmbientLight()); sceneShaderProgram.setUniform("specularPower", specularPower); PointLight[] pointLightList = sceneLight.getPointLightList(); int numLights = pointLightList != null ? pointLightList.length : 0; for (int i = 0; i < numLights; i++) { SpotLight[] spotLightList = sceneLight.getSpotLightList(); numLights = spotLightList != null ? spotLightList.length : 0; for (int i = 0; i < numLights; i++) { DirectionalLight currDirLight = new DirectionalLight(sceneLight.getDirectionalLight()); Vector4f dir = new Vector4f(currDirLight.getDirection(), 0); dir.mul(viewMatrix);
private void update(Window window, Matrix4f viewMatrix, Scene scene) { SceneLight sceneLight = scene.getSceneLight(); DirectionalLight directionalLight = sceneLight != null ? sceneLight.getDirectionalLight() : null; for (int i = 0; i < NUM_CASCADES; i++) { ShadowCascade shadowCascade = shadowCascades.get(i); shadowCascade.update(window, viewMatrix, directionalLight); } }
private void renderSkyBox(Window window, Camera camera, Scene scene) { skyBoxShaderProgram.bind(); skyBoxShaderProgram.setUniform("texture_sampler", 0); Matrix4f projectionMatrix = transformation.getProjectionMatrix(); skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix); SkyBox skyBox = scene.getSkyBox(); Matrix4f viewMatrix = transformation.getViewMatrix(); viewMatrix.m30(0); viewMatrix.m31(0); viewMatrix.m32(0); Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix); skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix); skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight()); scene.getSkyBox().getMesh().render(); skyBoxShaderProgram.unbind(); }
SpotLight[] spotLightList = sceneLight.getSpotLightList(); Vector3f coneDir = spotLightList[0].getConeDirection(); coneDir.y = (float) Math.sin(spotAngleRad); DirectionalLight directionalLight = sceneLight.getDirectionalLight(); lightAngle += 1.1f; if (lightAngle > 90) {
@Override public void input(Window window, MouseInput mouseInput) { cameraInc.set(0, 0, 0); if (window.isKeyPressed(GLFW_KEY_W)) { cameraInc.z = -1; } else if (window.isKeyPressed(GLFW_KEY_S)) { cameraInc.z = 1; } if (window.isKeyPressed(GLFW_KEY_A)) { cameraInc.x = -1; } else if (window.isKeyPressed(GLFW_KEY_D)) { cameraInc.x = 1; } if (window.isKeyPressed(GLFW_KEY_Z)) { cameraInc.y = -1; } else if (window.isKeyPressed(GLFW_KEY_X)) { cameraInc.y = 1; } SpotLight[] spotLightList = sceneLight.getSpotLightList(); float lightPos = spotLightList[0].getPointLight().getPosition().z; if (window.isKeyPressed(GLFW_KEY_N)) { spotLightList[0].getPointLight().getPosition().z = lightPos + 0.1f; } else if (window.isKeyPressed(GLFW_KEY_M)) { spotLightList[0].getPointLight().getPosition().z = lightPos - 0.1f; } }
private void renderSkyBox(Window window, Camera camera, Scene scene) { skyBoxShaderProgram.bind(); skyBoxShaderProgram.setUniform("texture_sampler", 0); Matrix4f projectionMatrix = transformation.getProjectionMatrix(); skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix); SkyBox skyBox = scene.getSkyBox(); Matrix4f viewMatrix = transformation.getViewMatrix(); viewMatrix.m30(0); viewMatrix.m31(0); viewMatrix.m32(0); Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix); skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix); skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getAmbientLight()); scene.getSkyBox().getMesh().render(); skyBoxShaderProgram.unbind(); }
private void renderLights(Matrix4f viewMatrix, SceneLight sceneLight) { sceneShaderProgram.setUniform("ambientLight", sceneLight.getAmbientLight()); sceneShaderProgram.setUniform("specularPower", specularPower); PointLight[] pointLightList = sceneLight.getPointLightList(); int numLights = pointLightList != null ? pointLightList.length : 0; for (int i = 0; i < numLights; i++) { SpotLight[] spotLightList = sceneLight.getSpotLightList(); numLights = spotLightList != null ? spotLightList.length : 0; for (int i = 0; i < numLights; i++) { DirectionalLight currDirLight = new DirectionalLight(sceneLight.getDirectionalLight()); Vector4f dir = new Vector4f(currDirLight.getDirection(), 0); dir.mul(viewMatrix);
private void update(Window window, Matrix4f viewMatrix, Scene scene) { SceneLight sceneLight = scene.getSceneLight(); DirectionalLight directionalLight = sceneLight != null ? sceneLight.getDirectionalLight() : null; for (int i = 0; i < NUM_CASCADES; i++) { ShadowCascade shadowCascade = shadowCascades.get(i); shadowCascade.update(window, viewMatrix, directionalLight); } }
private void setupLights() { SceneLight sceneLight = new SceneLight(); scene.setSceneLight(sceneLight); // Ambient Light sceneLight.setAmbientLight(new Vector3f(1.0f, 1.0f, 1.0f)); // Directional Light float lightIntensity = 1.0f; Vector3f lightPosition = new Vector3f(-1, 0, 0); sceneLight.setDirectionalLight(new DirectionalLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity)); }
private void renderSkyBox(Window window, Camera camera, Scene scene) { skyBoxShaderProgram.bind(); skyBoxShaderProgram.setUniform("texture_sampler", 0); Matrix4f projectionMatrix = transformation.getProjectionMatrix(); skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix); SkyBox skyBox = scene.getSkyBox(); Matrix4f viewMatrix = transformation.getViewMatrix(); viewMatrix.m30(0); viewMatrix.m31(0); viewMatrix.m32(0); Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix); skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix); skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight()); scene.getSkyBox().getMesh().render(); skyBoxShaderProgram.unbind(); }
@Override public void input(Window window, MouseInput mouseInput) { cameraInc.set(0, 0, 0); if (window.isKeyPressed(GLFW_KEY_W)) { cameraInc.z = -1; } else if (window.isKeyPressed(GLFW_KEY_S)) { cameraInc.z = 1; } if (window.isKeyPressed(GLFW_KEY_A)) { cameraInc.x = -1; } else if (window.isKeyPressed(GLFW_KEY_D)) { cameraInc.x = 1; } if (window.isKeyPressed(GLFW_KEY_Z)) { cameraInc.y = -1; } else if (window.isKeyPressed(GLFW_KEY_X)) { cameraInc.y = 1; } SpotLight[] spotLightList = sceneLight.getSpotLightList(); float lightPos = spotLightList[0].getPointLight().getPosition().z; if (window.isKeyPressed(GLFW_KEY_N)) { spotLightList[0].getPointLight().getPosition().z = lightPos + 0.1f; } else if (window.isKeyPressed(GLFW_KEY_M)) { spotLightList[0].getPointLight().getPosition().z = lightPos - 0.1f; } }
private void renderSkyBox(Window window, Camera camera, Scene scene) { skyBoxShaderProgram.bind(); skyBoxShaderProgram.setUniform("texture_sampler", 0); // Update projection Matrix Matrix4f projectionMatrix = transformation.getProjectionMatrix(FOV, window.getWidth(), window.getHeight(), Z_NEAR, Z_FAR); skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix); SkyBox skyBox = scene.getSkyBox(); Matrix4f viewMatrix = transformation.getViewMatrix(camera); viewMatrix.m30(0); viewMatrix.m31(0); viewMatrix.m32(0); Matrix4f modelViewMatrix = transformation.getModelViewMatrix(skyBox, viewMatrix); skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix); skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getAmbientLight()); scene.getSkyBox().getMesh().render(); skyBoxShaderProgram.unbind(); }
private void renderLights(Matrix4f viewMatrix, SceneLight sceneLight) { sceneShaderProgram.setUniform("ambientLight", sceneLight.getAmbientLight()); sceneShaderProgram.setUniform("specularPower", specularPower); PointLight[] pointLightList = sceneLight.getPointLightList(); int numLights = pointLightList != null ? pointLightList.length : 0; for (int i = 0; i < numLights; i++) { SpotLight[] spotLightList = sceneLight.getSpotLightList(); numLights = spotLightList != null ? spotLightList.length : 0; for (int i = 0; i < numLights; i++) { DirectionalLight currDirLight = new DirectionalLight(sceneLight.getDirectionalLight()); Vector4f dir = new Vector4f(currDirLight.getDirection(), 0); dir.mul(viewMatrix);
private void setupLights() { SceneLight sceneLight = new SceneLight(); scene.setSceneLight(sceneLight); // Ambient Light sceneLight.setAmbientLight(new Vector3f(0.3f, 0.3f, 0.3f)); sceneLight.setSkyBoxLight(new Vector3f(1.0f, 1.0f, 1.0f)); // Directional Light float lightIntensity = 1.0f; Vector3f lightPosition = new Vector3f(1, 1, 0); sceneLight.setDirectionalLight(new DirectionalLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity)); }
private void update(Window window, Matrix4f viewMatrix, Scene scene) { SceneLight sceneLight = scene.getSceneLight(); DirectionalLight directionalLight = sceneLight != null ? sceneLight.getDirectionalLight() : null; for (int i = 0; i < NUM_CASCADES; i++) { ShadowCascade shadowCascade = shadowCascades.get(i); shadowCascade.update(window, viewMatrix, directionalLight); } }
DirectionalLight directionalLight = sceneLight.getDirectionalLight(); lightAngle += 1.1f; if (lightAngle > 90) { lightAngle = -90; sceneLight.getAmbientLight().set(0.3f, 0.3f, 0.4f); } else if (lightAngle <= -80 || lightAngle >= 80) { float factor = 1 - (float) (Math.abs(lightAngle) - 80) / 10.0f; sceneLight.getAmbientLight().set(factor, factor, factor); directionalLight.setIntensity(factor); directionalLight.getColor().y = Math.max(factor, 0.9f); directionalLight.getColor().z = Math.max(factor, 0.5f); } else { sceneLight.getAmbientLight().set(1, 1, 1); directionalLight.setIntensity(1); directionalLight.getColor().x = 1;
private void renderSkyBox(Window window, Camera camera, Scene scene) { skyBoxShaderProgram.bind(); skyBoxShaderProgram.setUniform("texture_sampler", 0); Matrix4f projectionMatrix = transformation.getProjectionMatrix(); skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix); SkyBox skyBox = scene.getSkyBox(); Matrix4f viewMatrix = transformation.getViewMatrix(); viewMatrix.m30(0); viewMatrix.m31(0); viewMatrix.m32(0); Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix); skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix); skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight()); scene.getSkyBox().getMesh().render(); skyBoxShaderProgram.unbind(); }