From d74055619f028b248556eb031c8777c2843d9c78 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Mon, 12 Nov 2018 22:55:52 -0600 Subject: [PATCH] emissive fix: return the surface.basecolor in place of zeros emissive is at minimum non-shadowed. TODO: consult folks on if they want a multiplier, mask, or mix for further customization there. --- .../common/lighting/advanced/pointLightP.hlsl | 4 ++++ .../shaders/common/lighting/advanced/spotLightP.hlsl | 6 +++++- .../common/lighting/advanced/vectorLightP.hlsl | 12 +++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl index 21d89d1db..a9d4e287b 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl @@ -173,7 +173,11 @@ LightTargetOutput main( ConvexConnectP IN ) uvScene, eyePosWorld, eyeRay, cameraToWorld); //early out if emissive if (getFlag(surface.matFlag, 0)) + { + Output.diffuse = surface.baseColor; + Output.spec = surface.baseColor; return Output; + } // If we can do dynamic branching then avoid wasting // fillrate on pixels that are backfacing to the light. diff --git a/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl index 4ee3733df..aee6ac66a 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl @@ -110,8 +110,12 @@ LightTargetOutput main( ConvexConnectP IN ) uvScene, eyePosWorld, eyeRay, cameraToWorld); //early out if emissive if (getFlag(surface.matFlag, 0)) + { + Output.diffuse = surface.baseColor; + Output.spec = surface.baseColor; return Output; - + } + //create surface to light float3 wsLightDir = mul(cameraToWorld, float4(lightDirection,0)).xyz; SurfaceToLight surfaceToLight = CreateSurfaceToLight(surface, -wsLightDir); diff --git a/Templates/Full/game/shaders/common/lighting/advanced/vectorLightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/vectorLightP.hlsl index 5341ad36f..9c9f3aa2b 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/vectorLightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/vectorLightP.hlsl @@ -134,7 +134,7 @@ float4 AL_VectorLightShadowCast( TORQUE_SAMPLER2D(sourceShadowMap), #ifdef NO_SHADOW debugColor = float3(1.0,1.0,1.0); #endif - + #ifdef PSSM_DEBUG_RENDER if ( finalMask.x > 0 ) debugColor += float3( 1, 0, 0 ); @@ -194,6 +194,15 @@ LightTargetOutput main(FarFrustumQuadConnectP IN) //create surface Surface surface = CreateSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer), IN.uv0, eyePosWorld, IN.wsEyeRay, cameraToWorld); + + //early out if emissive + if (getFlag(surface.matFlag, 0)) + { + Output.diffuse = surface.baseColor; + Output.spec = surface.baseColor; + return Output; + } + //create surface to light float3 wsLightDir = mul(cameraToWorld, float4(lightDirection,0)).xyz; SurfaceToLight surfaceToLight = CreateSurfaceToLight(surface, -wsLightDir); @@ -215,6 +224,7 @@ LightTargetOutput main(FarFrustumQuadConnectP IN) float4 dynamic_shadowed_colors = AL_VectorLightShadowCast( TORQUE_SAMPLER2D_MAKEARG(dynamicShadowMap), IN.uv0.xy, dynamicWorldToLightProj, surface.P, dynamicScaleX, dynamicScaleY, dynamicOffsetX, dynamicOffsetY, dynamicFarPlaneScalePSSM, surfaceToLight.NdotL); + float static_shadowed = static_shadowed_colors.a; float dynamic_shadowed = dynamic_shadowed_colors.a;