Optimized shadows of the torches.
This commit is contained in:
parent
e13ddb14f6
commit
d6aef2a244
@ -74,7 +74,7 @@
|
|||||||
<rColour>1.0</rColour>
|
<rColour>1.0</rColour>
|
||||||
<gColour>0.9</gColour>
|
<gColour>0.9</gColour>
|
||||||
<bColour>0.3</bColour>
|
<bColour>0.3</bColour>
|
||||||
<intensity>10.0</intensity>
|
<intensity>8.0</intensity>
|
||||||
<flameOffset>-0.5</flameOffset>
|
<flameOffset>-0.5</flameOffset>
|
||||||
<flameHeight>1.0</flameHeight>
|
<flameHeight>1.0</flameHeight>
|
||||||
<flameWidth>1.0</flameWidth>
|
<flameWidth>1.0</flameWidth>
|
||||||
|
@ -146,8 +146,9 @@ float samplePointShadow(samplerCubeShadow shadowMap, vec3 lightDirection) {
|
|||||||
float A = -(farPlane+nearPlane)/(farPlane-nearPlane);
|
float A = -(farPlane+nearPlane)/(farPlane-nearPlane);
|
||||||
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
|
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
|
||||||
float compValue = 0.5*(-A*length(lightDirection) + B)/length(lightDirection) + 0.5;
|
float compValue = 0.5*(-A*length(lightDirection) + B)/length(lightDirection) + 0.5;
|
||||||
float bias = 0.001*tan(acos(clamp(dot(vNormal, lightDirection), 0.0, 1.0)));
|
float bias = 0.001*tan(acos(clamp(dot(vNormal, normalize(lightDirection)), 0.0, 1.0)));
|
||||||
bias = clamp(bias, 0.0, 0.0005);
|
bias = clamp(bias, 0.0, 0.001);
|
||||||
|
bias *= 1/length(lightDirection)*8;
|
||||||
return texture(shadowMap, vec4(lightDirection , compValue - bias));
|
return texture(shadowMap, vec4(lightDirection , compValue - bias));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,11 +249,11 @@ void main()
|
|||||||
intensity = clamp(exp(-(1/lightIntensities[i])*distance), 0.0, 1.0);
|
intensity = clamp(exp(-(1/lightIntensities[i])*distance), 0.0, 1.0);
|
||||||
}
|
}
|
||||||
diffuseColor += clamp(dot(normalize(vNormal), lightVector)
|
diffuseColor += clamp(dot(normalize(vNormal), lightVector)
|
||||||
*diffuseFactor*intensity*lightColors[i], 0.0, 1.0)*pointVisibility;
|
*diffuseFactor*intensity*lightColors[i]*pointVisibility, 0.0, 1.0);
|
||||||
vec3 cameraVector = normalize(camera - vec3(fragPosition));
|
vec3 cameraVector = normalize(camera - vec3(fragPosition));
|
||||||
specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/
|
specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/
|
||||||
(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess), 0.0, 1.0)
|
(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess)*pointVisibility, 0.0, 1.0)
|
||||||
*specularFactor*intensity*lightColors[i]*pointVisibility;
|
*specularFactor*intensity*lightColors[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user