remove useless normalization in lighting shaders
This commit is contained in:
parent
fca6d4a8b2
commit
628fa23059
@ -173,7 +173,7 @@ void main(){
|
|||||||
// allow use of control flow
|
// allow use of control flow
|
||||||
if(g_LightDirection.w != 0.0){
|
if(g_LightDirection.w != 0.0){
|
||||||
#endif
|
#endif
|
||||||
spotFallOff = computeSpotFalloff(g_LightDirection, lightVec);
|
spotFallOff = computeSpotFalloff(g_LightDirection, lightDir.xyz);
|
||||||
#if __VERSION__ >= 110
|
#if __VERSION__ >= 110
|
||||||
if(spotFallOff <= 0.0){
|
if(spotFallOff <= 0.0){
|
||||||
gl_FragColor.rgb = AmbientSum * diffuseColor.rgb;
|
gl_FragColor.rgb = AmbientSum * diffuseColor.rgb;
|
||||||
|
@ -158,7 +158,7 @@ void main(){
|
|||||||
// allow use of control flow
|
// allow use of control flow
|
||||||
if(lightColor.w > 1.0){
|
if(lightColor.w > 1.0){
|
||||||
#endif
|
#endif
|
||||||
spotFallOff = computeSpotFalloff(g_LightDirection, lightVec);
|
spotFallOff = computeSpotFalloff(g_LightDirection, vLightDir.xyz);
|
||||||
#if __VERSION__ >= 110
|
#if __VERSION__ >= 110
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -223,14 +223,13 @@ void main(){
|
|||||||
// allow use of control flow
|
// allow use of control flow
|
||||||
if(lightColor.w > 1.0){
|
if(lightColor.w > 1.0){
|
||||||
#endif
|
#endif
|
||||||
fallOff = computeSpotFalloff(g_LightData[i+2], lightVec);
|
fallOff = computeSpotFalloff(g_LightData[i+2], lightDir.xyz);
|
||||||
#if __VERSION__ >= 110
|
#if __VERSION__ >= 110
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//point light attenuation
|
//point light attenuation
|
||||||
fallOff *= lightDir.w;
|
fallOff *= lightDir.w;
|
||||||
|
|
||||||
lightDir.xyz = normalize(lightDir.xyz);
|
|
||||||
vec3 directDiffuse;
|
vec3 directDiffuse;
|
||||||
vec3 directSpecular;
|
vec3 directSpecular;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void main(){
|
|||||||
// allow use of control flow
|
// allow use of control flow
|
||||||
if(lightColor.w > 1.0){
|
if(lightColor.w > 1.0){
|
||||||
#endif
|
#endif
|
||||||
spotFallOff = computeSpotFalloff(g_LightData[i+2], lightVec);
|
spotFallOff = computeSpotFalloff(g_LightData[i+2], lightDir.xyz);
|
||||||
#if __VERSION__ >= 110
|
#if __VERSION__ >= 110
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -155,7 +155,7 @@ void main(){
|
|||||||
if(lightColor.w > 1.0){
|
if(lightColor.w > 1.0){
|
||||||
#endif
|
#endif
|
||||||
vec4 lightDirection = g_LightData[i+2];
|
vec4 lightDirection = g_LightData[i+2];
|
||||||
spotFallOff = computeSpotFalloff(lightDirection, lightVec);
|
spotFallOff = computeSpotFalloff(lightDirection, lightDir.xyz);
|
||||||
#if __VERSION__ >= 110
|
#if __VERSION__ >= 110
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,9 +23,9 @@ void lightComputeDir(in vec3 worldPos, in float lightType, in vec4 position, out
|
|||||||
/*
|
/*
|
||||||
* Computes the spot falloff for a spotlight
|
* Computes the spot falloff for a spotlight
|
||||||
*/
|
*/
|
||||||
float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector){
|
float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector) {
|
||||||
vec3 L=normalize(lightVector);
|
vec3 L = lightVector;
|
||||||
vec3 spotdir = normalize(lightDirection.xyz);
|
vec3 spotdir = lightDirection.xyz;
|
||||||
float curAngleCos = dot(-L, spotdir);
|
float curAngleCos = dot(-L, spotdir);
|
||||||
float innerAngleCos = floor(lightDirection.w) * 0.001;
|
float innerAngleCos = floor(lightDirection.w) * 0.001;
|
||||||
float outerAngleCos = fract(lightDirection.w);
|
float outerAngleCos = fract(lightDirection.w);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user