浏览代码

Adding fur occlusion property to FurMaterial

Julien Moreau-Mathis 7 年之前
父节点
当前提交
ffe1fe56f3

+ 1 - 0
dist/preview release/what's new.md

@@ -120,6 +120,7 @@
 - GUI: Introduced `MultiLine` which will draw lines between any number of meshes, controls and points. [Documentation](http://doc.babylonjs.com/how_to/gui#multiline) ([royibernthal](https://github.com/royibernthal))
 - Added `alphaCutOff` support for StandardMaterial ([deltakosh](https://github.com/deltakosh))
 - New `serialize` and `Parse` functions for SSAO2 Rendering Pipeline ([julien-moreau](https://github.com/julien-moreau))
+- Added `furOcclusion` property to FurMaterial to control the occlusion strength ([julien-moreau](https://github.com/julien-moreau))
 
 ## Bug fixes
 

+ 5 - 1
materialsLibrary/src/fur/babylon.furMaterial.ts

@@ -64,6 +64,9 @@ module BABYLON {
         @serialize()
         public furDensity: number = 20;
 
+        @serialize()
+        public furOcclusion: number = 0.0;
+
         public furTexture: DynamicTexture;
 
 
@@ -240,7 +243,7 @@ module BABYLON {
                     "vDiffuseInfos",
                     "mBones",
                     "vClipPlane", "diffuseMatrix",
-                    "furLength", "furAngle", "furColor", "furOffset", "furGravity", "furTime", "furSpacing", "furDensity"
+                    "furLength", "furAngle", "furColor", "furOffset", "furGravity", "furTime", "furSpacing", "furDensity", "furOcclusion"
                 ];
                 var samplers = ["diffuseSampler",
                     "heightTexture", "furTexture"
@@ -347,6 +350,7 @@ module BABYLON {
                 this._activeEffect.setFloat("furOffset", this.furOffset);
                 this._activeEffect.setFloat("furSpacing", this.furSpacing);
                 this._activeEffect.setFloat("furDensity", this.furDensity);
+                this._activeEffect.setFloat("furOcclusion", this.furOcclusion);
 
                 this._furTime += this.getScene().getEngine().getDeltaTime() / this.furSpeed;
                 this._activeEffect.setFloat("furTime", this._furTime);

+ 2 - 1
materialsLibrary/src/fur/fur.fragment.fx

@@ -34,6 +34,7 @@ uniform vec2 vDiffuseInfos;
 // Fur uniforms
 #ifdef HIGHLEVEL
 uniform float furOffset;
+uniform float furOcclusion;
 uniform sampler2D furTexture;
 
 varying vec2 vFurUV;
@@ -96,7 +97,7 @@ void main(void) {
 	
     float occlusion = mix(0.0, furTextureColor.b * 1.2, furOffset);
     
-	baseColor = vec4(baseColor.xyz * occlusion, 1.1 - furOffset);
+	baseColor = vec4(baseColor.xyz * max(occlusion, furOcclusion), 1.1 - furOffset);
 	#endif
 
 	// Lighting

+ 8 - 1
materialsLibrary/test/addfur.js

@@ -114,7 +114,14 @@ window.prepareFur = function() {
 		setValue("furSpacing", value);
     }, function() {
         return fur.furSpacing;
-    });
+	});
+	
+	// Fur Occlusion
+	registerRangeUI("fur", "Fur Occlusion", 0, 2, function (value) {
+		setValue("furOcclusion", value);
+	}, function () {
+		return fur.furOcclusion;
+	});
     
     return {
 		material: fur,