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 SunLightScattering() { lightScatteringShader = SunLightScatteringShader.getInstance(); additiveBlendShader = SunLightScatteringAdditiveBlendShader.getInstance(); sunLightScatteringTexture = new Texture2DBilinearFilterRGBA16F(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight()); sunLightScatteringTexture.bind(); sunLightScatteringTexture.clampToEdge(); sunLightScatteringTexture.unbind(); sunLightScatteringSceneTexture = new Texture2DBilinearFilterRGBA16F(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight()); sunLightScatteringSceneTexture.bind(); sunLightScatteringSceneTexture.clampToEdge(); sunLightScatteringSceneTexture.unbind(); }
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()); } }
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 void render(GLTexture sceneSampler) { contrastShader.bind(); glBindImageTexture(0, sceneSampler.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(1, contrastTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); contrastShader.updateUniforms(contrastFactor, brightnessFactor); glDispatchCompute(BaseContext.getWindow().getWidth()/16, BaseContext.getWindow().getHeight()/16, 1); glFinish(); }
public boolean onClick() { DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1); DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1); glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos); Vec2f mousePos = new Vec2f((float) xPos.get(),(float) yPos.get()); if(pos[0].getX() < mousePos.getX() && pos[1].getX() < mousePos.getX() && pos[2].getX() > mousePos.getX() && pos[3].getX() > mousePos.getX() && pos[0].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && pos[3].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && pos[1].getY() > BaseContext.getWindow().getHeight() - mousePos.getY() && pos[2].getY() > BaseContext.getWindow().getHeight() - mousePos.getY()) { return true; } else return false; }
public void updateUniforms(Matrix4f projectionMatrix, Matrix4f inverseViewProjectionMatrix, Matrix4f previousViewProjectionMatrix, GLTexture depthmap) { glActiveTexture(GL_TEXTURE0); depthmap.bind(); setUniformi("depthmap", 0); setUniformf("windowWidth", BaseContext.getWindow().getWidth()); setUniformf("windowHeight", BaseContext.getWindow().getHeight()); setUniform("projectionMatrix", projectionMatrix); setUniform("inverseViewProjectionMatrix", inverseViewProjectionMatrix); setUniform("previousViewProjectionMatrix", previousViewProjectionMatrix); } }
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(); }
public void render(GLTexture sceneTexture, GLTexture sceneDepthMap) { underWaterShader.bind(); glBindImageTexture(0, sceneTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(1, underwaterSceneTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); underWaterShader.updateUniforms(sceneDepthMap); glDispatchCompute(BaseContext.getWindow().getWidth()/8, BaseContext.getWindow().getHeight()/8, 1); glFinish(); distortion += distortion_delta; GLContext.getResources().setUnderwaterDistortion(distortion); }
public UnderWaterRenderer() { underWaterShader = UnderWaterShader.getInstance(); underwaterSceneTexture = new Texture2DBilinearFilterRGBA16F(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight()); underwaterSceneTexture.bind(); underwaterSceneTexture.clampToEdge(); underwaterSceneTexture.unbind(); dudvMap = new Texture2DTrilinearFilter("textures/water/dudv/dudv1.jpg"); causticsMap = new Texture2DTrilinearFilter("textures/water/caustics/caustics.jpg"); GLContext.getResources().setUnderwaterCausticsMap(causticsMap); GLContext.getResources().setUnderwaterDudvMap(dudvMap); }
public void render(GLTexture worldPositionTexture, GLTexture LightScatteringMaskMS) { shader.bind(); glBindImageTexture(0, sampleCoverageMask.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_R16F); glBindImageTexture(1, worldPositionTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); glBindImageTexture(2, lightScatteringMaskDownSampled.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); glBindImageTexture(3, LightScatteringMaskMS.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); shader.updateUniforms(); glDispatchCompute(BaseContext.getWindow().getWidth()/16, BaseContext.getWindow().getHeight()/16, 1); }
public void render(GLTexture opaqueScene, GLTexture opaqueSceneDepthMap, GLTexture opaqueSceneLightScatteringTexture, GLTexture transparencyLayer, GLTexture transparencyLayerDepthMap, GLTexture alphaMap, GLTexture transparencyLayerLightScatteringTexture){ shader.bind(); glBindImageTexture(0, blendedSceneTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); glBindImageTexture(1, blendedLightScatteringTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); glBindImageTexture(2, opaqueSceneDepthMap.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); glBindImageTexture(3, transparencyLayerDepthMap.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); shader.updateUniforms(opaqueScene, opaqueSceneLightScatteringTexture, transparencyLayer, alphaMap, transparencyLayerLightScatteringTexture); glDispatchCompute(BaseContext.getWindow().getWidth()/16, BaseContext.getWindow().getHeight()/16, 1); }
public void render(GLTexture sampleCoverageMask, GLTexture ssaoBlurTexture, GLTexture pssm, GLTexture offScreenAlbedoTexture, GLTexture offScreenWorldPositionTexture, GLTexture offScreenNormalTexture, GLTexture offScreenSpecularEmissionTexture, boolean ssaoFlag){ shader.bind(); glBindImageTexture(0, deferredLightingSceneTexture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F); glBindImageTexture(2, offScreenAlbedoTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(3, offScreenWorldPositionTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); glBindImageTexture(4, offScreenNormalTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); glBindImageTexture(5, offScreenSpecularEmissionTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA16F); glBindImageTexture(6, sampleCoverageMask.getHandle(), 0, false, 0, GL_READ_ONLY, GL_R16F); glBindImageTexture(7, ssaoBlurTexture.getHandle(), 0, false, 0, GL_READ_ONLY, GL_RGBA32F); shader.updateUniforms(pssm, ssaoFlag); glDispatchCompute(BaseContext.getWindow().getWidth()/16, BaseContext.getWindow().getHeight()/16,1); }