Merge remote-tracking branch 'upstream/development' into ShaderConstBuffer-CleanupRefactor

This commit is contained in:
marauder2k7 2024-02-24 14:42:53 +00:00
commit d9fd3375da
9 changed files with 61 additions and 30 deletions

View file

@ -132,7 +132,7 @@ void SpotLight::_conformLights()
mLight->setDynamicRefreshFreq(mDynamicRefreshFreq);
mLight->setPriority( mPriority );
mOuterConeAngle = getMax( 0.01f, mOuterConeAngle );
mOuterConeAngle = getMin(getMax( 0.01f, mOuterConeAngle ),179.0f);
mInnerConeAngle = getMin( mInnerConeAngle, mOuterConeAngle );
mLight->setInnerConeAngle( mInnerConeAngle );

View file

@ -399,9 +399,9 @@ void AdvancedLightBinManager::render( SceneRenderState *state )
sunLight->getCastShadows() &&
!disableShadows &&
sunLight->getExtended<ShadowMapParams>() )
vectorMatInfo = _getLightMaterial( LightInfo::Vector, ShadowType_PSSM );
vectorMatInfo = _getLightMaterial( LightInfo::Vector, ShadowType_PSSM,false,false );
else
vectorMatInfo = _getLightMaterial( LightInfo::Vector, ShadowType_None );
vectorMatInfo = _getLightMaterial( LightInfo::Vector, ShadowType_None, false, false);
// Initialize and set the per-frame parameters after getting
// the vector light material as we use lazy creation.

View file

@ -71,7 +71,7 @@ public:
//-----------------------------------------------------------------------
enum Constants
{
MAX_TEX_PER_PASS = 8, ///< Number of textures per pass
MAX_TEX_PER_PASS = 16, ///< Number of textures per pass
MAX_STAGES = 4,
NUM_EFFECT_COLOR_STAGES = 2, ///< Number of effect color definitions for transitioning effects.
};

View file

@ -360,6 +360,7 @@ void ProcessedCustomMaterial::setTextureStages( SceneRenderState *state, const S
break;
case Material::Mask:
case Material::PhotometricMask:
case Material::Standard:
case Material::Bump:
case Material::Detail:

View file

@ -118,6 +118,7 @@ singleton GFXStateBlockData( AL_ConvexLightState )
samplerStates[3] = SamplerClampPoint; // colorBuffer
samplerStates[4] = SamplerClampPoint; // matInfoBuffer
samplerStates[5] = SamplerClampLinear; // Cookie Map
samplerStates[6] = SamplerClampLinear; // iesProfile
cullDefined = true;
cullMode = GFXCullCW;
@ -142,6 +143,7 @@ singleton shaderData( AL_PointLightShader )
samplerNames[3] = "$colorBuffer";
samplerNames[4] = "$matInfoBuffer";
samplerNames[5] = "$cookieMap";
samplerNames[6] = "$iesProfile";
pixVersion = 3.0;
};
@ -156,7 +158,7 @@ singleton CustomMaterial( AL_PointLightMaterial )
sampler["cookieMap"] = "$dynamiclightmask";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
sampler["iesProfile"] = "$photometricmask";
target = "AL_FormatToken";
pixVersion = 3.0;
@ -177,6 +179,7 @@ singleton shaderData( AL_SpotLightShader )
samplerNames[3] = "$colorBuffer";
samplerNames[4] = "$matInfoBuffer";
samplerNames[5] = "$cookieMap";
samplerNames[6] = "$iesProfile";
pixVersion = 3.0;
};
@ -188,10 +191,10 @@ singleton CustomMaterial( AL_SpotLightMaterial )
sampler["deferredBuffer"] = "#deferred";
sampler["shadowMap"] = "$dynamiclight";
sampler["iesProfile"] = "$photometricmask";
sampler["cookieMap"] = "$dynamiclightmask";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "AL_FormatToken";
pixVersion = 3.0;

View file

@ -108,6 +108,7 @@ uniform sampler2D deferredBuffer;
#include "softShadow.glsl"
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
#ifdef SHADOW_CUBE
/// The texture for cookie rendering.
uniform samplerCube cookieMap;
@ -115,11 +116,14 @@ uniform samplerCube cookieMap;
uniform sampler2D cookieMap;
#endif
uniform sampler2D iesProfile;
#ifdef UES_PHOTOMETRIC_MASK
uniform sampler1D iesProfile;
#endif
uniform vec4 rtParams0;
uniform vec3 lightPosition;
uniform vec3 lightDirection;
uniform vec4 lightColor;
uniform float lightBrightness;
uniform float lightRange;
@ -230,17 +234,18 @@ void main()
OUT_col = vec4(final, 0);
return
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = texture(iesProfile, vec2(angle, 0.0)).r;
float iesMask = texture(iesProfile,angle).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
}

View file

@ -19,7 +19,6 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "farFrustumQuad.glsl"
#include "../../shadowMap/shadowMapIO_GLSL.h"
@ -38,8 +37,15 @@ uniform sampler2D shadowMap;
#include "softShadow.glsl"
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
#ifdef USE_COOKIE_TEX
uniform sampler2D cookieMap;
uniform sampler2D iesProfile;
#endif
#ifdef UES_PHOTOMETRIC_MASK
uniform sampler1D iesProfile;
#endif
uniform vec4 rtParams0;
uniform float lightBrightness;
@ -109,7 +115,10 @@ void main()
vec3 lightCol = lightColor.rgb;
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
vec4 cookie = texture(cookieMap, shadowCoord);
vec4 pxlPosLightProj = tMul( worldToLightProj, vec4( surface.P, 1 ) );
vec2 cookieCoord = ( ( pxlPosLightProj.xy / pxlPosLightProj.w ) * 0.5 ) + vec2( 0.5, 0.5 );
cookieCoord.y = 1.0f - cookieCoord.y;
vec4 cookie = texture(cookieMap, cookieCoord);
// Multiply the light with the cookie tex.
lightCol *= cookie.rgb;
// Use a maximum channel luminance to attenuate
@ -154,16 +163,17 @@ void main()
return;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = texture(iesProfile, vec2(angle, 0.0)).r;
float iesMask = texture(iesProfile, angle/(lightSpotParams.x-lightSpotParams.y)).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
}
OUT_col = vec4(lighting, 0);

View file

@ -107,13 +107,17 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
#include "softShadow.hlsl"
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
/// The texture for cookie rendering.
#ifdef SHADOW_CUBE
TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5);
#else
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
#endif
TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
#ifdef UES_PHOTOMETRIC_MASK
TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6);
#endif
uniform float4 rtParams0;
uniform float4 lightColor;
@ -223,17 +227,18 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
return final;
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r;
float iesMask = TORQUE_TEX1D(iesProfile, angle).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
}

View file

@ -43,8 +43,14 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
/// The texture for cookie rendering.
#ifdef USE_COOKIE_TEX
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
#endif
#ifdef UES_PHOTOMETRIC_MASK
TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6);
#endif
uniform float4 rtParams0;
@ -153,16 +159,17 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
return final;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r;
float iesMask = TORQUE_TEX1D(iesProfile, angle/(lightSpotParams.x-lightSpotParams.y)).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
}
return float4(lighting, 0);