From d76a76a1c4777510fa0a37ee5c2390bf9394f687 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 10 Nov 2020 13:57:26 -0600 Subject: [PATCH] shader preprocessor fixes some hardware/apis do not evalueate 'not defined' as '0', so always ensure there's *some* value when doing macro value comparisons --- .../core/rendering/shaders/gl/lighting.glsl | 22 ++++++++++++++----- .../game/core/rendering/shaders/lighting.hlsl | 12 ++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 2fc447a95..e94081142 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -24,7 +24,7 @@ #include "./brdf.glsl" #ifndef TORQUE_SHADERGEN -#line 26 +#line 27 // These are the uniforms used by most lighting shaders. uniform vec4 inLightPos[4]; @@ -52,6 +52,18 @@ uniform vec4 albedo; #define MAX_FORWARD_LIGHT 4 +#ifndef CAPTURING +#define CAPTURING 0 +#endif + +#ifndef DEBUGVIZ_ATTENUATION +#define DEBUGVIZ_ATTENUATION 0 +#endif + +#ifndef DEBUGVIZ_CONTRIB +#define DEBUGVIZ_CONTRIB 0 +#endif + vec3 getDistanceVectorToPlane( vec3 origin, vec3 direction, vec4 plane ) { float denum = dot( plane.xyz, direction.xyz ); @@ -219,7 +231,7 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq); vec3 Fr = D * F * Vis; -#if CAPTURING == true +#if (CAPTURING == 1) return mix(Fd + Fr,surface.f0,surface.metalness); #else return Fd + Fr; @@ -416,7 +428,7 @@ vec4 computeForwardProbes(Surface surface, } } -#if DEBUGVIZ_ATTENUATION == 1 +#if (DEBUGVIZ_ATTENUATION == 1) float contribAlpha = 1; for (i = 0; i < numProbes; ++i) { @@ -426,7 +438,7 @@ vec4 computeForwardProbes(Surface surface, return vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1); #endif -#if DEBUGVIZ_CONTRIB == 1 +#if (DEBUGVIZ_CONTRIB == 1) vec3 probeContribColors[4]; probeContribColors[0] = vec3(1,0,0); probeContribColors[1] = vec3(0,1,0); @@ -653,4 +665,4 @@ vec4 debugVizForwardProbes(Surface surface, horizon *= horizon; return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled -} \ No newline at end of file +} diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index b948eae27..8f6ef8c88 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -53,6 +53,18 @@ uniform float4 albedo; #define MAX_FORWARD_LIGHT 4 +#ifndef CAPTURING +#define CAPTURING 0 +#endif + +#ifndef DEBUGVIZ_ATTENUATION +#define DEBUGVIZ_ATTENUATION 0 +#endif + +#ifndef DEBUGVIZ_CONTRIB +#define DEBUGVIZ_CONTRIB 0 +#endif + inline float3 getDistanceVectorToPlane( float3 origin, float3 direction, float4 plane ) { float denum = dot( plane.xyz, direction.xyz );