Browse Source

per light shadow map + static/dynamic/mixed shadowmap mode
h3d.pass.ShadowMap renamed to DefaultShadowMap (old forward support)

ncannasse 7 years ago
parent
commit
465059b4e9

+ 35 - 0
h3d/pass/DefaultShadowMap.hx

@@ -0,0 +1,35 @@
+package h3d.pass;
+
+class DefaultShadowMap extends DirShadowMap {
+
+	var shadowMapId : Int;
+	var shadowProjId : Int;
+	var shadowColorId : Int;
+	var shadowPowerId : Int;
+	var shadowBiasId : Int;
+
+	public var color : h3d.Vector;
+
+	public function new(size=1024) {
+		super();
+		this.size = size;
+		color = new h3d.Vector();
+		mode = Dynamic;
+		shadowMapId = hxsl.Globals.allocID("shadow.map");
+		shadowProjId = hxsl.Globals.allocID("shadow.proj");
+		shadowColorId = hxsl.Globals.allocID("shadow.color");
+		shadowPowerId = hxsl.Globals.allocID("shadow.power");
+		shadowBiasId = hxsl.Globals.allocID("shadow.bias");
+	}
+
+	override function draw( passes ) {
+		super.draw(passes);
+		ctx.setGlobalID(shadowMapId, { texture : dshader.shadowMap, channel : format == h3d.mat.Texture.nativeFormat ? hxsl.Channel.PackedFloat : hxsl.Channel.R });
+		ctx.setGlobalID(shadowProjId, getShadowProj());
+		ctx.setGlobalID(shadowColorId, color);
+		ctx.setGlobalID(shadowPowerId, power);
+		ctx.setGlobalID(shadowBiasId, bias);
+		return passes;
+	}
+
+}

+ 81 - 62
h3d/pass/ShadowMap.hx → h3d/pass/DirShadowMap.hx

@@ -1,47 +1,34 @@
 package h3d.pass;
 
