mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-03-06 14:27:44 +00:00
Remove fixed shading check from specular.
This commit is contained in:
parent
4d685e0750
commit
7f6df0cc84
|
@ -164,40 +164,40 @@ void main()
|
|||
float ellipse;
|
||||
ellipse = length((gl_FragCoord.xy - spotEllipse.xy) / spotEllipse.zw);
|
||||
ellipse = pow(ellipse, 2.0); // decay rate = square of distance from center
|
||||
ellipse = 1.0 - ellipse; // invert
|
||||
ellipse = max(0.0, ellipse); // clamp
|
||||
|
||||
// Compute spotlight and apply lighting
|
||||
float enable, absExtent, d, inv_r, range;
|
||||
|
||||
// start of spotlight
|
||||
enable = step(spotRange.x, -fsViewVertex.z);
|
||||
|
||||
if (spotRange.y == 0.0) {
|
||||
range = 0.0;
|
||||
}
|
||||
else {
|
||||
absExtent = abs(spotRange.y);
|
||||
|
||||
d = spotRange.x + absExtent + fsViewVertex.z;
|
||||
d = min(d, 0.0);
|
||||
|
||||
// slope of decay function
|
||||
inv_r = 1.0 / (1.0 + absExtent);
|
||||
|
||||
// inverse-linear falloff
|
||||
// Reference: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
|
||||
// y = 1 / (d/r + 1)^2
|
||||
range = 1.0 / pow(d * inv_r - 1.0, 2.0);
|
||||
range *= enable;
|
||||
}
|
||||
|
||||
float lobeEffect = range * ellipse;
|
||||
float lobeFogEffect = enable * ellipse;
|
||||
|
||||
if (lightEnabled) {
|
||||
vec3 lightIntensity;
|
||||
vec3 sunVector; // sun lighting vector (as reflecting away from vertex)
|
||||
ellipse = 1.0 - ellipse; // invert
|
||||
ellipse = max(0.0, ellipse); // clamp
|
||||
|
||||
// Compute spotlight and apply lighting
|
||||
float enable, absExtent, d, inv_r, range;
|
||||
|
||||
// start of spotlight
|
||||
enable = step(spotRange.x, -fsViewVertex.z);
|
||||
|
||||
if (spotRange.y == 0.0) {
|
||||
range = 0.0;
|
||||
}
|
||||
else {
|
||||
absExtent = abs(spotRange.y);
|
||||
|
||||
d = spotRange.x + absExtent + fsViewVertex.z;
|
||||
d = min(d, 0.0);
|
||||
|
||||
// slope of decay function
|
||||
inv_r = 1.0 / (1.0 + absExtent);
|
||||
|
||||
// inverse-linear falloff
|
||||
// Reference: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
|
||||
// y = 1 / (d/r + 1)^2
|
||||
range = 1.0 / pow(d * inv_r - 1.0, 2.0);
|
||||
range *= enable;
|
||||
}
|
||||
|
||||
float lobeEffect = range * ellipse;
|
||||
float lobeFogEffect = enable * ellipse;
|
||||
|
||||
if (lightEnabled) {
|
||||
vec3 lightIntensity;
|
||||
vec3 sunVector; // sun lighting vector (as reflecting away from vertex)
|
||||
float sunFactor; // sun light projection along vertex normal (0.0 to 1.0)
|
||||
|
||||
// Sun angle
|
||||
|
@ -224,15 +224,15 @@ void main()
|
|||
|
||||
// Upper clamp is optional, step 1.5+ games will drive brightness beyond 100%
|
||||
if(intensityClamp) {
|
||||
lightIntensity = min(lightIntensity,1.0);
|
||||
}
|
||||
|
||||
lightIntensity.rgb += spotColor*lobeEffect;
|
||||
|
||||
finalData.rgb *= lightIntensity;
|
||||
lightIntensity = min(lightIntensity,1.0);
|
||||
}
|
||||
|
||||
lightIntensity.rgb += spotColor*lobeEffect;
|
||||
|
||||
finalData.rgb *= lightIntensity;
|
||||
|
||||
// for now assume fixed shading doesn't work with specular
|
||||
if (specularEnabled && !fixedShading) {
|
||||
if (specularEnabled) {
|
||||
|
||||
float exponent, NdotL, specularFactor;
|
||||
vec4 biasIndex, expIndex, multIndex;
|
||||
|
@ -262,16 +262,16 @@ void main()
|
|||
}
|
||||
|
||||
// Final clamp: we need it for proper shading in dimmed light and dark ambients
|
||||
finalData.rgb = min(finalData.rgb, vec3(1.0));
|
||||
|
||||
// Spotlight on fog
|
||||
vec3 lSpotFogColor = spotFogColor * fogAttenuation * fogColour.rgb * lobeFogEffect;
|
||||
|
||||
// Fog & spotlight applied
|
||||
finalData.rgb = mix(finalData.rgb, fogData.rgb + lSpotFogColor, fogData.a);
|
||||
|
||||
gl_FragColor = finalData;
|
||||
}
|
||||
finalData.rgb = min(finalData.rgb, vec3(1.0));
|
||||
|
||||
// Spotlight on fog
|
||||
vec3 lSpotFogColor = spotFogColor * fogAttenuation * fogColour.rgb * lobeFogEffect;
|
||||
|
||||
// Fog & spotlight applied
|
||||
finalData.rgb = mix(finalData.rgb, fogData.rgb + lSpotFogColor, fogData.a);
|
||||
|
||||
gl_FragColor = finalData;
|
||||
}
|
||||
)glsl";
|
||||
|
||||
R3DShader::R3DShader(const Util::Config::Node &config)
|
||||
|
|
Loading…
Reference in a new issue