|
@@ -1,29 +1,30 @@
|
|
|
-float GetDiffuseDir(vec3 normal, vec3 lightDir)
|
|
|
|
|
|
|
+float GetDiffuse(vec3 normal, vec3 lightVec, out vec3 lightDir)
|
|
|
{
|
|
{
|
|
|
- return max(dot(normal, lightDir), 0.0);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-float GetDiffuseDirVolumetric()
|
|
|
|
|
-{
|
|
|
|
|
- return 1.0;
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ #ifdef DIRLIGHT
|
|
|
|
|
+ #ifdef NORMALMAP
|
|
|
|
|
+ // In normal mapped forward lighting, the tangent space light vector needs renormalization
|
|
|
|
|
+ lightDir = normalize(lightVec);
|
|
|
|
|
+ #else
|
|
|
|
|
+ lightDir = lightVec;
|
|
|
|
|
+ #endif
|
|
|
|
|
|
|
|
-#if defined(POINTLIGHT) || defined(SPOTLIGHT)
|
|
|
|
|
-float GetDiffusePointOrSpot(vec3 normal, vec3 lightVec, out vec3 lightDir)
|
|
|
|
|
-{
|
|
|
|
|
- float lightDist = length(lightVec);
|
|
|
|
|
- lightDir = lightVec / lightDist;
|
|
|
|
|
- return max(dot(normal, lightDir), 0.0) * texture2D(sLightRampMap, vec2(lightDist, 0.0)).r;
|
|
|
|
|
|
|
+ return max(dot(normal, lightDir), 0.0);
|
|
|
|
|
+ #else
|
|
|
|
|
+ float lightDist = length(lightVec);
|
|
|
|
|
+ lightDir = lightVec / lightDist;
|
|
|
|
|
+ return max(dot(normal, lightDir), 0.0) * texture2D(sLightRampMap, vec2(lightDist, 0.0)).r;
|
|
|
|
|
+ #endif
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
|
|
|
|
-#if defined(POINTLIGHT) || defined(SPOTLIGHT)
|
|
|
|
|
-float GetDiffusePointOrSpotVolumetric(vec3 lightVec)
|
|
|
|
|
|
|
+float GetDiffuseVolumetric(vec3 lightVec)
|
|
|
{
|
|
{
|
|
|
- float lightDist = length(lightVec);
|
|
|
|
|
- return texture2D(sLightRampMap, vec2(lightDist, 0.0)).r;
|
|
|
|
|
|
|
+ #ifdef DIRLIGHT
|
|
|
|
|
+ return 1.0;
|
|
|
|
|
+ #else
|
|
|
|
|
+ float lightDist = length(lightVec);
|
|
|
|
|
+ return texture2D(sLightRampMap, vec2(lightDist, 0.0)).r;
|
|
|
|
|
+ #endif
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
|
|
|
|
float GetSpecular(vec3 normal, vec3 eyeVec, vec3 lightDir, float specularPower)
|
|
float GetSpecular(vec3 normal, vec3 eyeVec, vec3 lightDir, float specularPower)
|
|
|
{
|
|
{
|