-class ShadowMap extends Default {
+class DirShadowMap extends Shadows {
 
 	var lightCamera : h3d.Camera;
-	var shadowMapId : Int;
-	var shadowProjId : Int;
-	var shadowColorId : Int;
-	var shadowPowerId : Int;
-	var shadowBiasId : Int;
 	var customDepth : Bool;
 	var depth : h3d.mat.DepthBuffer;
 	var dshader : h3d.shader.DirShadow;
-
-	@ignore public var border : Border;
-	public var size(default,set) : Int;
-	public var color : h3d.Vector;
+	var border : Border;
+	var staticTexture : h3d.mat.Texture;
+	var mergePass = new h3d.pass.ScreenFx(new h3d.shader.MinMaxShader());
 	public var power = 30.0;
 	public var bias = 0.01;
-	public var blur : Blur;
 
-	public var shader(default,null) : hxsl.Shader;
+	public function new() {
+		super();
 
-	public function new(size=1024) {
-		super("shadow");
-		this.size = size;
 		lightCamera = new h3d.Camera();
 		lightCamera.orthoBounds = new h3d.col.Bounds();
-		shadowMapId = hxsl.Globals.allocID("shadow.map");
-		shadowProjId = hxsl.Globals.allocID("shadow.proj");
-		shadowColorId = hxsl.Globals.allocID("shadow.color");
-		shadowPowerId = hxsl.Globals.allocID("shadow.power");
-		shadowBiasId = hxsl.Globals.allocID("shadow.bias");
 		shader = dshader = new h3d.shader.DirShadow();
-		color = new h3d.Vector();
-		blur = new Blur(5);
-		blur.quality = 0.5;
-		blur.shader.isDepth = true;
 		border = new Border(size, size);
 		customDepth = h3d.Engine.getCurrent().driver.hasFeature(AllocDepthBuffer);
 		if( !customDepth ) depth = h3d.mat.DepthBuffer.getDefault();
 	}
 
-	function set_size(s) {
+	override function set_mode(m:Shadows.RenderMode) {
+		dshader.enable = m != None;
+		return mode = m;
+	}
+
+	override function set_size(s) {
 		if( border != null && size != s ) {
 			border.dispose();
 			border = new Border(s, s);
@@ -51,15 +38,14 @@ class ShadowMap extends Default {
 
 	override function dispose() {
 		super.dispose();
-		blur.dispose();
-		if( border != null ) border.dispose();
+		if( customDepth && depth != null ) depth.dispose();
+		if( staticTexture != null ) staticTexture.dispose();
 	}
 
 	public dynamic function calcShadowBounds( camera : h3d.Camera ) {
 		var bounds = camera.orthoBounds;
 		var mtmp = new h3d.Matrix();
 
-
 		// add visible casters in light camera position
 		ctx.scene.iterVisibleMeshes(function(m) {
 			if( m.primitive == null || !m.material.castShadows ) return;
@@ -101,25 +87,26 @@ class ShadowMap extends Default {
 
 		});
 
-		// intersect with frustum bounds
-		var cameraBounds = new h3d.col.Bounds();
-		for( pt in ctx.camera.getFrustumCorners() ) {
-			pt.transform(camera.mcam);
-			cameraBounds.addPos(pt.x, pt.y, pt.z);
+		if( mode == Dynamic ) {
+			// intersect with frustum bounds
+			var cameraBounds = new h3d.col.Bounds();
+			for( pt in ctx.camera.getFrustumCorners() ) {
+				pt.transform(camera.mcam);
+				cameraBounds.addPos(pt.x, pt.y, pt.z);
+			}
+			bounds.intersection(bounds, cameraBounds);
 		}
-		bounds.intersection(bounds, cameraBounds);
-		bounds.scaleCenter(1.01);
-	}
 
-	override function getOutputs() : Array<hxsl.Output> {
-		return [PackFloat(Value("output.depth"))];
+		bounds.scaleCenter(1.01);
 	}
 
 	override function setGlobals() {
 		super.setGlobals();
-		lightCamera.orthoBounds.empty();
-		calcShadowBounds(lightCamera);
-		lightCamera.update();
+		if( mode != Mixed || ctx.computingStatic ) {
+			lightCamera.orthoBounds.empty();
+			calcShadowBounds(lightCamera);
+			lightCamera.update();
+		}
 		cameraViewProj = lightCamera.m;
 	}
 
@@ -128,26 +115,43 @@ class ShadowMap extends Default {
 	}
 
 	override function draw( passes ) {
-		var texture = ctx.textures.allocTarget("shadowMap", size, size, false);
+
+		if( !ctx.computingStatic )
+			switch( mode ) {
+			case None:
+				return passes;
+			case Dynamic:
+				// nothing
+			case Static, Mixed:
+				if( staticTexture == null ) throw "Static texture is missing, call s3d.computeStatic() first";
+				if( mode == Static ) return passes;
+			}
+
+		passes = filterPasses(passes);
+
+		var texture = ctx.textures.allocTarget("shadowMap", size, size, false, format);
 		if( customDepth && (depth == null || depth.width != size || depth.height != size || depth.isDisposed()) ) {
 			if( depth != null ) depth.dispose();
 			depth = new h3d.mat.DepthBuffer(size, size);
 		}
 		texture.depthBuffer = depth;
-		var ct = ctx.camera.target;
-		var slight = ctx.lightSystem.shadowLight;
-		var ldir = slight == null ? null : @:privateAccess slight.getShadowDirection();
-		if( ldir == null )
-			lightCamera.target.set(0, 0, -1);
-		else {
-			lightCamera.target.set(ldir.x, ldir.y, ldir.z);
-			lightCamera.target.normalize();
+
+		if( mode != Mixed || ctx.computingStatic ) {
+			var ct = ctx.camera.target;
+			var slight = ctx.lightSystem.shadowLight;
+			var ldir = slight == null ? null : @:privateAccess slight.getShadowDirection();
+			if( ldir == null )
+				lightCamera.target.set(0, 0, -1);
+			else {
+				lightCamera.target.set(ldir.x, ldir.y, ldir.z);
+				lightCamera.target.normalize();
+			}
+			lightCamera.target.x += ct.x;
+			lightCamera.target.y += ct.y;
+			lightCamera.target.z += ct.z;
+			lightCamera.pos.load(ct);
+			lightCamera.update();
 		}
-		lightCamera.target.x += ct.x;
-		lightCamera.target.y += ct.y;
-		lightCamera.target.z += ct.z;
-		lightCamera.pos.load(ct);
-		lightCamera.update();
 
 		ctx.engine.pushTarget(texture);
 		ctx.engine.clear(0xFFFFFF, 1);
@@ -155,21 +159,36 @@ class ShadowMap extends Default {
 		if( border != null ) border.render();
 		ctx.engine.popTarget();
 
-		if( blur.radius > 0 )
+		if( mode == Mixed && !ctx.computingStatic ) {
+			var merge = ctx.textures.allocTarget("shadowMap", size, size, false, format);
+			mergePass.shader.texA = texture;
+			mergePass.shader.texB = staticTexture;
+			ctx.engine.pushTarget(merge);
+			mergePass.render();
+			ctx.engine.popTarget();
+			texture = merge;
+		}
+
+		if( blur.radius > 0 && (mode != Mixed || !ctx.computingStatic) )
 			blur.apply(ctx, texture);
 
 		dshader.shadowMap = texture;
+		dshader.shadowMapChannel = format == h3d.mat.Texture.nativeFormat ? PackedFloat : R;
 		dshader.shadowBias = bias;
 		dshader.shadowPower = power;
 		dshader.shadowProj = getShadowProj();
-
-		ctx.setGlobalID(shadowMapId, { texture : texture });
-		ctx.setGlobalID(shadowProjId, getShadowProj());
-		ctx.setGlobalID(shadowColorId, color);
-		ctx.setGlobalID(shadowPowerId, power);
-		ctx.setGlobalID(shadowBiasId, bias);
 		return passes;
 	}
 
+	override function computeStatic( passes : h3d.pass.Object ) {
+		if( mode != Static && mode != Mixed )
+			return;
+		draw(passes);
+		var texture = dshader.shadowMap;
+		if( staticTexture != null ) staticTexture.dispose();
+		staticTexture = texture.clone();
+		dshader.shadowMap = staticTexture;
+	}
+
 
 }

+ 114 - 0
h3d/pass/Shadows.hx

@@ -0,0 +1,114 @@
+package h3d.pass;
+
+enum RenderMode {
+	None;
+	Static;
+	Dynamic;
+	Mixed;
+}
+
+class Shadows extends Default {
+
+	var format : hxd.PixelFormat;
+	public var mode(default,set) : RenderMode = None;
+	public var size(default,set) : Int = 1024;
+	public var shader(default,null) : hxsl.Shader;
+	public var blur : Blur;
+
+	public function new() {
+		if( format == null ) format = R16F;
+		if( !h3d.Engine.getCurrent().driver.isSupportedFormat(format) ) format = h3d.mat.Texture.nativeFormat;
+		super("shadows");
+		blur = new Blur(5);
+		blur.quality = 0.5;
+		blur.shader.isDepth = format == h3d.mat.Texture.nativeFormat;
+	}
+
+	function set_mode(m:RenderMode) {
+		if( m != None ) throw "Shadow mode "+m+" not supported for "+this;
+		return mode = m;
+	}
+
+	function set_size(s) {
+		return size = s;
+	}
+
+	override function dispose() {
+		super.dispose();
+		blur.dispose();
+	}
+
+	override function getOutputs() : Array<hxsl.Output> {
+		if( format == h3d.mat.Texture.nativeFormat )
+			return [PackFloat(Value("output.depth"))];
+		return [Swiz(Value("output.depth",1),[X,X,X,X])];
+	}
+
+	public function computeStatic( passes : h3d.pass.Object ) {
+		throw "Not implemented";
+	}
+
+	function filterPasses( passes : h3d.pass.Object ) : h3d.pass.Object {
+		var isStatic : Bool;
+		switch( mode ) {
+		case None:
+			return null;
+		case Dynamic:
+			if( ctx.computingStatic ) return null;
+			return passes;
+		case Mixed:
+			isStatic = ctx.computingStatic;
+		case Static:
+			if( !ctx.computingStatic ) return null;
+			isStatic = true;
+		}
+		var head = null;
+		var prev = null;
+		var last = null;
+
+		var cur = passes;
+
+		var count = 0;
+		while( cur != null )  {
+			if( cur.pass.isStatic == isStatic )
+				count++;
+			cur = cur.next;
+		}
+		cur = passes;
+
+		while( cur != null ) {
+			if( cur.pass.isStatic == isStatic ) {
+				if( head == null )
+					head = prev = cur;
+				else {
+					prev.next = cur;
+					prev = cur;
+				}
+			} else {
+				if( last == null )
+					last = cur;
+				else {
+					last.next = cur;
+					last = cur;
+				}
+			}
+			cur = cur.next;
+		}
+		if( last != null )
+			last.next = head;
+		if( prev != null )
+			prev.next = null;
+
+
+		cur = head;
+		while( cur != null )  {
+			if( cur.pass.isStatic != isStatic ) throw "assert";
+			count--;
+			cur = cur.next;
+		}
+		if( count != 0 ) throw "assert";
+
+		return head;
+	}
+
+}

+ 2 - 1
h3d/scene/DefaultRenderer.hx

@@ -52,12 +52,13 @@ class NormalPass extends h3d.pass.Default {
 	}
 
 }
+
 class DefaultRenderer extends Renderer {
 
 	var def(get, never) : h3d.pass.Base;
 	public var depth : h3d.pass.Base = new DepthPass();
 	public var normal : h3d.pass.Base = new NormalPass();
-	public var shadow = new h3d.pass.ShadowMap(1024);
+	public var shadow = new h3d.pass.DefaultShadowMap(1024);
 
 	public function new() {
 		super();

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

@@ -6,6 +6,7 @@ class DirLight extends Light {
 
 	public function new(?dir: h3d.Vector, ?parent) {
 		pbr = new h3d.shader.pbr.Light.DirLight();
+		shadows = new h3d.pass.DirShadowMap();
 		super(pbr,parent);
 		if( dir != null ) setDirection(dir);
 	}

+ 9 - 1
h3d/scene/pbr/Light.hx

@@ -1,15 +1,23 @@
 package h3d.scene.pbr;
 
+enum ShadowMode {
+	None;
+	Dynamic;
+	Static;
+	Mixed;
+}
+
 class Light extends h3d.scene.Light {
 
 	var _color : h3d.Vector;
 	var primitive : h3d.prim.Primitive;
 	@:s public var power : Float = 1.;
-	public var shadows : hxsl.Shader;
+	public var shadows : h3d.pass.Shadows;
 
 	function new(shader,?parent) {
 		super(shader,parent);
 		_color = new h3d.Vector(1,1,1,1);
+		if( shadows == null ) shadows = new h3d.pass.Shadows();
 	}
 
 	override function get_color() {

+ 4 - 4
h3d/scene/pbr/LightSystem.hx

@@ -6,8 +6,8 @@ class LightSystem extends h3d.scene.LightSystem {
 	override function computeLight( obj : h3d.scene.Object, shaders : hxsl.ShaderList ) : hxsl.ShaderList {
 		var light = Std.instance(obj, h3d.scene.pbr.Light);
 		if( light != null ) {
-			if( light.shadows != null )
-				shaders = ctx.allocShaderList(light.shadows, shaders);
+			if( light.shadows.shader != null )
+				shaders = ctx.allocShaderList(light.shadows.shader, shaders);
 			return ctx.allocShaderList(light.shader, shaders);
 		}
 		return shaders;
@@ -22,11 +22,11 @@ class LightSystem extends h3d.scene.LightSystem {
 			if( light != shadowLight ) {
 				var light = Std.instance(light, h3d.scene.pbr.Light);
 				if( light != null && light.primitive == null ) {
-					if( light.shadows != null ) lightPass.addShader(light.shadows);
+					if( light.shadows.shader != null ) lightPass.addShader(light.shadows.shader);
 					lightPass.addShader(light.shader);
 					lightPass.render();
 					lightPass.removeShader(light.shader);
-					if( light.shadows != null ) lightPass.addShader(light.shadows);
+					if( light.shadows.shader != null ) lightPass.removeShader(light.shadows.shader);
 				}
 			}
 			light = light.next;

+ 39 - 51
h3d/scene/pbr/Renderer.hx

@@ -30,14 +30,6 @@ package h3d.scene.pbr;
 	var Reinhard = "Reinhard";
 }
 
-typedef ShadowProps = {
-	var enable : Bool;
-	var power : Float;
-	var blur : Float;
-	var bias : Float;
-	var quality : Float;
-}
-
 typedef RenderProps = {
 	var mode : DisplayMode;
 	var env : String;
@@ -45,7 +37,6 @@ typedef RenderProps = {
 	var exposure : Float;
 	var sky : SkyMode;
 	var tone : TonemapMap;
-	var shadow : ShadowProps;
 	var emissive : Float;
 	var occlusion : Float;
 }
@@ -59,11 +50,11 @@ class Renderer extends h3d.scene.Renderer {
 	var pbrLightPass : h3d.mat.Pass;
 	var screenLightPass : h3d.pass.ScreenFx<h3d.shader.ScreenShader>;
 	var fxaa = new h3d.pass.FXAA();
-	var shadows = new h3d.pass.ShadowMap(2048);
 	var pbrIndirect = new h3d.shader.pbr.Lighting.Indirect();
 	var pbrDirect = new h3d.shader.pbr.Lighting.Direct();
 	var pbrProps = new h3d.shader.pbr.PropsImport();
 	var hasDebugEvent = false;
+	var curDirShadow : hxsl.Shader;
 
 	public var skyMode : SkyMode = Hide;
 	public var toneMode : TonemapMap = Reinhard;
@@ -98,7 +89,6 @@ class Renderer extends h3d.scene.Renderer {
 		pbrOutIndirect.pass.stencil.setOp(Keep, Keep, Keep);
 		allPasses.push(output);
 		allPasses.push(defaultPass);
-		allPasses.push(shadows);
 		allPasses.push(decalsOutput);
 		refreshProps();
 	}
@@ -146,19 +136,33 @@ class Renderer extends h3d.scene.Renderer {
 				f.apply(this, step);
 	}
 
+	override function computeStatic() {
+		var light = @:privateAccess ctx.lights;
+		var passes = get("shadow");
+		while( light != null ) {
+			var plight = Std.instance(light, h3d.scene.pbr.Light);
+			if( plight != null ) {
+				plight.shadows.setContext(ctx);
+				plight.shadows.computeStatic(passes);
+			}
+			light = light.next;
+		}
+	}
+
 	override function render() {
 		var props : RenderProps = props;
+		var ls = getLightSystem();
 
-		if( props.shadow.enable ) {
-			var sh = props.shadow;
-			shadows.power = sh.power;
-			shadows.blur.radius = sh.blur;
-			shadows.blur.quality = sh.quality;
-			shadows.bias = sh.bias * 0.1;
-			shadows.draw(get("shadow"));
-		} else
-			get("shadow");
-		pbrDirect.enableShadow = props.shadow.enable;
+		var light = @:privateAccess ctx.lights;
+		var passes = get("shadow");
+		while( light != null ) {
+			var plight = Std.instance(light, h3d.scene.pbr.Light);
+			if( plight != null ) {
+				plight.shadows.setContext(ctx);
+				plight.shadows.draw(passes);
+			}
+			light = light.next;
+		}
 
 		var albedo = allocTarget("albedo");
 		var normal = allocTarget("normalDepth",false,1.,RGBA16F);
@@ -190,7 +194,6 @@ class Renderer extends h3d.scene.Renderer {
 				setTarget(pbr);
 				clear(0x00FF80FF);
 			}
-
 		}
 		apply(BeforeHdr);
 
@@ -219,18 +222,26 @@ class Renderer extends h3d.scene.Renderer {
 		pbrIndirect.irrSpecular = env.specular;
 		pbrIndirect.irrSpecularLevels = env.specLevels;
 
-		var ls = getLightSystem();
 		if( ls.shadowLight == null ) {
+			if( curDirShadow != null ) {
+				pbrOut.removeShader(curDirShadow);
+				curDirShadow = null;
+			}
 			pbrOut.removeShader(pbrDirect);
 			pbrOut.removeShader(pbrSun);
-			pbrOut.removeShader(shadows.shader);
 		} else {
 			var pdir = Std.instance(ls.shadowLight, h3d.scene.pbr.DirLight);
+			var pshadow = @:privateAccess pdir == null ? null : pdir.shadows.shader;
+			if( pshadow != curDirShadow ) {
+				if( curDirShadow != null ) pbrOut.removeShader(curDirShadow);
+				curDirShadow = pshadow;
+				if( pshadow != null ) pbrOut.addShader(pshadow);
+			}
 			if( pbrOut.getShader(h3d.shader.pbr.Light.DirLight) == null ) {
-				pbrOut.addShader(shadows.shader);
 				pbrOut.addShader(pbrDirect);
 				pbrOut.addShader(pbrSun);
 			}
+			// works with both pre-pbr DirLight and pbr DirLight
 			pbrSun.lightColor.load(ls.shadowLight.color);
 			if( pdir != null ) pbrSun.lightColor.scale3(pdir.power * pdir.power);
 			pbrSun.lightDir.load(@:privateAccess ls.shadowLight.getShadowDirection());
@@ -254,7 +265,8 @@ class Renderer extends h3d.scene.Renderer {
 			pbrIndirect.skyMap = env.env;
 		}
 
-		pbrOut.render();
+		if( ls.shadowLight != null )
+			pbrOut.render();
 		pbrDirect.doDiscard = true;
 
 		var ls = Std.instance(ls, LightSystem);
@@ -369,14 +381,7 @@ class Renderer extends h3d.scene.Renderer {
 			exposure : 0.,
 			sky : Irrad,
 			tone : Linear,
-			occlusion : 1.,
-			shadow : {
-				enable : true,
-				power : 40,
-				blur : 9,
-				bias : 0.1,
-				quality : 0.3,
-			},
+			occlusion : 1.
 		};
 		return props;
 	}
@@ -403,16 +408,6 @@ class Renderer extends h3d.scene.Renderer {
 	#if js
 	override function editProps() {
 		var props : RenderProps = props;
-
-		var shadowProps = '
-			<dl>
-			<dt>Power</dt><dd><input type="range" min="0" max="100" step="0.1" field="shadow.power"/></dd>
-			<dt>Blur</dt><dd><input type="range" min="0" max="20" field="shadow.blur"/></dd>
-			<dt>Quality</dt><dd><input type="range" field="shadow.quality"/></dd>
-			<dt>Bias</dt><dd><input type="range" min="0" max="1" field="shadow.bias"/></dd>
-			</dt>
-		';
-
 		return new js.jquery.JQuery('
 			<div class="group" name="Renderer">
 			<dl>
@@ -448,13 +443,6 @@ class Renderer extends h3d.scene.Renderer {
 				<dt>Exposure</dt><dd><input type="range" min="-3" max="3" field="exposure"></dd>
 			</dl>
 			</div>
-
-			<div class="group">
-				<div class="title">
-					<input type="checkbox" field="shadow.enable"/> Shadows
-				</div>
-				$shadowProps
-			</div>
 		');
 	}
 	#end

+ 9 - 5
h3d/shader/DirShadow.hx

@@ -4,6 +4,8 @@ class DirShadow extends hxsl.Shader {
 
 	static var SRC = {
 
+		@const var enable : Bool;
+
 		@param var shadowMap : Channel;
 		@param var shadowProj : Mat3x4;
 		@param var shadowPower : Float;
@@ -13,11 +15,13 @@ class DirShadow extends hxsl.Shader {
 		var shadow : Float;
 
 		function fragment() {
-			var shadowPos = transformedPosition * shadowProj;
-			var depth = shadowMap.get(screenToUv(shadowPos.xy));
-			var zMax = shadowPos.z.saturate();
-			var delta = (depth + shadowBias).min(zMax) - zMax;
-			shadow = exp( shadowPower * delta ).saturate();
+			if( enable ) {
+				var shadowPos = transformedPosition * shadowProj;
+				var depth = shadowMap.get(screenToUv(shadowPos.xy));
+				var zMax = shadowPos.z.saturate();
+				var delta = (depth + shadowBias).min(zMax) - zMax;
+				shadow = exp( shadowPower * delta ).saturate();
+			}
 		}
 
 	}

+ 20 - 0
h3d/shader/MinMaxShader.hx

@@ -0,0 +1,20 @@
+package h3d.shader;
+
+class MinMaxShader extends ScreenShader {
+
+	static var SRC = {
+
+		@param var texA : Sampler2D;
+		@param var texB : Sampler2D;
+		@const var isMax : Bool;
+
+		function fragment() {
+			var a = texA.get(calculatedUV);
+			var b = texB.get(calculatedUV);
+			pixelColor = isMax ? max(a,b) : min(a,b);
+		}
+
+	};
+
+
+}

+ 0 - 3
h3d/shader/pbr/Lighting.hx

@@ -55,12 +55,9 @@ class Direct extends PropsDefinition {
 		var pbrLightDirection : Vec3;
 		var pbrLightColor : Vec3;
 		@const var doDiscard : Bool = true;
-		@const var enableShadow : Bool = true;
 
 		function fragment() {
 
-			if( !enableShadow ) shadow = 1.;
-
 			var NdL = normal.dot(pbrLightDirection).max(0.);
 			if( pbrLightColor.dot(pbrLightColor) > 0.0001 && NdL > 0 ) {
 

+ 1 - 1
hxd/inspect/SceneProps.hx

@@ -90,7 +90,7 @@ class SceneProps {
 			if( ls.shadowLight != null )
 				props.push(PGroup("DirLight", getObjectProps(ls.shadowLight)));
 
-			var s = r.getPass(h3d.pass.ShadowMap);
+			var s = r.getPass(h3d.pass.DefaultShadowMap);
 			if( s != null ) {
 				props.push(PGroup("Shadows",[
 					PRange("size", 64, 2048, function() return s.size, function(sz) s.size = Std.int(sz), 64),

+ 2 - 2
samples/Shadows.hx

@@ -5,7 +5,7 @@ class Shadows extends SampleApp {
 	var time : Float = 0.;
 	var spheres : Array<h3d.scene.Object>;
 	var dir : h3d.scene.DirLight;
-	var shadow : h3d.pass.ShadowMap;
+	var shadow : h3d.pass.DefaultShadowMap;
 
 	override function init() {
 		super.init();
@@ -37,7 +37,7 @@ class Shadows extends SampleApp {
 		dir = new h3d.scene.DirLight(new h3d.Vector(-0.3, -0.2, -1), s3d);
 		dir.enableSpecular = true;
 
-		shadow = s3d.renderer.getPass(h3d.pass.ShadowMap);
+		shadow = s3d.renderer.getPass(h3d.pass.DefaultShadowMap);
 		addSlider("Power", function() return shadow.power, function(p) shadow.power = p, 0, 100);
 		addSlider("Radius", function() return shadow.blur.radius, function(r) shadow.blur.radius = r, 0, 20);
 		addSlider("Quality", function() return shadow.blur.quality, function(r) shadow.blur.quality = r);

+ 1 - 1
samples/Skin.hx

@@ -25,7 +25,7 @@ class Skin extends SampleApp {
 		}
 		s3d.lightSystem.ambientLight.set(0.4, 0.4, 0.4);
 
-		var shadow = s3d.renderer.getPass(h3d.pass.ShadowMap);
+		var shadow = s3d.renderer.getPass(h3d.pass.DefaultShadowMap);
 		shadow.power = 20;
 		shadow.color.setColor(0x301030);
 		dir.enableSpecular = true;

+ 2 - 2
samples/World.hx

@@ -3,7 +3,7 @@ import hxd.Key in K;
 class World extends hxd.App {
 
 	var world : h3d.scene.World;
-	var shadow :h3d.pass.ShadowMap;
+	var shadow :h3d.pass.DefaultShadowMap;
 
 	override function init() {
 
@@ -23,7 +23,7 @@ class World extends hxd.App {
 		s3d.camera.target.set(72, 72, 0);
 		s3d.camera.pos.set(120, 120, 40);
 
-		shadow = s3d.renderer.getPass(h3d.pass.ShadowMap);
+		shadow = s3d.renderer.getPass(h3d.pass.DefaultShadowMap);
 		shadow.size = 2048;
 		shadow.power = 200;
 		shadow.blur.radius= 0;