summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl11
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl165
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl135
5 files changed, 194 insertions, 137 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index 513b748f5f..699a9c0276 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -27,6 +27,8 @@
/*[EXTRA_CODE_HERE]*/
+#define DEBUG_PBR_LIGHT_TYPE 0
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -95,17 +97,24 @@ void main()
for (int light_idx = 0; light_idx < LIGHT_COUNT; ++light_idx)
{
vec3 lightColor = light_col[ light_idx ].rgb;
+ float falloff = light_col[ light_idx ].a;
float lightSize = light [ light_idx ].w;
vec3 lv =(light [ light_idx ].xyz - pos);
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
if (nl > 0.0 || nv > 0.0)
{
- vec3 intensity = getLightIntensityPoint(lightColor, lightSize, lightDist);
+ float dist = lightDist / lightSize;
+ float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff);
+ vec3 intensity = dist_atten * getLightIntensityPoint(lightColor, lightSize, lightDist);
colorDiffuse += intensity * nl * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
colorSpec += intensity * nl * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
}
}
+
+ #if DEBUG_PBR_LIGHT_TYPE
+ colorDiffuse = vec3(0,0.5,0); colorSpec = vec3(0);
+ #endif
final_color = colorDiffuse + colorSpec;
}
else
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index b86402b031..20309d9673 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -28,6 +28,16 @@
/*[EXTRA_CODE_HERE]*/
+#define DEBUG_PBR_LIGHT_TYPE 0 // Ouput gray if PBR multiSpot lights object
+#define DEBUG_PBR_SPOT 0
+#define DEBUG_PBR_SPOT_DIFFUSE 0 // PBR diffuse lit
+#define DEBUG_PBR_SPOT_SPECULAR 0 // PBR spec lit
+
+#define DEBUG_SPOT_DIFFUSE 0
+#define DEBUG_SPOT_NL 0 // monochome area effected by light
+#define DEBUG_SPOT_SPEC_POS 0
+#define DEBUG_SPOT_REFLECTION 0
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -42,7 +52,7 @@ uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, M
uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D noiseMap;
-uniform sampler2D projectionMap;
+uniform sampler2D projectionMap; // rgba
uniform sampler2D lightFunc;
uniform mat4 proj_mat; //screen space to light space
@@ -76,48 +86,15 @@ uniform mat4 inv_proj;
vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh );
vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh );
void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);
+bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc );
vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
+vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv );
+vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n);
vec2 getScreenXY(vec4 clip);
void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 cs);
-
-vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
-{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
- ret.rgb = srgb_to_linear(ret.rgb);
- vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
-
- float det = min(lod/(proj_lod*0.5), 1.0);
-
- float d = min(dist.x, dist.y);
-
- d *= min(1, d * (proj_lod - lod));
-
- float edge = 0.25*det;
-
- ret *= clamp(d/edge, 0.0, 1.0);
-
- return ret;
-}
-
-vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
-{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
- ret.rgb = srgb_to_linear(ret.rgb);
-
- vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
-
- float det = min(lod/(proj_lod*0.5), 1.0);
-
- float d = min(dist.x, dist.y);
-
- float edge = 0.25*det;
-
- ret *= clamp(d/edge, 0.0, 1.0);
-
- return ret;
-}
+vec4 texture2DLodSpecular(vec2 tc, float lod);
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
@@ -144,14 +121,13 @@ void main()
vec2 tc = getScreenXY(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
- vec3 lv = center.xyz-pos.xyz;
- float dist = length(lv);
-
- if (dist >= size)
+ vec3 lv;
+ vec4 proj_tc;
+ float dist, l_dist;
+ if (clipProjectedLightVars(center, pos, dist, l_dist, lv, proj_tc))
{
discard;
}
- dist /= size;
float shadow = 1.0;
@@ -167,24 +143,7 @@ void main()
vec3 n;
vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity);
- float l_dist = -dot(lv, proj_n);
-
- vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
- if (proj_tc.z < 0.0)
- {
- discard;
- }
-
- proj_tc.xyz /= proj_tc.w;
-
- float fa = falloff+1.0;
- float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0);
- dist_atten *= dist_atten;
- dist_atten *= 2.0;
- if (dist_atten <= 0.0)
- {
- discard;
- }
+ float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff);
lv = proj_origin-pos.xyz;
vec3 h, l, v = -normalize(pos);
@@ -194,6 +153,7 @@ void main()
vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
vec4 spec = texture2DRect(specularRect, tc);
vec3 dlit = vec3(0, 0, 0);
+ vec3 slit = vec3(0, 0, 0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
@@ -201,11 +161,68 @@ void main()
vec3 colorSpec = vec3(0);
vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
vec3 packedORM = texture2DRect(emissiveRect, tc).rgb; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+ float metal = packedORM.b;
+
+// if (proj_tc.x > 0.0 && proj_tc.x < 1.0
+// && proj_tc.y > 0.0 && proj_tc.y < 1.0)
+ if (nl > 0.0)
+ {
+ vec3 c_diff, reflect0, reflect90;
+ float alphaRough, specWeight;
+ initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight );
+
+ dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
+ slit = getProjectedLightSpecularColor( pos, n );
+
+// vec3 intensity = getLightIntensitySpot( color, size, lightDist, v );
+ colorDiffuse = shadow * dlit * nl * dist_atten;
+ colorSpec = shadow * slit * nl * dist_atten;
+
+// colorDiffuse *= BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh );
+// colorSpec *= BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh );
+
+ #if DEBUG_PBR_SPOT_DIFFUSE
+ colorDiffuse = dlit.rgb; colorSpec = vec3(0);
+ #endif
+ #if DEBUG_PBR_SPOT_SPECULAR
+ colorDiffuse = vec3(0); colorSpec = slit.rgb;
+ #endif
+ #if DEBUG_PBR_SPOT
+ colorDiffuse = dlit; colorSpec = vec3(0);
+ colorDiffuse *= nl;
+ colorDiffuse *= shadow;
+ #endif
+
+ #if DEBUG_SPOT_SPEC_POS
+ colorDiffuse = pos + ref * dot(pdelta, proj_n)/ds; colorSpec = vec3(0);
+ #endif
+ #if DEBUG_SPOT_REFLECTION
+ colorDiffuse = ref; colorSpec = vec3(0);
+ #endif
+
+ }
+
+ #if DEBUG_SPOT_DIFFUSE
+ colorDiffuse = vec3(nl * dist_atten);
+ #endif
+ #if DEBUG_SPOT_NL
+ colorDiffuse = vec3(nl); colorSpec = vec3(0);
+ #endif
+ #if DEBUG_PBR_LIGHT_TYPE
+ colorDiffuse = vec3(0.5); colorSpec = vec3(0);
+ #endif
final_color = colorDiffuse + colorSpec;
}
else
{
+ dist_atten *= dist_atten;
+ dist_atten *= 2.0;
+ if (dist_atten <= 0.0)
+ {
+ discard;
+ }
+
float noise = texture2D(noiseMap, tc/128.0).b;
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
@@ -220,13 +237,8 @@ void main()
{
lit = nl * dist_atten * noise;
- float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
- float lod = diff * proj_lod;
-
- vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
-
- dlit = color.rgb * plcol.rgb * plcol.a;
-
+ dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
+
final_color = dlit*lit*diffuse*shadow;
// unshadowed for consistency between forward and deferred?
@@ -244,7 +256,6 @@ void main()
final_color += amb_da*color.rgb*diffuse.rgb*amb_plcol.rgb*amb_plcol.a;
}
-
if (spec.a > 0.0)
{
dlit *= min(nl*6.0, 1.0) * dist_atten;
@@ -286,11 +297,25 @@ void main()
stc.x > 0.0 &&
stc.y > 0.0)
{
- final_color += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity;
+ final_color += color.rgb * texture2DLodSpecular(stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity;
}
}
}
+ #if DEBUG_SPOT_SPEC_POS
+ final_color = pos + ref * dot(pdelta, proj_n)/ds;
+ #endif
+ #if DEBUG_SPOT_REFLECTION
+ final_color = ref;
+ #endif
}
+
+#if DEBUG_SPOT_NL
+ final_color =vec3(nl);
+#endif
+#if DEBUG_SPOT_DIFFUSE
+ final_color = vec3(nl * dist_atten * noise);
+#endif
+
}
//not sure why, but this line prevents MATBUG-194
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 8886abb7d1..defd577266 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -27,6 +27,8 @@
/*[EXTRA_CODE_HERE]*/
+#define DEBUG_PBR_LIGHT_TYPE 0
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -86,6 +88,9 @@ void main()
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
+ float dist = lightDist / size;
+ float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff);
+
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
vec3 colorDiffuse = vec3(0);
@@ -99,11 +104,15 @@ void main()
if (nl > 0.0 || nv > 0.0)
{
- vec3 intensity = getLightIntensityPoint(color, size, lightDist);
+ vec3 intensity = dist_atten * getLightIntensityPoint(color, size, lightDist);
colorDiffuse += intensity * nl * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
colorSpec += intensity * nl * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
}
+#if DEBUG_PBR_LIGHT_TYPE
+ colorDiffuse = vec3(0,0,0.5); colorSpec = vec3(0);
+#endif
+
final_color = colorDiffuse + colorSpec;
}
else
@@ -120,8 +129,6 @@ void main()
discard;
}
- float fa = falloff+1.0;
- float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
dist_atten *= dist_atten;
dist_atten *= 2.0;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 59076d9760..83fc144434 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -27,6 +27,7 @@
#define PBR_USE_GGX_EMS_HACK 0
#define PBR_USE_IRRADIANCE_HACK 1
+#define DEBUG_PBR_LIGHT_TYPE 0 // Output no global light to make it easier to see pointLight and spotLight
#define DEBUG_PBR_PACKORM0 0 // Rough=0, Metal=0
#define DEBUG_PBR_PACKORM1 0 // Rough=1, Metal=1
#define DEBUG_PBR_TANGENT1 1 // Tangent = 1,0,0
@@ -178,8 +179,7 @@ void main()
da = pow(da, light_gamma);
vec4 diffuse = texture2DRect(diffuseRect, tc);
- vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
-
+ vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); // NOTE: PBR sRGB Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
@@ -478,6 +478,9 @@ void main()
#if DEBUG_PBR_SUN_CONTRIB
color.rgb = sun_contrib;
#endif
+ #if DEBUG_PBR_LIGHT_TYPE
+ color.rgb = vec3(0);
+ #endif
frag_color.rgb = color.rgb; // PBR is done in linear
}
else
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index 680fcbfab3..a82581d1a1 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -28,6 +28,12 @@
/*[EXTRA_CODE_HERE]*/
+#define DEBUG_PBR_LIGHT_TYPE 0
+#define DEBUG_PBR_SPOT 0
+#define DEBUG_PBR_NL 0 // monochome area effected by light
+#define DEBUG_PBR_SPOT_DIFFUSE 0
+#define DEBUG_PBR_SPOT_SPECULAR 0
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -42,7 +48,7 @@ uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, M
uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D noiseMap;
-uniform sampler2D projectionMap;
+uniform sampler2D projectionMap; // rgba
uniform sampler2D lightFunc;
uniform mat4 proj_mat; //screen space to light space
@@ -75,40 +81,15 @@ uniform mat4 inv_proj;
vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh );
vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh );
void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);
+bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc );
vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
+vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv );
+vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n);
vec2 getScreenXY(vec4 clip_point);
void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 c);
-
-vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
-{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
- ret.rgb = srgb_to_linear(ret.rgb);
-
- vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
- float det = min(lod/(proj_lod*0.5), 1.0);
- float d = min(dist.x, dist.y);
- d *= min(1, d * (proj_lod - lod));
- float edge = 0.25*det;
- ret *= clamp(d/edge, 0.0, 1.0);
-
- return ret;
-}
-
-vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
-{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
- ret.rgb = srgb_to_linear(ret.rgb);
-
- vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
- float det = min(lod/(proj_lod*0.5), 1.0);
- float d = min(dist.x, dist.y);
- float edge = 0.25*det;
- ret *= clamp(d/edge, 0.0, 1.0);
-
- return ret;
-}
+vec4 texture2DLodSpecular(vec2 tc, float lod);
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
@@ -133,13 +114,13 @@ void main()
vec2 tc = getScreenXY(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
- vec3 lv = trans_center.xyz-pos.xyz;
- float dist = length(lv);
- if (dist >= size)
+ vec3 lv;
+ vec4 proj_tc;
+ float dist, l_dist;
+ if (clipProjectedLightVars(trans_center, pos, dist, l_dist, lv, proj_tc))
{
discard;
}
- dist /= size;
float shadow = 1.0;
@@ -155,27 +136,9 @@ void main()
vec3 n;
vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG()
- float l_dist = -dot(lv, proj_n);
-
- vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
- if (proj_tc.z < 0.0)
- {
- discard;
- }
-
- proj_tc.xyz /= proj_tc.w;
-
- float fa = falloff+1.0;
- float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0);
- dist_atten *= dist_atten;
- dist_atten *= 2.0;
-
- if (dist_atten <= 0.0)
- {
- discard;
- }
+ float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff);
- lv = proj_origin-pos.xyz;
+ lv = proj_origin-pos.xyz; // NOTE: Re-using lv
vec3 h, l, v = -normalize(pos);
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
@@ -183,6 +146,7 @@ void main()
vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
vec4 spec = texture2DRect(specularRect, tc);
vec3 dlit = vec3(0, 0, 0);
+ vec3 slit = vec3(0, 0, 0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
@@ -190,11 +154,65 @@ void main()
vec3 colorSpec = vec3(0);
vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
vec3 packedORM = texture2DRect(emissiveRect, tc).rgb; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+ float metal = packedORM.b;
+
+// if (proj_tc.x > 0.0 && proj_tc.x < 1.0
+// && proj_tc.y > 0.0 && proj_tc.y < 1.0)
+ if (nl > 0.0)
+ {
+ vec3 c_diff, reflect0, reflect90;
+ float alphaRough, specWeight;
+ initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight );
+
+ dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
+ slit = getProjectedLightSpecularColor( pos, n );
+
+// vec3 intensity = getLightIntensitySpot( color, size, lightDist, v );
+// colorDiffuse = shadow * dlit * nl;
+// colorSpec = shadow * slit * nl;
+
+// colorDiffuse *= BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh );
+// colorSpec *= BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh );
+
+ colorDiffuse = shadow * dlit * nl * dist_atten;
+ colorSpec = shadow * slit * nl * dist_atten;
+
+ #if DEBUG_PBR_SPOT_DIFFUSE
+ colorDiffuse = dlit.rgb; colorSpec = vec3(0);
+ #endif
+ #if DEBUG_PBR_SPOT_SPECULAR
+ colorDiffuse = vec3(0); colorSpec = slit.rgb;
+ #endif
+ #if DEBUG_PBR_SPOT
+ colorDiffuse = dlit; colorSpec = vec3(0);
+ colorDiffuse *= nl;
+ colorDiffuse *= shadow;
+ #endif
+
+ }
+
+ #if DEBUG_SPOT_DIFFUSE
+ colorDiffuse = vec3(nl * dist_atten);
+ #endif
+ #if DEBUG_PBR_NL
+ colorDiffuse = vec3(nl); colorSpec = vec3(0);
+ #endif
+ #if DEBUG_PBR_LIGHT_TYPE
+ colorDiffuse = vec3(0.5,0,0); colorSpec = vec3(0.0);
+ #endif
final_color = colorDiffuse + colorSpec;
}
else
{
+ dist_atten *= dist_atten;
+ dist_atten *= 2.0;
+
+ if (dist_atten <= 0.0)
+ {
+ discard;
+ }
+
float noise = texture2D(noiseMap, tc/128.0).b;
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
@@ -209,12 +227,7 @@ void main()
{
lit = nl * dist_atten * noise;
- float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
- float lod = diff * proj_lod;
-
- vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
-
- dlit = color.rgb * plcol.rgb * plcol.a;
+ dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
final_color = dlit*lit*diffuse*shadow;
@@ -271,7 +284,7 @@ void main()
stc.x > 0.0 &&
stc.y > 0.0)
{
- final_color += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity;
+ final_color += color.rgb * texture2DLodSpecular(stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity;
}
}
}