public void updateQuadtree(){ if (BaseContext.getCamera().isCameraMoved()){ updateCounter++; } if (updateCounter == updateThreshold){ synchronized(finishUpdateQuadtreeLock) { updateQuadtreeFinished = false; for (Node node : getChildren()){ ((QuadtreeChunk) node).updateQuadtree(leafChunks, formerLeafChunks); } updateCounter = 0; updateQuadtreeFinished = true; finishUpdateQuadtreeLock.notifyAll(); } } }
public void updateUniforms(GLTexture texture) { glActiveTexture(GL_TEXTURE0); texture.bind(); setUniformi("texture", 0); setUniformi("width", BaseContext.getWindow().getWidth()); setUniformi("height", BaseContext.getWindow().getHeight()); setUniformi("multisamples", BaseContext.getConfig().getMultisamples()); } }
if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_G)){ if (BaseContext.getConfig().isRenderWireframe()) BaseContext.getConfig().setRenderWireframe(false); else BaseContext.getConfig().setRenderWireframe(true); if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_1)){ if (renderAlbedoBuffer){ renderAlbedoBuffer = false; if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_2)){ if (renderNormalBuffer){ renderNormalBuffer = false; if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_3)){ if (renderPositionBuffer){ renderPositionBuffer = false; if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_4)){ if (renderSampleCoverageMask){ renderSampleCoverageMask = false; if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_5)){ if (renderSSAOBuffer){ renderSSAOBuffer = false; if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_6)){ if (renderDeferredLightingScene){ renderDeferredLightingScene = false;
public void render(GLTexture sceneSampler, GLTexture depthmap) { pixelVelocityShader.bind(); glBindImageTexture(0, pixelVelocityTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA32F); pixelVelocityShader.updateUniforms(BaseContext.getCamera().getProjectionMatrix(), BaseContext.getCamera().getViewProjectionMatrix().invert(), BaseContext.getCamera().getPreviousViewProjectionMatrix(), depthmap); glDispatchCompute(BaseContext.getWindow().getWidth()/8, BaseContext.getWindow().getHeight()/8, 1); glFinish(); motionBlurSceneTexture.bind(); motionBlurShader.bind(); glBindImageTexture(0, motionBlurSceneTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); glBindImageTexture(1, sceneSampler.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(2, pixelVelocityTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); motionBlurShader.updateUniforms(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight()); glDispatchCompute(BaseContext.getWindow().getWidth()/8, BaseContext.getWindow().getHeight()/8, 1); glFinish(); }
setUniform("projectionViewMatrix", BaseContext.getCamera().getViewProjectionMatrix()); setUniform("worldMatrix", object.getWorldTransform().getWorldMatrix()); setUniform("eyePosition", BaseContext.getCamera().getPosition()); setUniformi("windowWidth", BaseContext.getWindow().getWidth()); setUniformi("windowHeight", BaseContext.getWindow().getHeight()); setUniform("frustumPlanes[" + i +"]", BaseContext.getCamera().getFrustumPlanes()[i]); setUniformf("specular", configuration.getSpecular()); setUniformf("motion", ocean.getMotion()); setUniformi("isCameraUnderWater", BaseContext.getConfig().isRenderUnderwater() ? 1 : 0);
public void update() { if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_ADD)){ contrastFactor += 0.01f; } if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_SUBTRACT)){ contrastFactor -= 0.01f; } if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_MULTIPLY)){ brightnessFactor += 1f; } if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_KP_DIVIDE)){ brightnessFactor -= 1f; } }
BaseContext.getConfig().setRenderUnderwater(false); BaseContext.getConfig().setRenderUnderwater(true); BaseContext.getConfig().setClipplane(getClipplane()); glViewport(0,0,BaseContext.getWindow().getWidth()/2, BaseContext.getWindow().getHeight()/2); BaseContext.getConfig().setRenderReflection(true); reflectionRenderer.render(); BaseContext.getConfig().setRenderReflection(false); BaseContext.getConfig().setRenderRefraction(true); refractionRenderer.render(); BaseContext.getConfig().setRenderRefraction(false); BaseContext.getConfig().setClipplane(Constants.ZEROPLANE); glViewport(0,0,BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight());
public void render(GLTexture sceneSampler, GLTexture lightScatteringMask) { lightScatteringShader.bind(); glBindImageTexture(0, lightScatteringMask.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(1, sunLightScatteringTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); lightScatteringShader.updateUniforms(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight(), BaseContext.getCamera().getViewProjectionMatrix()); glDispatchCompute(BaseContext.getWindow().getWidth()/8, BaseContext.getWindow().getHeight()/8, 1); glFinish(); additiveBlendShader.bind(); glBindImageTexture(0, sunLightScatteringTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(1, sceneSampler.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(2, sunLightScatteringSceneTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); glDispatchCompute(BaseContext.getWindow().getWidth()/8, BaseContext.getWindow().getHeight()/8, 1); glFinish(); }
public MotionBlur() { pixelVelocityTexture = new Texture2DNoFilterRGBA32F(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight()); motionBlurSceneTexture = new Texture2DStorageRGBA16F(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight(),1); pixelVelocityShader = PixelVelocityShader.getInstance(); motionBlurShader = MotionBlurShader.getInstance(); }
public void getTerrainPosition(){ if (isActive() && glfwGetMouseButton(BaseContext.getWindow().getId(),1) == GLFW_PRESS){ Vec3f pos = new Vec3f(0,0,0); DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1); DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1); glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos); Vec2f screenPos = new Vec2f((float) xPos.get(),(float) yPos.get()); float depth = depthmapBuffer.get((int) (BaseContext.getWindow().getWidth() * screenPos.getY() + screenPos.getX())); Vec2f w = new Vec2f(screenPos.getX()/BaseContext.getWindow().getWidth(), screenPos.getY()/BaseContext.getWindow().getHeight()); float cw = BaseContext.getCamera().getProjectionMatrix().get(3,2) / (ndc.getZ() - BaseContext.getCamera().getProjectionMatrix().get(2,2)); Vec3f clip = ndc.mul(cw); Vec4f clipPos = new Vec4f(clip.getX(),clip.getY(),clip.getZ(),cw); Vec4f worldPos = BaseContext.getCamera().getViewProjectionMatrix().invert().mul(clipPos); worldPos = worldPos.div(worldPos.getW());
if (BaseContext.getInput().isKeyPushed(GLFW.GLFW_KEY_L)){
@Override public void updateUBOs(){ getHighPolyIndices().clear(); int index = 0; for (Matrix4f transform : getWorldMatrices()){ if (transform.getTranslation().sub(BaseContext.getCamera().getPosition()).length() < 220){ getHighPolyIndices().add(index); } index++; } getHighPolyInstances().setValue(getHighPolyIndices().size()); }