mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
shift capturing from a globalMacro to a sceneRenderstate S32
lets us ditch shader recompilation so that can be done on the fly without hitches, though does cost us a per-shader const for objects and postfx
This commit is contained in:
parent
71e0626ec2
commit
fe26ffc375
13 changed files with 69 additions and 101 deletions
|
|
@ -24,6 +24,7 @@
|
|||
#include "./brdf.glsl"
|
||||
|
||||
uniform float maxProbeDrawDistance;
|
||||
uniform int isCapturing;
|
||||
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
#line 27
|
||||
|
|
@ -54,10 +55,6 @@ uniform vec4 albedo;
|
|||
|
||||
#define MAX_FORWARD_LIGHT 4
|
||||
|
||||
#ifndef CAPTURING
|
||||
#define CAPTURING 0
|
||||
#endif
|
||||
|
||||
#ifndef DEBUGVIZ_ATTENUATION
|
||||
#define DEBUGVIZ_ATTENUATION 0
|
||||
#endif
|
||||
|
|
@ -237,32 +234,28 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
|
|||
float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
|
||||
vec3 Fr = D * F * Vis;
|
||||
|
||||
#if CAPTURING == 1
|
||||
return mix(Fd + Fr, surface.baseColor.rgb, surface.metalness);
|
||||
#else
|
||||
return Fd + Fr;
|
||||
#endif
|
||||
|
||||
if(isCapturing == 1)
|
||||
return mix(Fd + Fr, surface.baseColor.rgb, surface.metalness);
|
||||
else
|
||||
return Fd + Fr;
|
||||
}
|
||||
|
||||
vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow)
|
||||
{
|
||||
#if CAPTURING == 1
|
||||
float lightfloor = CAPTURE_LIGHT_FLOOR;
|
||||
#else
|
||||
float lightfloor = 0.0;
|
||||
#endif
|
||||
if(isCapturing != 1)
|
||||
lightfloor = 0.0;
|
||||
|
||||
vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity, lightfloor);
|
||||
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
|
||||
}
|
||||
|
||||
vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, float shadow)
|
||||
{
|
||||
#if CAPTURING == 1
|
||||
float lightfloor = CAPTURE_LIGHT_FLOOR;
|
||||
#else
|
||||
float lightfloor = 0.0;
|
||||
#endif
|
||||
if(isCapturing != 1)
|
||||
lightfloor = 0.0;
|
||||
|
||||
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
||||
vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity * attenuation, lightfloor);
|
||||
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
|
||||
|
|
@ -270,11 +263,10 @@ vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 light
|
|||
|
||||
vec3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, vec3 lightDir, vec2 lightSpotParams, float shadow)
|
||||
{
|
||||
#if CAPTURING == 1
|
||||
float lightfloor = CAPTURE_LIGHT_FLOOR;
|
||||
#else
|
||||
float lightfloor = 0.0;
|
||||
#endif
|
||||
if(isCapturing != 1)
|
||||
lightfloor = 0.0;
|
||||
|
||||
float attenuation = 1.0f;
|
||||
attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
|
||||
attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
|
||||
|
|
@ -567,11 +559,11 @@ vec4 computeForwardProbes(Surface surface,
|
|||
float horizonOcclusion = 1.3;
|
||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||
horizon *= horizon;
|
||||
#if CAPTURING == 1
|
||||
return vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
|
||||
#else
|
||||
return vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
|
||||
#endif
|
||||
|
||||
if(isCapturing == 1)
|
||||
return vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
|
||||
else
|
||||
return vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
|
||||
}
|
||||
|
||||
vec4 debugVizForwardProbes(Surface surface,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
//globals
|
||||
uniform float3 eyePosWorld;
|
||||
uniform float maxProbeDrawDistance;
|
||||
uniform int isCapturing;
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
|
||||
// These are the uniforms used by most lighting shaders.
|
||||
|
|
@ -56,10 +57,6 @@ uniform float4 albedo;
|
|||
|
||||
#define MAX_FORWARD_LIGHT 4
|
||||
|
||||
#ifndef CAPTURING
|
||||
#define CAPTURING 0
|
||||
#endif
|
||||
|
||||
#ifndef DEBUGVIZ_ATTENUATION
|
||||
#define DEBUGVIZ_ATTENUATION 0
|
||||
#endif
|
||||
|
|
@ -238,32 +235,28 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
|
|||
float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
|
||||
float3 Fr = D * F * Vis;
|
||||
|
||||
#if CAPTURING == 1
|
||||
return lerp(Fd + Fr,surface.baseColor.rgb,surface.metalness);
|
||||
#else
|
||||
return Fd + Fr;
|
||||
#endif
|
||||
|
||||
if(isCapturing == 1)
|
||||
return lerp(Fd + Fr,surface.baseColor.rgb,surface.metalness);
|
||||
else
|
||||
return Fd + Fr;
|
||||
}
|
||||
|
||||
float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow)
|
||||
{
|
||||
#if CAPTURING == 1
|
||||
float lightfloor = CAPTURE_LIGHT_FLOOR;
|
||||
#else
|
||||
float lightfloor = 0.0;
|
||||
#endif
|
||||
if(isCapturing != 1)
|
||||
lightfloor = 0.0;
|
||||
|
||||
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity, lightfloor) ;
|
||||
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
|
||||
}
|
||||
|
||||
float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float shadow)
|
||||
{
|
||||
#if CAPTURING == 1
|
||||
float lightfloor = CAPTURE_LIGHT_FLOOR;
|
||||
#else
|
||||
float lightfloor = 0.0;
|
||||
#endif
|
||||
if(isCapturing != 1)
|
||||
lightfloor = 0.0;
|
||||
|
||||
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
||||
float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, lightfloor) ;
|
||||
return evaluateStandardBRDF(surface,surfaceToLight) * factor;
|
||||
|
|
@ -271,11 +264,10 @@ float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 l
|
|||
|
||||
float3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float3 lightDir, float2 lightSpotParams, float shadow)
|
||||
{
|
||||
#if CAPTURING == 1
|
||||
float lightfloor = CAPTURE_LIGHT_FLOOR;
|
||||
#else
|
||||
float lightfloor = 0.0;
|
||||
#endif
|
||||
if(isCapturing != 1)
|
||||
lightfloor = 0.0;
|
||||
|
||||
float attenuation = 1.0f;
|
||||
attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
|
||||
attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
|
||||
|
|
@ -573,11 +565,11 @@ float4 computeForwardProbes(Surface surface,
|
|||
float horizonOcclusion = 1.3;
|
||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||
horizon *= horizon;
|
||||
#if CAPTURING == 1
|
||||
return float4(lerp((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
|
||||
#else
|
||||
return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
|
||||
#endif
|
||||
|
||||
if(isCapturing == 1)
|
||||
return float4(lerp((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
|
||||
else
|
||||
return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
|
||||
}
|
||||
|
||||
float4 debugVizForwardProbes(Surface surface,
|
||||
|
|
|
|||
|
|
@ -222,9 +222,9 @@ void main()
|
|||
float horizonOcclusion = 1.3;
|
||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||
horizon *= horizon;
|
||||
#if CAPTURING == 1
|
||||
OUT_col = vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb, surface.metalness),0);
|
||||
#else
|
||||
OUT_col = vec4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
|
||||
#endif
|
||||
|
||||
if(isCapturing == 1)
|
||||
OUT_col = vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb, surface.metalness),0);
|
||||
else
|
||||
OUT_col = vec4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,9 +208,9 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
float horizonOcclusion = 1.3;
|
||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||
horizon *= horizon;
|
||||
#if CAPTURING == 1
|
||||
return float4(lerp((irradiance + specular* horizon), surface.baseColor.rgb,surface.metalness),0);
|
||||
#else
|
||||
return float4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
|
||||
#endif
|
||||
|
||||
if(isCapturing == 1)
|
||||
return float4(lerp((irradiance + specular* horizon), surface.baseColor.rgb,surface.metalness),0);
|
||||
else
|
||||
return float4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue