translation.setY(terrainHeight); Matrix4f translationMatrix = new Matrix4f().Translation(translation); Matrix4f rotationMatrix = new Matrix4f().Rotation(rotation); Matrix4f scalingMatrix = new Matrix4f().Scaling(scaling); getWorldMatrices().add(translationMatrix.mul(scalingMatrix.mul(rotationMatrix))); getModelMatrices().add(rotationMatrix); getHighPolyIndices().add(i);
public UIElement(int xPos, int yPos, int xScaling, int yScaling){ super(); setOrthographicMatrix(new Matrix4f().Orthographic2D()); getWorldTransform().setTranslation(xPos, yPos, 0); getWorldTransform().setScaling(xScaling, yScaling, 0); setOrthographicMatrix(getOrthographicMatrix().mul(getWorldTransform().getWorldMatrix())); }
public LensFlareTexturePanel() { super(); orthographicMatrix = new Matrix4f().Orthographic2D(); orthoTransform = new Transform(); setConfig(new AdditiveBlending()); setShader(LensFlareShader.getInstance()); }
public void updateUniforms(Renderable object) { bindUniformBlock("Camera", Constants.CameraUniformBlockBinding); setUniformi("isReflection", BaseContext.getConfig().isRenderReflection() ? 1 : 0); ((GLInstancedCluster) object.getParentNode()).getWorldMatricesBuffer().bindBufferBase(0); bindUniformBlock("worldMatrices", 0); ((GLInstancedCluster) object.getParentNode()).getModelMatricesBuffer().bindBufferBase(1); bindUniformBlock("modelMatrices", 1); setUniform("clipplane", BaseContext.getConfig().getClipplane()); setUniform("scalingMatrix", new Matrix4f().Scaling(object.getWorldTransform().getScaling())); List<Integer> indices = ((InstancedCluster) object.getParentNode()).getHighPolyIndices(); for (int i=0; i<indices.size(); i++) { setUniformi("matrixIndices[" + i +"]", indices.get(i)); } } }
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());
protected void computeWorldPos(){ Vec2f chunkCenter = location.add(gap/2f); Vec4f worldPosition = getWorldTransform().getWorldMatrixRTS().mul( new Vec4f(chunkCenter.getX(),0,chunkCenter.getY(),1)); worldPosition = worldPosition.normalize(); worldPosition = worldPosition.mul(terrainProperties.getHorizontalScaling()); // TODO displacment // Vec3f displacement = TerrainHelper.getTerrainHeight(terrainProperties, loc.getX(), loc.getY()); // System.out.println(worldPosition); worldPos = worldPosition.xyz(); }
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 updateUniforms(Renderable object) { bindUniformBlock("Camera", Constants.CameraUniformBlockBinding); setUniformi("isReflection", BaseContext.getConfig().isRenderReflection() ? 1 : 0); ((GLInstancedCluster) object.getParentNode()).getWorldMatricesBuffer().bindBufferBase(0); bindUniformBlock("worldMatrices", 0); ((GLInstancedCluster) object.getParentNode()).getModelMatricesBuffer().bindBufferBase(1); bindUniformBlock("modelMatrices", 1); setUniform("clipplane", BaseContext.getConfig().getClipplane()); setUniform("scalingMatrix", new Matrix4f().Scaling(object.getWorldTransform().getScaling())); @SuppressWarnings("unchecked") Material<GLTexture> material = (Material<GLTexture>) object.getComponent(NodeComponentType.MATERIAL0); setUniform("material.color", material.getColor()); // setUniformf("material.emission", material.getEmission()); // setUniformf("material.shininess", material.getShininess()); List<Integer> indices = ((InstancedCluster) object.getParentNode()).getHighPolyIndices(); for (int i=0; i<indices.size(); i++) { setUniformi("matrixIndices[" + i +"]", indices.get(i)); } } }
public GLButton(int xPos, int yPos, int xScaling, int yScaling, Mesh panelMesh){ super(xPos, yPos, xScaling, yScaling); pos = new Vec2f[4]; shader = UITextPanelShader.getInstance(); vao = new GUIVAO(); config = new DefaultRenderParams(); vao.addData(panelMesh); Vec4f q0 = new Vec4f(0,0,0,0); Vec4f q1 = new Vec4f(0,0,0,0); Vec4f q2 = new Vec4f(0,0,0,0); Vec4f q3 = new Vec4f(0,0,0,0); q0 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[0].getPosition(),1)); q1 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[1].getPosition(),1)); q2 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[2].getPosition(),1)); q3 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[3].getPosition(),1)); pos[0] = new Vec2f(q0.getX(),q0.getY()+5); pos[1] = new Vec2f(q1.getX(),q1.getY()+5); pos[2] = new Vec2f(q2.getX()-7,q2.getY()-5); pos[3] = new Vec2f(q3.getX()-7,q3.getY()-5); }
translation.setY(terrainHeight); Matrix4f translationMatrix = new Matrix4f().Translation(translation); Matrix4f rotationMatrix = new Matrix4f().Rotation(rotation); Matrix4f scalingMatrix = new Matrix4f().Scaling(scaling); getWorldMatrices().add(translationMatrix.mul(scalingMatrix.mul(rotationMatrix))); getModelMatrices().add(rotationMatrix); getHighPolyIndices().add(i);
texturePanel0.setTexture(new Texture2DBilinearFilter("textures/lens_flare/tex4.png")); texturePanel0.getOrthoTransform().setScaling(200,200,0); texturePanel0.setOrthographicMatrix(new Matrix4f().Orthographic2D().mul(texturePanel0.getOrthoTransform().getWorldMatrix())); texturePanel0.setSpacing(0.06f); texturePanel0.setBrightness(0.2f); texturePanel1.setTexture(new Texture2DBilinearFilter("textures/lens_flare/tex01.png")); texturePanel1.getOrthoTransform().setScaling(400,400,0); texturePanel1.setOrthographicMatrix(new Matrix4f().Orthographic2D().mul(texturePanel1.getOrthoTransform().getWorldMatrix())); texturePanel1.setSpacing(0.0f); texturePanel1.setBrightness(0.4f); texturePanel2.setTexture(new Texture2DBilinearFilter("textures/lens_flare/tex2.png")); texturePanel2.getOrthoTransform().setScaling(250,250,0); texturePanel2.setOrthographicMatrix(new Matrix4f().Orthographic2D().mul(texturePanel2.getOrthoTransform().getWorldMatrix())); texturePanel2.setSpacing(0.2f); texturePanel2.setBrightness(0.25f); texturePanel3.setTexture(new Texture2DBilinearFilter("textures/lens_flare/tex7.png")); texturePanel3.getOrthoTransform().setScaling(200,200,0); texturePanel3.setOrthographicMatrix(new Matrix4f().Orthographic2D().mul(texturePanel3.getOrthoTransform().getWorldMatrix())); texturePanel3.setSpacing(0.4f); texturePanel3.setBrightness(0.2f); texturePanel4.setTexture(new Texture2DBilinearFilter("textures/lens_flare/tex5.png")); texturePanel4.getOrthoTransform().setScaling(100,100,0); texturePanel4.setOrthographicMatrix(new Matrix4f().Orthographic2D().mul(texturePanel4.getOrthoTransform().getWorldMatrix())); texturePanel4.setSpacing(0.6f); texturePanel4.setBrightness(0.2f);
public void updateUniforms(Renderable object){ setUniform("clipplane", BaseContext.getConfig().getClipplane()); bindUniformBlock("Camera", Constants.CameraUniformBlockBinding); setUniformi("isReflection", BaseContext.getConfig().isRenderReflection() ? 1 : 0); setUniform("scalingMatrix", new Matrix4f().Scaling(object.getWorldTransform().getScaling())); ((GLInstancedCluster) object.getParentNode()).getWorldMatricesBuffer().bindBufferBase(0); bindUniformBlock("worldMatrices", 0); ((GLInstancedCluster) object.getParentNode()).getModelMatricesBuffer().bindBufferBase(1); bindUniformBlock("modelMatrices", 1); @SuppressWarnings("unchecked") Material<GLTexture> material = (Material<GLTexture>) object.getComponent(NodeComponentType.MATERIAL0); glActiveTexture(GL_TEXTURE0); material.getDiffusemap().bind(); setUniformi("material.diffusemap", 0); List<Integer> indices = ((InstancedCluster) object.getParentNode()).getLowPolyIndices(); for (int i=0; i<indices.size(); i++) { setUniformi("matrixIndices[" + i +"]", indices.get(i)); } } }
translation.setY(terrainHeight); Matrix4f translationMatrix = new Matrix4f().Translation(translation); Matrix4f rotationMatrix = new Matrix4f().Rotation(rotation); Matrix4f scalingMatrix = new Matrix4f().Scaling(scaling); getWorldMatrices().add(translationMatrix.mul(scalingMatrix.mul(rotationMatrix))); getModelMatrices().add(rotationMatrix); getHighPolyIndices().add(i);
- lensFlareTexture.getOrthoTransform().getScaling().getY()/2f); lensFlareTexture.setOrthographicMatrix( new Matrix4f().Orthographic2D().mul(lensFlareTexture.getOrthoTransform().getWorldMatrix()));
public void updateUniforms(Renderable object) { bindUniformBlock("Camera", Constants.CameraUniformBlockBinding); // setUniformi("screenWidth", CoreSystem.getInstance().getWindow().getWidth()); // setUniformi("screenHeight", CoreSystem.getInstance().getWindow().getHeight()); setUniformi("isReflection", BaseContext.getConfig().isRenderReflection() ? 1 : 0); ((GLInstancedCluster) object.getParentNode()).getWorldMatricesBuffer().bindBufferBase(0); bindUniformBlock("worldMatrices", 0); ((GLInstancedCluster) object.getParentNode()).getModelMatricesBuffer().bindBufferBase(1); bindUniformBlock("modelMatrices", 1); setUniform("clipplane", BaseContext.getConfig().getClipplane()); setUniform("scalingMatrix", new Matrix4f().Scaling(object.getWorldTransform().getScaling())); @SuppressWarnings("unchecked") Material<GLTexture> material = (Material<GLTexture>) object.getComponent(NodeComponentType.MATERIAL0); glActiveTexture(GL_TEXTURE0); material.getDiffusemap().bind(); setUniformi("material.diffusemap", 0); List<Integer> indices = ((InstancedCluster) object.getParentNode()).getHighPolyIndices(); for (int i=0; i<indices.size(); i++) { setUniformi("matrixIndices[" + i +"]", indices.get(i)); } } }
translation.setY(terrainHeight); Matrix4f translationMatrix = new Matrix4f().Translation(translation); Matrix4f rotationMatrix = new Matrix4f().Rotation(rotation); Matrix4f scalingMatrix = new Matrix4f().Scaling(scaling); getWorldMatrices().add(translationMatrix.mul(scalingMatrix.mul(rotationMatrix))); getModelMatrices().add(rotationMatrix); getHighPolyIndices().add(i);
public void updateUniforms(Renderable object){ setUniform("clipplane", BaseContext.getConfig().getClipplane()); bindUniformBlock("Camera", Constants.CameraUniformBlockBinding); setUniformi("isReflection", BaseContext.getConfig().isRenderReflection() ? 1 : 0); setUniformi("isRefraction", BaseContext.getConfig().isRenderRefraction() ? 1 : 0); setUniform("scalingMatrix", new Matrix4f().Scaling(object.getWorldTransform().getScaling())); ((GLInstancedCluster) object.getParentNode()).getWorldMatricesBuffer().bindBufferBase(0); bindUniformBlock("worldMatrices", 0); ((GLInstancedCluster) object.getParentNode()).getModelMatricesBuffer().bindBufferBase(1); bindUniformBlock("modelMatrices", 1); @SuppressWarnings("unchecked") Material<GLTexture> material = (Material<GLTexture>) object.getComponent(NodeComponentType.MATERIAL0); glActiveTexture(GL_TEXTURE0); material.getDiffusemap().bind(); setUniformi("material.diffusemap", 0); List<Integer> indices = ((InstancedCluster) object.getParentNode()).getLowPolyIndices(); for (int i=0; i<indices.size(); i++) { setUniformi("matrixIndices[" + i +"]", indices.get(i)); } } }