瀏覽代碼

define additive lighting model

ncannasse 10 年之前
父節點
當前提交
7c2337701b
共有 2 個文件被更改,包括 12 次插入11 次删除
  1. 8 7
      h3d/pass/LightSystem.hx
  2. 4 4
      h3d/shader/AmbientLight.hx

+ 8 - 7
h3d/pass/LightSystem.hx

@@ -15,23 +15,24 @@ class LightSystem {
 	public var perPixelLighting : Bool = true;
 	public var perPixelLighting : Bool = true;
 
 
 	/**
 	/**
-		In the old lighting model, the lights are added after the ambient.
-		In the new one (by default), the lights will be modulated against the ambient, so an ambient of 1 will turn off all lights
+		In the additive lighting model (by default), the lights are added after the ambient.
+		In the new non additive ligthning model, the lights will be modulated against the ambient, so an ambient of 1 will reduce lights intensities to 0.
 	**/
 	**/
-	public var oldModel(get, set) : Bool;
+	public var additiveLighting(get, set) : Bool;
 
 
 	public function new() {
 	public function new() {
 		shadowDirection = new h3d.Vector(0, 0, -1);
 		shadowDirection = new h3d.Vector(0, 0, -1);
 		ambientLight = new h3d.Vector(0.5, 0.5, 0.5);
 		ambientLight = new h3d.Vector(0.5, 0.5, 0.5);
 		ambientShader = new h3d.shader.AmbientLight();
 		ambientShader = new h3d.shader.AmbientLight();
+		additiveLighting = true;
 	}
 	}
 
 
-	function get_oldModel() {
-		return Std.instance(ambientShader,h3d.shader.AmbientLight).oldModel;
+	function get_additiveLighting() {
+		return Std.instance(ambientShader,h3d.shader.AmbientLight).additive;
 	}
 	}
 
 
-	function set_oldModel(b) {
-		return Std.instance(ambientShader,h3d.shader.AmbientLight).oldModel = b;
+	function set_additiveLighting(b) {
+		return Std.instance(ambientShader,h3d.shader.AmbientLight).additive = b;
 	}
 	}
 
 
 	public function initLights( globals : hxsl.Globals, ctx : h3d.scene.RenderContext ) {
 	public function initLights( globals : hxsl.Globals, ctx : h3d.scene.RenderContext ) {

+ 4 - 4
h3d/shader/AmbientLight.hx

@@ -13,18 +13,18 @@ class AmbientLight extends hxsl.Shader {
 		var lightPixelColor : Vec3;
 		var lightPixelColor : Vec3;
 		var lightColor : Vec3;
 		var lightColor : Vec3;
 
 
-		@const var oldModel : Bool;
+		@const var additive : Bool;
 
 
 		function __init__() {
 		function __init__() {
-			lightColor = oldModel ? global.ambientLight : vec3(0.);
+			lightColor = additive ? global.ambientLight : vec3(0.);
 		}
 		}
 
 
 		function __init__fragment() {
 		function __init__fragment() {
-			lightPixelColor = oldModel ? global.ambientLight : vec3(0.);
+			lightPixelColor = additive ? global.ambientLight : vec3(0.);
 		}
 		}
 
 
 		function calcLight( lightColor : Vec3 ) : Vec3 {
 		function calcLight( lightColor : Vec3 ) : Vec3 {
-			return oldModel ? lightColor : (global.ambientLight + (1 - global.ambientLight).max(0.) * lightColor);
+			return additive ? lightColor : (global.ambientLight + (1 - global.ambientLight).max(0.) * lightColor);
 		}
 		}
 
 
 		function vertex() {
 		function vertex() {