Bladeren bron

Add occlusionFActor
Add correct StartTime for emitter

ShiroSmith 6 jaren geleden
bovenliggende
commit
69849b87ce
2 gewijzigde bestanden met toevoegingen van 12 en 5 verwijderingen
  1. 5 0
      hrt/prefab/Light.hx
  2. 7 5
      hrt/prefab/fx/Emitter.hx

+ 5 - 0
hrt/prefab/Light.hx

@@ -44,6 +44,7 @@ class Light extends Object3D {
 	public var color : Int = 0xffffff;
 	public var power : Float = 1.0;
 	public var shadows : LightShadows = getShadowsDefault();
+	public var occlusionFactor = 0.0;
 	public var isMainLight : Bool = false;
 
 	// Point/Spot
@@ -91,6 +92,7 @@ class Light extends Object3D {
 		obj.fallOff = fallOff;
 		obj.maxRange = maxRange;
 		obj.cookiePath = cookiePath;
+		obj.occlusionFactor = occlusionFactor;
 
 		if( shadows.mode != None ) {
 			obj.shadows = Reflect.copy(shadows);
@@ -112,6 +114,7 @@ class Light extends Object3D {
 		fallOff = obj.fallOff;
 		maxRange = obj.maxRange;
 		cookiePath = obj.cookiePath;
+		occlusionFactor = obj.occlusionFactor == null ? 0.0 : obj.occlusionFactor;
 
 		if( obj.shadows != null ) {
 			var sh : Dynamic = Reflect.copy(obj.shadows);
@@ -200,6 +203,7 @@ class Light extends Object3D {
 		var color = color | 0xff000000;
 		var light = cast(ctx.local3d,h3d.scene.pbr.Light);
 		light.isMainLight = isMainLight;
+		light.occlusionFactor = occlusionFactor;
 
 		switch( kind ) {
 		case Spot:
@@ -414,6 +418,7 @@ class Light extends Object3D {
 						</select></dd>
 					<dt>Color</dt><dd><input type="color" field="color"/></dd>
 					<dt>Power</dt><dd><input type="range" min="0" max="10" field="power"/></dd>
+					<dt>Occlusion Factor</dt><dd><input type="range" min="0" max="1" field="occlusionFactor"/></dd>
 				</dl>
 			</div>
 		');

+ 7 - 5
hrt/prefab/fx/Emitter.hx

@@ -436,7 +436,7 @@ class EmitterObject extends h3d.scene.Object {
 		emitCount += count;
 	}
 
-	function createMeshBatch() {
+	function createMeshBatch( startTime : Float ) {
 
 		if( batch != null )
 			batch.remove();
@@ -477,9 +477,9 @@ class EmitterObject extends h3d.scene.Object {
 			// Animated textures animations
 			var frameCount = frameCount == 0 ? frameDivisionX * frameDivisionY : frameCount;
 			if( frameCount > 1 ) {
-				if( mesh != null && mesh.material != null ) {
+				if( mesh != null && mesh.material != null && mesh.material.texture != null ) {
 					var pshader = new h3d.shader.AnimatedTexture(mesh.material.texture, frameDivisionX, frameDivisionY, frameCount, frameCount * animationRepeat / lifeTime);
-					pshader.startTime = renderTime;
+					pshader.startTime = startTime;
 					pshader.loop = animationLoop;
 					mesh.material.mainPass.addShader(pshader);
 				}
@@ -538,7 +538,9 @@ class EmitterObject extends h3d.scene.Object {
 					var frameCount = frameCount == 0 ? frameDivisionX * frameDivisionY : frameCount;
 					if( frameCount > 0 && animationRepeat == 0 ) {
 						var s = batch.material.mainPass.getShader(h3d.shader.AnimatedTexture);
-						if( s != null) s.startFrame = p.startFrame;
+						if( s != null){
+							s.startFrame = p.startFrame;
+						}
 					}
 					batch.emitInstance();
 				}
@@ -807,7 +809,7 @@ class Emitter extends Object3D {
 		emitterObj.animationRepeat = getParamVal("animationRepeat");
 		emitterObj.animationLoop = getParamVal("animationLoop");
 
-		emitterObj.createMeshBatch();
+		emitterObj.createMeshBatch(@:privateAccess ctx.local3d.getScene().renderer.ctx.time);
 
 		#if editor
 		if(propName == null || ["emitShape", "emitAngle", "emitRad1", "emitRad2"].indexOf(propName) >= 0)