浏览代码

Add getInverseProj() for camera
Add BeforeTonemappingFX step

ShiroSmith 5 年之前
父节点
当前提交
053bf13b11
共有 3 个文件被更改,包括 25 次插入8 次删除
  1. 23 8
      h3d/Camera.hx
  2. 1 0
      h3d/impl/RendererFX.hx
  3. 1 0
      h3d/scene/pbr/Renderer.hx

+ 23 - 8
h3d/Camera.hx

@@ -44,7 +44,8 @@ class Camera {
 	public var frustum(default, null) : h3d.col.Frustum;
 	public var frustum(default, null) : h3d.col.Frustum;
 
 
 	var minv : Matrix;
 	var minv : Matrix;
-	var miview : Matrix;
+	var mcamInv : Matrix;
+	var mprojInv : Matrix;
 	var needInv : Bool;
 	var needInv : Bool;
 
 
 	public function new( fovY = 25., zoom = 1., screenRatio = 1.333333, zNear = 0.02, zFar = 4000., rightHanded = false ) {
 	public function new( fovY = 25., zoom = 1., screenRatio = 1.333333, zNear = 0.02, zFar = 4000., rightHanded = false ) {
@@ -103,17 +104,30 @@ class Camera {
 		return minv;
 		return minv;
 	}
 	}
 
 
+	/**
+		Returns the inverse of the camera matrix projection. Cache the result until the next update().
+	**/
+	public function getInverseProj() {
+		if( mprojInv == null ) {
+			mprojInv = new h3d.Matrix();
+			mprojInv._44 = 0;
+		}
+		if( mprojInv._44 == 0 )
+			mprojInv.initInverse(mproj);
+		return mprojInv;
+	}
+
 	/**
 	/**
 		Returns the inverse of the camera matrix view only. Cache the result until the next update().
 		Returns the inverse of the camera matrix view only. Cache the result until the next update().
 	**/
 	**/
 	public function getInverseView() {
 	public function getInverseView() {
-		if( miview == null ) {
-			miview = new h3d.Matrix();
-			miview._44 = 0;
+		if( mcamInv == null ) {
+			mcamInv = new h3d.Matrix();
+			mcamInv._44 = 0;
 		}
 		}
-		if( miview._44 == 0 )
-			miview.initInverse(mcam);
-		return miview;
+		if( mcamInv._44 == 0 )
+			mcamInv.initInverse(mcam);
+		return mcamInv;
 	}
 	}
 
 
 	/**
 	/**
@@ -181,7 +195,8 @@ class Camera {
 		m.multiply(mcam, mproj);
 		m.multiply(mcam, mproj);
 
 
 		needInv = true;
 		needInv = true;
-		if( miview != null ) miview._44 = 0;
+		if( mcamInv != null ) mcamInv._44 = 0;
+		if( mprojInv != null ) mprojInv._44 = 0;
 
 
 		frustum.loadMatrix(m);
 		frustum.loadMatrix(m);
 	}
 	}

+ 1 - 0
h3d/impl/RendererFX.hx

@@ -2,6 +2,7 @@ package h3d.impl;
 
 
 enum Step {
 enum Step {
 	BeforeLighting;
 	BeforeLighting;
+	BeforeTonemappingFX;
 	BeforeTonemapping;
 	BeforeTonemapping;
 	AfterTonemapping;
 	AfterTonemapping;
 	AfterUI;
 	AfterUI;

+ 1 - 0
h3d/scene/pbr/Renderer.hx

@@ -425,6 +425,7 @@ class Renderer extends h3d.scene.Renderer {
 
 
 		lighting();
 		lighting();
 
 
+		apply(BeforeTonemappingFX);
 		drawBeforeTonemapping();
 		drawBeforeTonemapping();
 		apply(BeforeTonemapping);
 		apply(BeforeTonemapping);