|
@@ -115,10 +115,15 @@ class PointShadowMap extends Shadows {
|
|
switch( mode ) {
|
|
switch( mode ) {
|
|
case None:
|
|
case None:
|
|
return passes;
|
|
return passes;
|
|
- case Dynamic: // nothing
|
|
|
|
- case Mixed: // nothing
|
|
|
|
|
|
+ case Dynamic:
|
|
|
|
+ // nothing
|
|
|
|
+ case Mixed:
|
|
|
|
+ if( staticTexture == null || staticTexture.isDisposed() )
|
|
|
|
+ staticTexture = createDefaultShadowMap();
|
|
case Static:
|
|
case Static:
|
|
- if( staticTexture == null || staticTexture.isDisposed() ) staticTexture = createDefaultShadowMap();
|
|
|
|
|
|
+ if( staticTexture == null || staticTexture.isDisposed() )
|
|
|
|
+ staticTexture = createDefaultShadowMap();
|
|
|
|
+ updateCamera();
|
|
syncShader(staticTexture);
|
|
syncShader(staticTexture);
|
|
return passes;
|
|
return passes;
|
|
}
|
|
}
|
|
@@ -133,27 +138,30 @@ class PointShadowMap extends Shadows {
|
|
}
|
|
}
|
|
texture.depthBuffer = depth;
|
|
texture.depthBuffer = depth;
|
|
|
|
|
|
|
|
+ var validBakedTexture = (staticTexture != null && staticTexture.width == texture.width);
|
|
var merge : h3d.mat.Texture = null;
|
|
var merge : h3d.mat.Texture = null;
|
|
- if( mode == Mixed && !ctx.computingStatic )
|
|
|
|
|
|
+ if( mode == Mixed && !ctx.computingStatic && validBakedTexture)
|
|
merge = ctx.textures.allocTarget("pointShadowMap", size, size, false, format, [Target, Cube]);
|
|
merge = ctx.textures.allocTarget("pointShadowMap", size, size, false, format, [Target, Cube]);
|
|
|
|
|
|
for(i in 0 ... 6){
|
|
for(i in 0 ... 6){
|
|
-
|
|
|
|
var pointLight = cast(light, h3d.scene.pbr.PointLight);
|
|
var pointLight = cast(light, h3d.scene.pbr.PointLight);
|
|
|
|
|
|
- if( mode != Mixed || ctx.computingStatic ) {
|
|
|
|
- var absPos = light.getAbsPos();
|
|
|
|
- lightCamera.setCubeMap(i, new h3d.Vector(absPos.tx, absPos.ty, absPos.tz));
|
|
|
|
- lightCamera.zFar = pointLight.range;
|
|
|
|
- lightCamera.update();
|
|
|
|
- }
|
|
|
|
|
|
+ var absPos = light.getAbsPos();
|
|
|
|
+ lightCamera.setCubeMap(i, new h3d.Vector(absPos.tx, absPos.ty, absPos.tz));
|
|
|
|
+ lightCamera.zFar = pointLight.range;
|
|
|
|
+ lightCamera.update();
|
|
|
|
|
|
ctx.engine.pushTarget(texture, i);
|
|
ctx.engine.pushTarget(texture, i);
|
|
ctx.engine.clear(0xFFFFFF, 1);
|
|
ctx.engine.clear(0xFFFFFF, 1);
|
|
passes = super.draw(passes);
|
|
passes = super.draw(passes);
|
|
ctx.engine.popTarget();
|
|
ctx.engine.popTarget();
|
|
|
|
+ }
|
|
|
|
|
|
- if( mode == Mixed && !ctx.computingStatic ) {
|
|
|
|
|
|
+ if( blur.radius > 0 )
|
|
|
|
+ blur.apply(ctx, texture);
|
|
|
|
+
|
|
|
|
+ if( mode == Mixed && !ctx.computingStatic && merge != null ) {
|
|
|
|
+ for(i in 0 ... 6){
|
|
mergePass.shader.texA = texture;
|
|
mergePass.shader.texA = texture;
|
|
mergePass.shader.texB = staticTexture;
|
|
mergePass.shader.texB = staticTexture;
|
|
mergePass.shader.mat = cubeDir[i];
|
|
mergePass.shader.mat = cubeDir[i];
|
|
@@ -161,18 +169,19 @@ class PointShadowMap extends Shadows {
|
|
mergePass.render();
|
|
mergePass.render();
|
|
ctx.engine.popTarget();
|
|
ctx.engine.popTarget();
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- if( blur.radius > 0 && (mode != Mixed || !ctx.computingStatic) )
|
|
|
|
- blur.apply(ctx, texture);
|
|
|
|
-
|
|
|
|
- if( mode == Mixed && !ctx.computingStatic )
|
|
|
|
texture = merge;
|
|
texture = merge;
|
|
|
|
+ }
|
|
|
|
|
|
syncShader(texture);
|
|
syncShader(texture);
|
|
return passes;
|
|
return passes;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function updateCamera(){
|
|
|
|
+ var absPos = light.getAbsPos();
|
|
|
|
+ lightCamera.pos.set(absPos.tx, absPos.ty, absPos.tz);
|
|
|
|
+ lightCamera.update();
|
|
|
|
+ }
|
|
|
|
+
|
|
override function computeStatic( passes : h3d.pass.Object ) {
|
|
override function computeStatic( passes : h3d.pass.Object ) {
|
|
if( mode != Static && mode != Mixed )
|
|
if( mode != Static && mode != Mixed )
|
|
return;
|
|
return;
|