Skip to content

Commit

Permalink
Fix cube shadow map
Browse files Browse the repository at this point in the history
  • Loading branch information
TothBenoit committed Dec 22, 2023
1 parent 9fa3157 commit 5c60edb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions h3d/pass/CubeShadowMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,9 @@ class CubeShadowMap extends Shadows {

var prevFar = @:privateAccess ctx.cameraFar;
var prevPos = @:privateAccess ctx.cameraPos;
@:privateAccess ctx.cameraFar = lightCamera.zFar;
@:privateAccess ctx.cameraPos = lightCamera.pos;
var prevViewProj = @:privateAccess ctx.cameraViewProj;

for( i in 0...6 ) {

// Shadows on the current face is disabled
if( !faceMask.has(CubeFaceFlag.createByIndex(i)) ) {
clear(texture, i);
Expand All @@ -199,13 +197,19 @@ class CubeShadowMap extends Shadows {

ctx.engine.pushTarget(texture, i);
format == RGBA ? ctx.engine.clear(0xFFFFFF, i) : ctx.engine.clearF(clearDepthColor, 1);

@:privateAccess ctx.cameraViewProj = getShadowProj();
@:privateAccess ctx.cameraFar = lightCamera.zFar;
@:privateAccess ctx.cameraPos = lightCamera.pos;

super.draw(passes,sort);
passes.load(save);
ctx.engine.popTarget();
}

@:privateAccess ctx.cameraFar = prevFar;
@:privateAccess ctx.cameraPos = prevPos;
@:privateAccess ctx.cameraViewProj = prevViewProj;

// Blur is applied even if there's no shadows - TO DO : remove the useless blur pass
if( blur.radius > 0 )
Expand All @@ -215,6 +219,7 @@ class CubeShadowMap extends Shadows {
syncShader(merge(texture));
else
syncShader(texture);

}

function merge( dynamicTex : h3d.mat.Texture ) : h3d.mat.Texture{
Expand Down

0 comments on commit 5c60edb

Please sign in to comment.