Fixed viewport uniforms binding

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9561 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 2a18784041
commit 96ae823504
  1. 1
      engine/src/core/com/jme3/renderer/RenderManager.java
  2. 24
      engine/src/core/com/jme3/shader/UniformBindingManager.java

@ -813,6 +813,7 @@ public class RenderManager {
viewY = (int) (cam.getViewPortBottom() * cam.getHeight());
viewWidth = (int) ((cam.getViewPortRight() - cam.getViewPortLeft()) * cam.getWidth());
viewHeight = (int) ((cam.getViewPortTop() - cam.getViewPortBottom()) * cam.getHeight());
uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
cam.clearViewportChanged();

@ -7,6 +7,7 @@ package com.jme3.shader;
import com.jme3.math.*;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.system.Timer;
import java.util.List;
@ -21,7 +22,7 @@ import java.util.List;
* @author Kirill Vainer
*/
public class UniformBindingManager {
private Timer timer;
private float near, far;
private int viewX, viewY, viewWidth, viewHeight;
@ -29,18 +30,14 @@ public class UniformBindingManager {
camLeft = new Vector3f(),
camDir = new Vector3f(),
camLoc = new Vector3f();
private Matrix4f tempMatrix = new Matrix4f();
private Matrix4f viewMatrix = new Matrix4f();
private Matrix4f projMatrix = new Matrix4f();
private Matrix4f viewProjMatrix = new Matrix4f();
private Matrix4f worldMatrix = new Matrix4f();
private Matrix4f worldViewMatrix = new Matrix4f();
private Matrix4f worldViewProjMatrix = new Matrix4f();
private Matrix3f normalMatrix = new Matrix3f();
private Matrix4f worldMatrixInv = new Matrix4f();
private Matrix4f viewMatrixInv = new Matrix4f();
private Matrix4f projMatrixInv = new Matrix4f();
@ -48,12 +45,11 @@ public class UniformBindingManager {
private Matrix4f worldViewMatrixInv = new Matrix4f();
private Matrix3f normalMatrixInv = new Matrix3f();
private Matrix4f worldViewProjMatrixInv = new Matrix4f();
private Vector4f viewPort = new Vector4f();
private Vector2f resolution = new Vector2f();
private Vector2f resolutionInv = new Vector2f();
private Vector2f nearFar = new Vector2f();
/**
* Internal use only.
* Updates the given list of uniforms with {@link UniformBinding uniform bindings}
@ -183,7 +179,7 @@ public class UniformBindingManager {
}
}
}
/**
* Internal use only. Sets the world matrix to use for future
* rendering. This has no effect unless objects are rendered manually
@ -196,7 +192,7 @@ public class UniformBindingManager {
public void setWorldMatrix(Matrix4f mat) {
worldMatrix.set(mat);
}
/**
* Set the timer that should be used to query the time based
* {@link UniformBinding}s for material world parameters.
@ -206,7 +202,7 @@ public class UniformBindingManager {
public void setTimer(com.jme3.system.Timer timer) {
this.timer = timer;
}
public void setCamera(Camera cam, Matrix4f viewMatrix, Matrix4f projMatrix, Matrix4f viewProjMatrix) {
this.viewMatrix.set(viewMatrix);
this.projMatrix.set(projMatrix);
@ -220,5 +216,11 @@ public class UniformBindingManager {
near = cam.getFrustumNear();
far = cam.getFrustumFar();
}
public void setViewPort(int viewX, int viewY, int viewWidth, int viewHeight) {
this.viewX = viewX;
this.viewY = viewY;
this.viewWidth = viewWidth;
this.viewHeight = viewHeight;
}
}

Loading…
Cancel
Save