summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2018-11-06 19:33:04 +0000
committerGraham Linden <graham@lindenlab.com>2018-11-06 19:33:04 +0000
commit2929998982f37221a58b9fa8037748a2e905f4b1 (patch)
tree24cc0c3da6655e9ed98908baa524e72068fbd64d
parent8c1aefc17c710b55ed7a72bd9de14cbed58ccd31 (diff)
Move to using a shared deferredUtil object for getting pos/norm from gbuffer.
Eliminate 20+ callsites with copy-paste of getPosition and/or getNorm code. Make pipeline use getShadowTarget/releaseShadowTarget consistently.
-rw-r--r--indra/llrender/llglslshader.cpp3
-rw-r--r--indra/llrender/llglslshader.h4
-rw-r--r--indra/llrender/llshadermgr.cpp14
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl24
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl21
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl21
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl32
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/srgb.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl92
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/transportF.glsl23
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl51
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl26
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl86
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/transportF.glsl26
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl77
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl136
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/skyF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/skyV.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl107
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl22
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl89
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/transportF.glsl8
-rw-r--r--indra/newview/lltoolgun.cpp2
-rw-r--r--indra/newview/llviewershadermgr.cpp154
-rw-r--r--indra/newview/llvowlsky.h6
-rw-r--r--indra/newview/pipeline.cpp201
-rw-r--r--indra/newview/pipeline.h4
46 files changed, 538 insertions, 922 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index de15d1d75b..585f8f6504 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -81,6 +81,9 @@ LLShaderFeatures::LLShaderFeatures()
, hasSrgb(false)
, encodesNormal(false)
, decodesNormal(false)
+ , isDeferred(false)
+ , hasIndirect(false)
+ , hasShadows(false)
, mIndexedTextureChannels(0)
, disableTextureIndex(false)
, hasAlphaMask(false)
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 0934ceba30..ed13106bfd 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -48,9 +48,12 @@ public:
bool hasObjectSkinning;
bool hasAtmospherics;
bool hasGamma;
+ bool hasShadows;
bool hasSrgb;
bool encodesNormal;
bool decodesNormal;
+ bool isDeferred;
+ bool hasIndirect;
S32 mIndexedTextureChannels;
bool disableTextureIndex;
bool hasAlphaMask;
@@ -227,5 +230,4 @@ extern LLGLSLShader gSolidColorProgram;
//Alpha mask shader (declared here so llappearance can access properly)
extern LLGLSLShader gAlphaMaskProgram;
-
#endif
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index d6fe35e2ca..55e4ecda2a 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -186,15 +186,23 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
}
}
- if (features->calculatesLighting || features->calculatesAtmospherics)
+ // NOTE order of shader object attaching is VERY IMPORTANT!!!
+ if (features->isDeferred || features->hasShadows)
{
- if (!shader->attachObject("windlight/atmosphericsHelpersF.glsl"))
+ if (!shader->attachObject("deferred/deferredUtil.glsl"))
+ {
+ return FALSE;
+ }
+ }
+
+ if (features->hasIndirect)
+ {
+ if (!shader->attachObject("deferred/indirect.glsl"))
{
return FALSE;
}
}
- // NOTE order of shader object attaching is VERY IMPORTANT!!!
if (features->hasGamma)
{
if (!shader->attachObject("windlight/gammaF.glsl"))
diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
index 767fad016c..c4caed4d71 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
@@ -38,12 +38,5 @@ mat4 getSkinnedTransform()
ret[1] = mix(matrixPalette[i+15],matrixPalette[i+16], x);
ret[2] = mix(matrixPalette[i+30],matrixPalette[i+31], x);
ret[3] = vec4(0,0,0,1);
-
return ret;
-
-#ifdef IS_AMD_CARD
- // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts.
- vec4 dummy1 = matrixPalette[0];
- vec4 dummy2 = matrixPalette[44];
-#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
index 90bf2851c9..94de2f7b53 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
@@ -61,12 +61,5 @@ mat4 getObjectSkinnedTransform()
ret[3] = vec4(trans, 1.0);
return ret;
-
-#ifdef IS_AMD_CARD
- // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts.
- mat3x4 dummy1 = matrixPalette[0];
- mat3x4 dummy2 = matrixPalette[MAX_JOINTS_PER_MESH_OBJECT-1];
-#endif
-
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 3ec2ea12da..a325faaad7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -89,9 +89,7 @@ vec2 encode_normal (vec3 n);
vec3 decode_normal (vec2 enc);
vec3 scaleSoftClipFrag(vec3 l);
-vec3 atmosFragAmbient(vec3 light, vec3 sunlit);
vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten);
-vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit);
void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
@@ -164,6 +162,8 @@ void main()
float shadow = 1.0;
+ vec3 norm = vary_norm;
+
#if HAS_SHADOW
vec4 spos = pos;
@@ -268,13 +268,10 @@ void main()
vec4 gamma_diff = diff;
diff.rgb = srgb_to_linear(diff.rgb);
- vec3 norm = vary_norm;
-
- vec3 sunlit;
- vec3 amblit;
- vec3 additive;
- vec3 atten;
-
+ vec3 sunlit;
+ vec3 amblit;
+ vec3 additive;
+ vec3 atten;
calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten);
vec2 abnormal = encode_normal(norm.xyz);
@@ -290,7 +287,7 @@ void main()
vec4 color = vec4(0,0,0,0);
- color.rgb = atmosFragAmbient(color.rgb, amblit);
+ color.rgb = (color.rgb * 0.5) + amblit;
color.a = final_alpha;
float ambient = abs(da);
@@ -299,7 +296,7 @@ void main()
ambient = (1.0-ambient);
color.rgb *= ambient;
- color.rgb += atmosFragAffectDirectionalLight(final_da, sunlit);
+ color.rgb += (final_da * sunlit);
color.rgb *= gamma_diff.rgb;
//color.rgb = mix(diff.rgb, color.rgb, final_alpha);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 506118d381..394ae80e53 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -73,7 +73,7 @@ void main()
vec3 norm;
//transform vertex
-#ifdef HAS_SKIN
+#if defined(HAS_SKIN)
mat4 trans = getObjectSkinnedTransform();
trans = modelview_matrix * trans;
@@ -83,9 +83,7 @@ void main()
norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz);
vec4 frag_pos = projection_matrix * pos;
gl_Position = frag_pos;
-#else
-
-#ifdef IS_AVATAR_SKIN
+#elif defined(IS_AVATAR_SKIN)
mat4 trans = getSkinnedTransform();
vec4 pos_in = vec4(position.xyz, 1.0);
pos.x = dot(trans[0], pos_in);
@@ -107,14 +105,11 @@ void main()
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
#endif
-#endif
-
#ifdef USE_INDEXED_TEX
passTextureIndex();
#endif
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
-
vary_norm = norm;
vary_position = pos.xyz;
@@ -122,18 +117,14 @@ void main()
vertex_color = diffuse_color;
#endif
-#ifdef HAS_SKIN
+#if defined(HAS_SKIN)
vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-#else
-
-#ifdef IS_AVATAR_SKIN
+#elif defined(IS_AVATAR_SKIN)
vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
#else
pos = modelview_projection_matrix * vert;
vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
#endif
-#endif
-
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index b56abb66d1..7c9382d474 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -33,7 +33,6 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
@@ -45,22 +44,7 @@ uniform float kern_scale;
VARYING vec2 vary_fragcoord;
-uniform mat4 inv_proj;
-uniform vec2 screen_res;
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
+vec4 getPosition(vec2 pos_screen);
vec3 decode_normal (vec2 enc);
void main()
@@ -119,11 +103,5 @@ void main()
col.y *= col.y;
frag_color = col;
-
-#ifdef IS_AMD_CARD
- // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts.
- vec3 dummy1 = kern[0];
- vec3 dummy2 = kern[3];
-#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index 6ba16b169c..def149d86d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -32,11 +32,9 @@ out vec4 frag_data[3];
#endif
uniform float minimum_alpha;
-
-
uniform sampler2D diffuseMap;
-uniform sampler2D normalMap;
uniform sampler2D specularMap;
+uniform sampler2D normalMap;
VARYING vec2 vary_texcoord0;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index c1c17532b8..1e566b77bf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -40,7 +40,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
-vec3 atmosFragAmbient(vec3 l, vec3 ambient);
vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
vec3 scaleSoftClipFrag(vec3 l);
@@ -176,19 +175,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
}
-vec4 getPosition_d(vec2 pos_screen, float depth)
-{
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-
#else
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_data[3];
@@ -233,6 +219,8 @@ vec3 decode_normal (vec2 enc);
void main()
{
+ vec2 pos_screen = vary_texcoord0.xy;
+
vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy);
diffcol.rgb *= vertex_color.rgb;
@@ -390,7 +378,7 @@ void main()
final_da = min(final_da, 1.0f);
final_da = pow(final_da, 1.0/1.3);
- col.rgb = atmosFragAmbient(col, amblit);
+ col.rgb = (col * 0.5) + amblit;
float ambient = min(abs(da), 1.0);
ambient *= 0.5;
@@ -444,9 +432,6 @@ void main()
glare += cur_glare;
}
- //col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a);
- //col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a);
-
col = atmosFragLighting(col, additive, atten);
col = scaleSoftClipFrag(col);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index d1ac19270d..eb65c28645 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -59,18 +59,7 @@ uniform mat4 inv_proj;
vec3 decode_normal (vec2 enc);
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
@@ -148,12 +137,4 @@ void main()
frag_color.rgb = out_col;
frag_color.a = 0.0;
-
-#ifdef IS_AMD_CARD
- // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts.
- vec4 dummy1 = light[0];
- vec4 dummy2 = light_col[0];
- vec4 dummy3 = light[LIGHT_COUNT-1];
- vec4 dummy4 = light_col[LIGHT_COUNT-1];
-#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 1d75322b4c..3aa7a3a449 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -128,19 +128,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
return ret;
}
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 13b803e03e..df48a66fab 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -57,19 +57,7 @@ uniform mat4 inv_proj;
uniform vec4 viewport;
vec3 decode_normal (vec2 enc);
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = (pos_screen.xy-viewport.xy)*2.0;
- sc /= viewport.zw;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
index a5625fbc16..3da8531442 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
@@ -1,5 +1,5 @@
/**
- * @file pointLightF.glsl
+ * @file pointLightV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index e33254304b..c2963046c5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -49,18 +49,7 @@ VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
@@ -101,10 +90,4 @@ void main()
col = col*col*blur_quad.x + col*blur_quad.y + blur_quad.z;
frag_color.rgb = col;
-
-#ifdef IS_AMD_CARD
- // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts.
- vec2 dummy1 = kern[0];
- vec2 dummy2 = kern[31];
-#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 5627275df6..cac3e75f1f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -69,33 +69,17 @@ vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
vec3 decode_normal (vec2 enc);
+vec3 scaleSoftClipFrag(vec3 l);
vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
-vec4 getPosition_d(vec2 pos_screen, float depth)
-{
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
- return getPosition_d(pos_screen, depth);
-}
-
+vec4 getPositionWithDepth(vec2 pos_screen, float depth);
void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).r;
- vec3 pos = getPosition_d(tc, depth).xyz;
+ vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = texture2DRect(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = decode_normal(norm.xy); // unpack norm
@@ -156,27 +140,25 @@ void main()
if (envIntensity > 0.0)
{ //add environmentmap
vec3 env_vec = env_mat * refnormpersp;
-
-
vec3 refcol = textureCube(environmentMap, env_vec).rgb;
-
- col = mix(col.rgb, refcol,
- envIntensity);
+ col = mix(col.rgb, refcol, envIntensity);
}
if (norm.w < 0.5)
{
col = atmosFragLighting(col, additive, atten);
+ col = scaleSoftClipFrag(col);
}
#ifdef WATER_FOG
- vec4 fogged = applyWaterFogView(pos,vec4(col, bloom));
+ vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom));
col = fogged.rgb;
bloom = fogged.a;
#endif
col = srgb_to_linear(col);
+ //col = vec3(1,0,1);
//col.g = envIntensity;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
index b59fcbe017..5655c6f99f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
@@ -30,6 +30,7 @@ ATTRIBUTE vec3 position;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
+
void main()
{
//transform vertex
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 2b6428963d..022bcbabca 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -132,18 +132,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
}
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl
index 00ba0e8fad..bc3324f543 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl
@@ -48,7 +48,6 @@ vec3 srgb_to_linear(vec3 cs)
bvec3 lte = lessThanEqual(cs,vec3(0.04045));
return mix(high_range, low_range, lte);
-
}
vec3 linear_to_srgb(vec3 cl)
@@ -59,6 +58,4 @@ vec3 linear_to_srgb(vec3 cl)
bvec3 lt = lessThan(cl,vec3(0.0031308));
return mix(high_range, low_range, lt);
-
}
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 403df87853..006a49d9a0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -35,102 +35,26 @@ out vec4 frag_color;
//class 1 -- no shadow, SSAO only
-uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
-uniform sampler2D noiseMap;
-
// Inputs
-uniform float ssao_radius;
-uniform float ssao_max_radius;
-uniform float ssao_factor;
-uniform float ssao_factor_inv;
-
VARYING vec2 vary_fragcoord;
-uniform mat4 inv_proj;
-uniform vec2 screen_res;
-
vec3 decode_normal (vec2 enc);
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec3 getNorm(vec2 pos_screen);
+vec4 getPosition(vec2 pos_screen);
//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
- float ret = 1.0;
-
- vec2 kern[8];
- // exponentially (^2) distant occlusion samples spread around origin
- kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
- kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
- kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
- kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
- kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
- kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
- kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
- kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
- vec2 pos_screen = vary_fragcoord.xy;
- vec3 pos_world = pos.xyz;
- vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-
- float angle_hidden = 0.0;
- int points = 0;
-
- float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-
- // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations unrolling?)
- for (int i = 0; i < 8; i++)
- {
- vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
- vec3 samppos_world = getPosition(samppos_screen).xyz;
-
- vec3 diff = pos_world - samppos_world;
- float dist2 = dot(diff, diff);
-
- // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
- // --> solid angle shrinking by the square of distance
- //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
- //(k should vary inversely with # of samples, but this is taken care of later)
-
- angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
-
- // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion"
- points = points + int(diff.z > -1.0);
- }
-
- angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-
- ret = (1.0 - (float(points != 0) * angle_hidden));
-
- return min(ret, 1.0);
-}
+float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen);
void main()
{
- vec2 pos_screen = vary_fragcoord.xy;
-
- //try doing an unproject here
-
- vec4 pos = getPosition(pos_screen);
-
- vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
- norm = decode_normal(norm.xy);
-
+ vec2 pos_screen = vary_fragcoord.xy;
+ vec4 pos = getPosition(pos_screen);
+ vec3 norm = getNorm(pos_screen);
+
frag_color[0] = 1.0;
- frag_color[1] = calcAmbientOcclusion(pos, norm);
+ frag_color[1] = calcAmbientOcclusion(pos, norm, pos_screen);
frag_color[2] = 1.0;
frag_color[3] = 1.0;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 73f6d9fec3..69543b93ea 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -41,15 +41,6 @@ uniform sampler2D bumpMap2;
uniform float blend_factor;
uniform sampler2D screenTex;
uniform sampler2D refTex;
-uniform sampler2DRectShadow shadowMap0;
-uniform sampler2DRectShadow shadowMap1;
-uniform sampler2DRectShadow shadowMap2;
-uniform sampler2DRectShadow shadowMap3;
-uniform sampler2D noiseMap;
-
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-
uniform float sunAngle;
uniform float sunAngle2;
uniform vec3 lightDir;
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl
index c1cc3679a7..2b8cf9d8df 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl
@@ -23,21 +23,10 @@
* $/LicenseInfo$
*/
-vec3 atmosFragAmbient(vec3 light, vec3 sunlit)
-{
- /* stub function for fallback compatibility on class1 hardware */
- return light;
-}
-
vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten)
{
- /* stub function for fallback compatibility on class1 hardware */
- return light;
-}
-
-vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit)
-{
- return light * sunlit;
+ /* stub function for fallback compatibility on class1 hardware */
+ return light;
}
vec3 atmosLighting(vec3 light)
diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl
index ebce9ea91d..e2b391cb7a 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl
@@ -1,5 +1,5 @@
/**
- * @file transportF.glsl
+ * @file class1/windlight/transportF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -25,6 +25,24 @@
uniform int no_atmo;
+vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
+ /* stub function for fallback compatibility on class1 hardware */
+ return light;
+}
+
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
+ /* stub function for fallback compatibility on class1 hardware */
+ return light;
+}
+
+vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 atten, vec3 additive)
+{
+ /* stub function for fallback compatibility on class1 hardware */
+ return light;
+}
+
vec3 atmosTransport(vec3 light)
{
/* stub function for fallback compatibility on class1 hardware */
@@ -33,11 +51,12 @@ vec3 atmosTransport(vec3 light)
vec3 fullbrightAtmosTransport(vec3 light)
{
+ /* stub function for fallback compatibility on class1 hardware */
return light;
}
vec3 fullbrightShinyAtmosTransport(vec3 light)
{
+ /* stub function for fallback compatibility on class1 hardware */
return light;
}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 864ba4859d..0848adba73 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -133,18 +133,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
}
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index c92dbda185..33f3eb46c0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -83,51 +83,12 @@ vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
vec3 fullbrightScaleSoftClipFrag(vec3 l);
vec3 scaleSoftClipFrag(vec3 l);
-vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
-{
- if (no_atmo == 1)
- {
- return light;
- }
- return (light + additive) * atten.r * 2.0;
-}
-
-vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) {
- if (no_atmo == 1)
- {
- return light;
- }
- float brightness = dot(light.rgb, vec3(0.33333));
- return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive.rgb, brightness * brightness);
-}
-
-vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) {
- if (no_atmo == 1)
- {
- return light;
- }
- float brightness = dot(light.rgb, vec3(0.33333));
- return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
-}
-
-vec4 getPosition_d(vec2 pos_screen, float depth)
-{
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- return getPosition_d(pos_screen, depth);
-}
+vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten);
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten);
+vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten);
+vec4 getPositionWithDepth(vec2 pos_screen, float depth);
+vec4 getPosition(vec2 pos_screen);
#ifdef WATER_FOG
vec4 applyWaterFogView(vec3 pos, vec4 color);
@@ -137,7 +98,7 @@ void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).r;
- vec3 pos = getPosition_d(tc, depth).xyz;
+ vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = texture2DRect(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = decode_normal(norm.xy); // unpack norm
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
index c840d72784..8b8b338f68 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
@@ -36,7 +36,5 @@ void main()
//transform vertex
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
-
-
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index a7da140b31..80e2a9dd55 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -133,18 +133,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
}
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index aa5e99a2f7..c4018ca61a 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -67,20 +67,9 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
+vec3 getNorm(vec2 pos_screen);
vec3 decode_normal (vec2 enc);
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen)
{
@@ -123,14 +112,9 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
void main()
{
- vec2 pos_screen = vary_fragcoord.xy;
-
- //try doing an unproject here
-
- vec4 pos = getPosition(pos_screen);
-
- vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
- norm = decode_normal(norm.xy); // unpack norm
+ vec2 pos_screen = vary_fragcoord.xy;
+ vec4 pos = getPosition(pos_screen);
+ vec3 norm = getNorm(pos_screen);
/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 58f3f2f91e..bd468306ee 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -70,79 +70,10 @@ uniform float spot_shadow_offset;
vec3 decode_normal (vec2 enc);
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-vec2 getKern(int i)
-{
- vec2 kern[8];
- // exponentially (^2) distant occlusion samples spread around origin
- kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
- kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
- kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
- kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
- kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
- kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
- kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
- kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
- return kern[i];
-}
-
-//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
- float ret = 1.0;
-
- vec2 pos_screen = vary_fragcoord.xy;
- vec3 pos_world = pos.xyz;
- vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-
- float angle_hidden = 0.0;
- float points = 0;
-
- float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-
- // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
- for (int i = 0; i < 8; i++)
- {
- vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect);
- vec3 samppos_world = getPosition(samppos_screen).xyz;
-
- vec3 diff = pos_world - samppos_world;
- float dist2 = dot(diff, diff);
-
- // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
- // --> solid angle shrinking by the square of distance
- //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
- //(k should vary inversely with # of samples, but this is taken care of later)
-
- float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0;
- angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv);
-
- // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion"
- float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0;
- points = points + diffz_val;
- }
-
- angle_hidden = min(ssao_factor*angle_hidden/points, 1.0);
-
- float points_val = (points > 0.0) ? 1.0 : 0.0;
- ret = (1.0 - (points_val * angle_hidden));
+vec4 getPosition(vec2 pos_screen);
+vec3 getNorm(vec2 pos_screen);
- ret = max(ret, 0.0);
- return min(ret, 1.0);
-}
+float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen);
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen)
{
@@ -185,13 +116,8 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
void main()
{
vec2 pos_screen = vary_fragcoord.xy;
-
- //try doing an unproject here
-
- vec4 pos = getPosition(pos_screen);
-
- vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
- norm = decode_normal(norm.xy); // unpack norm
+ vec4 pos = getPosition(pos_screen);
+ vec3 norm = getNorm(pos_screen);
/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
{
@@ -291,7 +217,7 @@ void main()
}
frag_color[0] = shadow;
- frag_color[1] = calcAmbientOcclusion(pos, norm);
+ frag_color[1] = calcAmbientOcclusion(pos, norm, pos_screen);
spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
index bf64605014..75d1bb0cd5 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
@@ -32,7 +32,7 @@ vec3 getAtmosAttenuation();
uniform int no_atmo;
-vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive)
+vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
{
if (no_atmo == 1)
{
@@ -41,32 +41,36 @@ vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive)
return (light + additive) * atten * 2.0;
}
-vec3 fullbrightFragAtmosTransport(vec3 light, vec3 atten, vec3 additive) {
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
if (no_atmo == 1)
{
return light;
}
float brightness = dot(light.rgb, vec3(0.33333));
- return mix(atmosFragTransport(light.rgb, atten, additive), light.rgb + additive.rgb, brightness * brightness);
+ return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive.rgb, brightness * brightness);
}
-vec3 fullbrightFragShinyAtmosTransport(vec3 light, vec3 atten, vec3 additive) {
+vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 atten, vec3 additive) {
if (no_atmo == 1)
{
return light;
}
float brightness = dot(light.rgb, vec3(0.33333));
- return mix(atmosFragTransport(light.rgb, atten, additive), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
+ return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
}
-vec3 atmosTransport(vec3 light) {
- return (no_atmo == 1) ? light : atmosFragTransport(light, getAtmosAttenuation(), getAdditiveColor());
+vec3 atmosTransport(vec3 light)
+{
+ return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
}
-vec3 fullbrightAtmosTransport(vec3 light) {
- return (no_atmo == 1) ? light : fullbrightFragAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor());
+vec3 fullbrightAtmosTransport(vec3 light)
+{
+ return fullbrightAtmosTransportFrag(light,getAdditiveColor(), getAtmosAttenuation());
}
-vec3 fullbrightShinyAtmosTransport(vec3 light) {
- return (no_atmo == 1) ? light : fullbrightFragShinyAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor());
+vec3 fullbrightShinyAtmosTransport(vec3 light)
+{
+ return fullbrightShinyAtmosTransportFrag(light,getAdditiveColor(), getAtmosAttenuation());
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl
index 9f06319da3..f8373215f0 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl
@@ -1,5 +1,5 @@
/**
- * @file WLCloudsF.glsl
+ * @file class3/deferred/cloudsF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -24,9 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
+out vec4 frag_data[3];
#else
-#define frag_color gl_FragColor
+#define frag_data gl_FragData
#endif
/////////////////////////////////////////////////////////////////////////
@@ -36,20 +36,37 @@ out vec4 frag_color;
VARYING vec4 vary_CloudColorSun;
VARYING vec4 vary_CloudColorAmbient;
VARYING float vary_CloudDensity;
+VARYING vec2 vary_texcoord0;
+VARYING vec2 vary_texcoord1;
+VARYING vec2 vary_texcoord2;
+VARYING vec2 vary_texcoord3;
+VARYING vec3 vary_pos;
uniform sampler2D cloud_noise_texture;
uniform sampler2D cloud_noise_texture_next;
uniform float blend_factor;
uniform vec4 cloud_pos_density1;
uniform vec4 cloud_pos_density2;
-uniform vec4 gamma;
+uniform vec4 sunlight_color;
+uniform vec4 cloud_color;
+uniform float cloud_shadow;
uniform float cloud_scale;
uniform float cloud_variance;
-
-VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
-VARYING vec2 vary_texcoord2;
-VARYING vec2 vary_texcoord3;
+uniform vec3 ambient;
+uniform vec3 camPosLocal;
+uniform vec3 sun_dir;
+uniform float sun_size;
+uniform float far_z;
+
+uniform sampler2D transmittance_texture;
+uniform sampler3D scattering_texture;
+uniform sampler3D single_mie_scattering_texture;
+uniform sampler2D irradiance_texture;
+uniform sampler2D sh_input_r;
+uniform sampler2D sh_input_g;
+uniform sampler2D sh_input_b;
+
+vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance);
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light);
@@ -67,11 +84,9 @@ void main()
// Set variables
vec2 uv1 = vary_texcoord0.xy;
vec2 uv2 = vary_texcoord1.xy;
-
- vec4 cloudColorSun = vary_CloudColorSun;
- vec4 cloudColorAmbient = vary_CloudColorAmbient;
- float cloudDensity = vary_CloudDensity;
vec2 uv3 = vary_texcoord2.xy;
+ float cloudDensity = 2.0 * (cloud_shadow - 0.25);
+
vec2 uv4 = vary_texcoord3.xy;
vec2 disturbance = vec2(cloudNoise(uv1 / 16.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f);
@@ -82,33 +97,53 @@ void main()
uv3 += cloud_pos_density2.xy + disturbance; //small texture, visible density
uv4 += cloud_pos_density2.xy; //small texture, self shadow
+ float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0));
- // Compute alpha1, the main cloud opacity
+ cloudDensity *= 1.0 - (density_variance * density_variance);
+ // Compute alpha1, the main cloud opacity
float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z;
- alpha1 = min(max(alpha1 + cloudDensity, 0.) * (10. + disturbance.y) * cloud_pos_density1.z, 1.);
+ alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.);
// And smooth
alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1;
+ if (alpha1 < 0.001f)
+ {
+ discard;
+ }
// Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight
float alpha2 = (cloudNoise(uv2).x - 0.5);
- alpha2 = min(max(alpha2 + cloudDensity, 0.) * (2.5 + disturbance.x) * cloud_pos_density1.z, 1.);
+ alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
// And smooth
alpha2 = 1. - alpha2;
alpha2 = 1. - alpha2 * alpha2;
+ vec3 view_ray = vary_pos.xyz + camPosLocal;
+
+ vec3 view_direction = normalize(view_ray);
+ vec3 sun_direction = normalize(sun_dir);
+ vec3 earth_center = vec3(0, 0, -6360.0f);
+ vec3 camPos = (camPosLocal / 1000.0f) - earth_center;
+
+ vec3 transmittance;
+ vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 1.0 - alpha1, sun_direction, transmittance);
+
+ vec3 sun_color = vec3(1.0) - exp(-radiance_sun * 0.0001);
+
// Combine
vec4 color;
- color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
- color *= 2.;
- /// Gamma correct for WL (soft clip effect).
- frag_color.rgb = scaleSoftClip(color.rgb);
- frag_color.a = alpha1;
+ color.rgb = sun_color * cloud_color.rgb * (1. - alpha2);
+ color.rgb = pow(color.rgb, vec3(1.0 / 2.2));
+ color.rgb += ambient;
+
+ frag_data[0] = vec4(color.rgb, alpha1);
+ frag_data[1] = vec4(0);
+ frag_data[2] = vec4(0,1,0,1);
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl
index c1dd45cd67..53b6d88ef5 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl
@@ -24,6 +24,7 @@
*/
uniform mat4 modelview_projection_matrix;
+uniform mat4 modelview_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
@@ -33,158 +34,37 @@ ATTRIBUTE vec2 texcoord0;
///////////////////////////////////////////////////////////////////////////////
// Output parameters
-VARYING vec4 vary_CloudColorSun;
-VARYING vec4 vary_CloudColorAmbient;
-VARYING float vary_CloudDensity;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
+VARYING vec3 vary_pos;
// Inputs
-uniform vec3 camPosLocal;
-
-uniform vec4 lightnorm;
-uniform vec4 sunlight_color;
-uniform vec4 ambient;
-uniform vec4 blue_horizon;
-uniform vec4 blue_density;
-uniform float haze_horizon;
-uniform float haze_density;
-
-uniform float cloud_shadow;
-uniform float density_multiplier;
-uniform float max_y;
-
-uniform vec4 glow;
-
-uniform vec4 cloud_color;
-
uniform float cloud_scale;
+uniform vec4 lightnorm;
+uniform vec3 camPosLocal;
void main()
{
+ vary_pos = position;
// World / view / projection
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
- vary_texcoord0 = texcoord0;
-
- // Get relative position
- vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
-
- // Set altitude
- if (P.y > 0.)
- {
- P *= (max_y / P.y);
- }
- else
- {
- P *= (-32000. / P.y);
- }
-
- // Can normalize then
- vec3 Pn = normalize(P);
- float Plen = length(P);
-
- // Initialize temp variables
- vec4 temp1 = vec4(0.);
- vec4 temp2 = vec4(0.);
- vec4 blue_weight;
- vec4 haze_weight;
- vec4 sunlight = sunlight_color;
- vec4 light_atten;
-
-
- // Sunlight attenuation effect (hue and brightness) due to atmosphere
- // this is used later for sunlight modulation at various altitudes
- light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y);
-
- // Calculate relative weights
- temp1 = blue_density + haze_density;
- blue_weight = blue_density / temp1;
- haze_weight = haze_density / temp1;
-
- // Compute sunlight from P & lightnorm (for long rays like sky)
- temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
- temp2.y = 1. / temp2.y;
- sunlight *= exp( - light_atten * temp2.y);
-
- // Distance
- temp2.z = Plen * density_multiplier;
-
- // Transparency (-> temp1)
- // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
- // compiler gets confused.
- temp1 = exp(-temp1 * temp2.z);
-
-
- // Compute haze glow
- temp2.x = dot(Pn, lightnorm.xyz);
- temp2.x = 1. - temp2.x;
- // temp2.x is 0 at the sun and increases away from sun
- temp2.x = max(temp2.x, .001);
- // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
- temp2.x *= glow.x;
- // Higher glow.x gives dimmer glow (because next step is 1 / "angle")
- temp2.x = pow(temp2.x, glow.z);
- // glow.z should be negative, so we're doing a sort of (1 / "angle") function
-
- // Add "minimum anti-solar illumination"
- temp2.x += .25;
-
- // Increase ambient when there are more clouds
- vec4 tmpAmbient = ambient;
- tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5;
-
- // Dim sunlight by cloud shadow percentage
- sunlight *= (1. - cloud_shadow);
-
- // Haze color below cloud
- vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
- + (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient)
- );
-
- // CLOUDS
-
- sunlight = sunlight_color;
- temp2.y = max(0., lightnorm.y * 2.);
- temp2.y = 1. / temp2.y;
- sunlight *= exp( - light_atten * temp2.y);
-
- // Cloud color out
- vary_CloudColorSun = (sunlight * temp2.x) * cloud_color;
- vary_CloudColorAmbient = tmpAmbient * cloud_color;
-
- // Attenuate cloud color by atmosphere
- temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
- vary_CloudColorSun *= temp1;
- vary_CloudColorAmbient *= temp1;
- vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1);
-
- // Make a nice cloud density based on the cloud_shadow value that was passed in.
- vary_CloudDensity = 2. * (cloud_shadow - 0.25);
-
-
// Texture coords
vary_texcoord0 = texcoord0;
vary_texcoord0.xy -= 0.5;
- vary_texcoord0.xy /= cloud_scale;
- vary_texcoord0.xy += 0.5;
+ vary_texcoord0.xy /= cloud_scale;
+ vary_texcoord0.xy += 0.5;
vary_texcoord1 = vary_texcoord0;
vary_texcoord1.x += lightnorm.x * 0.0125;
- vary_texcoord1.y += lightnorm.z * 0.0125;
+ vary_texcoord1.y += lightnorm.z * 0.0125;
vary_texcoord2 = vary_texcoord0 * 16.;
vary_texcoord3 = vary_texcoord1 * 16.;
- // Combine these to minimize register use
- vary_CloudColorAmbient += oHazeColorBelowCloud;
-
- // needs this to compile on mac
- //vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
-
// END CLOUDS
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index 864ba4859d..0848adba73 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -133,18 +133,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
}
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl
index 2073fc066f..d0514f7d23 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl
@@ -1,5 +1,5 @@
/**
- * @file class3/skyF.glsl
+ * @file class3/deferred/skyF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -44,6 +44,7 @@ uniform sampler3D single_mie_scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler2D rainbow_map;
uniform sampler2D halo_map;
+uniform vec4 gamma;
uniform float moisture_level;
uniform float droplet_radius;
@@ -53,6 +54,7 @@ vec3 GetSolarLuminance();
vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance);
vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir, out vec3 transmittance);
+vec3 ColorFromRadiance(vec3 radiance);
vec3 rainbow(float d)
{
float rad = (droplet_radius - 5.0f) / 1024.0f;
@@ -93,18 +95,15 @@ void main()
}
s = smoothstep(0.9, 1.0, s) * 16.0f;
- vec3 color = vec3(1.0) - exp(-radiance_sun * 0.0001);
+ vec3 color = ColorFromRadiance(radiance_sun);
float optic_d = dot(view_direction, sun_direction);
-
vec3 halo_22 = halo22(optic_d);
- if (optic_d <= 0)
- color.rgb += rainbow(optic_d);
-
+ color.rgb += rainbow(optic_d) * optic_d;
color.rgb += halo_22;
- color = pow(color, vec3(1.0 / 2.2));
+ color = pow(color, vec3(1.0/2.2));
frag_data[0] = vec4(color, 1.0 + s);
frag_data[1] = vec4(0.0);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl
index a5cc49ca30..2eb222ada4 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl
@@ -1,5 +1,5 @@
/**
- * @file advancedAtmoV.glsl
+ * @file class3/deferred/skyV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -23,12 +23,6 @@
* $/LicenseInfo$
*/
-uniform vec3 cameraPosLocal;
-uniform mat4 modelview_projection_matrix;
-uniform mat4 modelview_matrix;
-uniform mat4 inv_proj;
-uniform mat4 inv_modelview;
-
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 2615400e52..ecf6858136 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -38,30 +38,21 @@ uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
uniform sampler2DRect depthMap;
-uniform samplerCube environmentMap;
-uniform sampler2D lightFunc;
+uniform sampler2D lightFunc;
uniform float blur_size;
+uniform samplerCube environmentMap;
+
uniform float blur_fidelity;
// Inputs
uniform vec4 morphFactor;
uniform vec3 camPosLocal;
-//uniform vec4 camPosWorld;
uniform vec4 gamma;
-uniform vec4 sunlight_color;
-uniform vec4 ambient;
-uniform vec4 blue_horizon;
-uniform vec4 blue_density;
-uniform float haze_horizon;
-uniform float haze_density;
uniform float cloud_shadow;
-uniform float density_multiplier;
-uniform float distance_multiplier;
uniform float max_y;
uniform vec4 glow;
uniform float global_gamma;
-uniform float scene_light_strength;
uniform mat3 env_mat;
uniform vec4 shadow_clip;
uniform mat3 ssao_effect_mat;
@@ -74,28 +65,29 @@ uniform mat4 inv_modelview;
uniform vec2 screen_res;
+uniform sampler2D transmittance_texture;
+uniform sampler3D scattering_texture;
+uniform sampler3D single_mie_scattering_texture;
+uniform sampler2D irradiance_texture;
+
+uniform sampler2D sh_input_r;
+uniform sampler2D sh_input_g;
+uniform sampler2D sh_input_b;
+
+vec3 GetSunAndSkyIrradiance(vec3 camPos, vec3 norm, vec3 dir, out vec3 sky_irradiance);
+vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance);
+vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir, out vec3 transmittance);
+
+vec3 scaleSoftClipFrag(vec3 c);
+vec3 fullbrightScaleSoftClipFrag(vec3 c);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
vec3 decode_normal (vec2 enc);
-vec4 getPosition_d(vec2 pos_screen, float depth)
-{
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- return getPosition_d(pos_screen, depth);
-}
-
+vec3 ColorFromRadiance(vec3 radiance);
+vec4 getPositionWithDepth(vec2 pos_screen, float depth);
+vec4 getPosition(vec2 pos_screen);
+vec3 getNorm(vec2 pos_screen);
#ifdef WATER_FOG
vec4 applyWaterFogView(vec3 pos, vec4 color);
@@ -105,24 +97,22 @@ void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).r;
- vec3 pos = getPosition_d(tc, depth).xyz;
+ vec3 pos = getPositionWithDepth(tc, depth).xyz;
vec4 norm = texture2DRect(normalMap, tc);
float envIntensity = norm.z;
- norm.xyz = decode_normal(norm.xy); // unpack norm
-
+ norm.xyz = decode_normal(norm.xy);
+
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
float light_gamma = 1.0/1.3;
- da = pow(da, light_gamma);
- vec4 diffuse = texture2DRect(diffuseRect, tc);
+ vec4 diffuse = texture2DRect(diffuseRect, tc); // linear
- //convert to gamma space
- diffuse.rgb = linear_to_srgb(diffuse.rgb);
-
vec3 col;
float bloom = 0.0;
{
+ vec3 camPos = (camPosLocal / 1000.0f) + vec3(0, 0, 6360.0f);
+
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
@@ -132,17 +122,37 @@ void main()
float ambocc = scol_ambocc.g;
- col *= diffuse.rgb;
-
+ vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265));
+ vec4 l1r = texture2D(sh_input_r, vec2(0,0));
+ vec4 l1g = texture2D(sh_input_g, vec2(0,0));
+ vec4 l1b = texture2D(sh_input_b, vec2(0,0));
+
+ vec3 indirect = vec3(dot(l1r, l1tap * vec4(1, norm.xyz)),
+ dot(l1g, l1tap * vec4(1, norm.xyz)),
+ dot(l1b, l1tap * vec4(1, norm.xyz)));
+
+ indirect = clamp(indirect, vec3(0), vec3(1.0));
+
+ vec3 transmittance;
+ vec3 sky_irradiance;
+ vec3 sun_irradiance = GetSunAndSkyIrradiance(camPos, norm.xyz, sun_dir, sky_irradiance);
+ vec3 inscatter = GetSkyLuminanceToPoint(camPos, (pos / 1000.f) + vec3(0, 0, 6360.0f), scol, sun_dir, transmittance);
+
+ vec3 radiance = scol * (sun_irradiance + sky_irradiance) + inscatter;
+ vec3 atmo_color = ColorFromRadiance(radiance);
+
+ col = atmo_color + indirect;
+ col *= transmittance;
+ col *= diffuse.rgb;
+
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
-
float sa = dot(refnormpersp, sun_dir.xyz);
- vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r);
+ vec3 dumbshiny = scol * texture2D(lightFunc, vec2(sa, spec.a)).r * atmo_color;
// add the two types of shiny together
vec3 spec_contrib = dumbshiny * spec.rgb;
@@ -155,17 +165,24 @@ void main()
if (envIntensity > 0.0)
{ //add environmentmap
vec3 env_vec = env_mat * refnormpersp;
- vec3 refcol = textureCube(environmentMap, env_vec).rgb;
- col = mix(col.rgb, refcol, envintensity);
+ vec3 sun_direction = (inv_modelview * vec4(sun_dir, 1.0)).xyz;
+ vec3 radiance_sun = GetSkyLuminance(camPos, env_vec, 0.0f, sun_direction, transmittance);
+ vec3 refcol = ColorFromRadiance(radiance_sun);
+ col = mix(col.rgb, refcol, envIntensity);
}
+ /*if (norm.w < 0.5)
+ {
+ col = scaleSoftClipFrag(col);
+ }*/
+
#ifdef WATER_FOG
vec4 fogged = applyWaterFogView(pos,vec4(col, bloom));
col = fogged.rgb;
bloom = fogged.a;
#endif
- col = srgb_to_linear(col);
+ col = pow(col, vec3(light_gamma));
}
frag_color.rgb = col;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
index c840d72784..9d872b8df8 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
@@ -1,5 +1,5 @@
/**
- * @file softenLightF.glsl
+ * @file class3/deferred/softenLightV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -22,21 +22,17 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
-uniform vec2 screen_res;
-
VARYING vec2 vary_fragcoord;
+uniform mat4 modelview_projection_matrix;
+uniform vec2 screen_res;
+
void main()
{
//transform vertex
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
-
-
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index a7da140b31..80e2a9dd55 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -133,18 +133,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
}
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl
index aa5e99a2f7..894534b105 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl
@@ -68,19 +68,8 @@ uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
vec3 decode_normal (vec2 enc);
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
+vec4 getPosition(vec2 pos_screen);
+vec3 getNorm(vec2 pos_screen);
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen)
{
@@ -124,13 +113,8 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
void main()
{
vec2 pos_screen = vary_fragcoord.xy;
-
- //try doing an unproject here
-
vec4 pos = getPosition(pos_screen);
-
- vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
- norm = decode_normal(norm.xy); // unpack norm
+ vec3 norm = getNorm(pos_screen);
/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl
index 58f3f2f91e..0870a80a32 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl
@@ -68,81 +68,11 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
-vec3 decode_normal (vec2 enc);
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).r;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-vec2 getKern(int i)
-{
- vec2 kern[8];
- // exponentially (^2) distant occlusion samples spread around origin
- kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
- kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
- kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
- kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
- kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
- kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
- kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
- kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
- return kern[i];
-}
+vec4 getPosition(vec2 pos_screen);
+vec3 getNorm(vec2 pos_screen);
//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
- float ret = 1.0;
-
- vec2 pos_screen = vary_fragcoord.xy;
- vec3 pos_world = pos.xyz;
- vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-
- float angle_hidden = 0.0;
- float points = 0;
-
- float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-
- // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
- for (int i = 0; i < 8; i++)
- {
- vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect);
- vec3 samppos_world = getPosition(samppos_screen).xyz;
-
- vec3 diff = pos_world - samppos_world;
- float dist2 = dot(diff, diff);
-
- // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
- // --> solid angle shrinking by the square of distance
- //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
- //(k should vary inversely with # of samples, but this is taken care of later)
-
- float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0;
- angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv);
-
- // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion"
- float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0;
- points = points + diffz_val;
- }
-
- angle_hidden = min(ssao_factor*angle_hidden/points, 1.0);
-
- float points_val = (points > 0.0) ? 1.0 : 0.0;
- ret = (1.0 - (points_val * angle_hidden));
-
- ret = max(ret, 0.0);
- return min(ret, 1.0);
-}
+float calcAmbientOcclusion(vec4 pos, vec3 norm, pos_screen);
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen)
{
@@ -184,14 +114,9 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
void main()
{
- vec2 pos_screen = vary_fragcoord.xy;
-
- //try doing an unproject here
-
- vec4 pos = getPosition(pos_screen);
-
- vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
- norm = decode_normal(norm.xy); // unpack norm
+ vec2 pos_screen = vary_fragcoord.xy;
+ vec4 pos = getPosition(pos_screen);
+ vec3 norm = getNorm(pos_screen);
/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
{
@@ -291,7 +216,7 @@ void main()
}
frag_color[0] = shadow;
- frag_color[1] = calcAmbientOcclusion(pos, norm);
+ frag_color[1] = calcAmbientOcclusion(pos, norm, pos_screen);
spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
index 8195801be6..9c050256dc 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
@@ -41,16 +41,18 @@ vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
return (light + additive) * atten * 2.0;
}
-vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) {
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
if (no_atmo == 1)
{
return light;
}
float brightness = dot(light.rgb, vec3(0.33333));
- return mix(atmosTransportFrag(light.rgb, additive,a tten), light.rgb + additive.rgb, brightness * brightness);
+ return mix(atmosTransportFrag(light.rgb, additive,atten), light.rgb + additive.rgb, brightness * brightness);
}
-vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 atten, vec3 additive) {
+vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
if (no_atmo == 1)
{
return light;
diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp
index ee757f2566..9539081f30 100644
--- a/indra/newview/lltoolgun.cpp
+++ b/indra/newview/lltoolgun.cpp
@@ -116,7 +116,7 @@ BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask)
{
LLVector3 moonpos = LLViewerCamera::getInstance()->getAtAxis();
gSky.setMoonDirectionCFR(moonpos);
- gSavedSettings.setVector3("SkySunDefaultPosition", LLViewerCamera::getInstance()->getAtAxis());
+ gSavedSettings.setVector3("SkyMoonDefaultPosition", LLViewerCamera::getInstance()->getAtAxis());
}
gViewerWindow->moveCursorToCenter();
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 6418c9900e..6498ed652a 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -483,6 +483,8 @@ void LLViewerShaderMgr::setShaders()
S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail");
bool useRenderDeferred = canRenderDeferred && gSavedSettings.getBOOL("RenderDeferred") && gSavedSettings.getBOOL("RenderAvatarVP");
bool doingWindLight = hasWindLightShaders && gSavedSettings.getBOOL("WindLightUseAtmosShaders");
+ bool useAdvancedAtmospherics = doingWindLight && gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics");
+ (void)useAdvancedAtmospherics;
//using shaders, disable fixed function
LLGLSLShader::sNoFixedFunction = true;
@@ -989,6 +991,8 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
index_channels.push_back(-1); shaders.push_back( make_pair( "environment/encodeNormF.glsl", mVertexShaderLevel[SHADER_ENVIRONMENT] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "environment/decodeNormF.glsl", mVertexShaderLevel[SHADER_ENVIRONMENT] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "environment/srgbF.glsl", mVertexShaderLevel[SHADER_ENVIRONMENT] ) );
+ index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/deferredUtil.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) );
+ index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/indirect.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) );
@@ -1042,7 +1046,10 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment()
gTerrainProgram.mName = "Terrain Shader";
gTerrainProgram.mFeatures.calculatesLighting = true;
gTerrainProgram.mFeatures.calculatesAtmospherics = true;
- gTerrainProgram.mFeatures.hasAtmospherics = true;
+ gTerrainProgram.mFeatures.hasAtmospherics = true;
+ gTerrainProgram.mFeatures.hasTransport = true;
+ gTerrainProgram.mFeatures.hasGamma = true;
+ gTerrainProgram.mFeatures.hasSrgb = true;
gTerrainProgram.mFeatures.mIndexedTextureChannels = 0;
gTerrainProgram.mFeatures.disableTextureIndex = true;
gTerrainProgram.mFeatures.hasGamma = true;
@@ -1201,6 +1208,8 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
BOOL LLViewerShaderMgr::loadShadersDeferred()
{
+ bool use_sun_shadow = mVertexShaderLevel[SHADER_DEFERRED] > 1;
+
if (mVertexShaderLevel[SHADER_DEFERRED] == 0)
{
gDeferredTreeProgram.unload();
@@ -1330,7 +1339,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
success = gDeferredNonIndexedDiffuseProgram.createShader(NULL, NULL);
llassert(success);
}
-
if (success)
{
@@ -1373,6 +1381,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasTransport = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true;
+ gDeferredSkinnedAlphaProgram.mFeatures.hasShadows = true;
+ gDeferredSkinnedAlphaProgram.mFeatures.hasIndirect = true;
gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1381,7 +1391,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1");
gDeferredSkinnedAlphaProgram.addPermutation("HAS_SKIN", "1");
gDeferredSkinnedAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1");
- gDeferredSkinnedAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
+ gDeferredSkinnedAlphaProgram.addPermutation("HAS_SHADOW", use_sun_shadow ? "1" : "0");
success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL);
llassert(success);
@@ -1435,17 +1445,19 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredMaterialProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0");
gDeferredMaterialProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0");
gDeferredMaterialProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode));
- gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
+ gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", use_sun_shadow ? "1" : "0");
bool has_skin = i & 0x10;
gDeferredMaterialProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0");
gDeferredMaterialProgram[i].mFeatures.hasSrgb = true;
- gDeferredMaterialProgram[i].mFeatures.hasGamma = true;
gDeferredMaterialProgram[i].mFeatures.hasTransport = true;
gDeferredMaterialProgram[i].mFeatures.decodesNormal = true;
gDeferredMaterialProgram[i].mFeatures.encodesNormal = true;
gDeferredMaterialProgram[i].mFeatures.calculatesAtmospherics = true;
gDeferredMaterialProgram[i].mFeatures.hasAtmospherics = true;
+ gDeferredMaterialProgram[i].mFeatures.hasGamma = true;
+ gDeferredMaterialProgram[i].mFeatures.hasShadows = true;
+ gDeferredMaterialProgram[i].mFeatures.hasIndirect = true;
if (has_skin)
{
@@ -1478,12 +1490,14 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredMaterialWaterProgram[i].mFeatures.hasWaterFog = true;
gDeferredMaterialWaterProgram[i].mFeatures.hasSrgb = true;
- gDeferredMaterialWaterProgram[i].mFeatures.hasGamma = true;
gDeferredMaterialWaterProgram[i].mFeatures.hasTransport = true;
gDeferredMaterialWaterProgram[i].mFeatures.decodesNormal = true;
gDeferredMaterialWaterProgram[i].mFeatures.encodesNormal = true;
gDeferredMaterialWaterProgram[i].mFeatures.calculatesAtmospherics = true;
gDeferredMaterialWaterProgram[i].mFeatures.hasAtmospherics = true;
+ gDeferredMaterialWaterProgram[i].mFeatures.hasGamma = true;
+ gDeferredMaterialWaterProgram[i].mFeatures.hasShadows = true;
+ gDeferredMaterialWaterProgram[i].mFeatures.hasIndirect = true;
if (has_skin)
{
@@ -1555,6 +1569,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredLightProgram.mName = "Deferred Light Shader";
gDeferredLightProgram.mFeatures.decodesNormal = true;
+ gDeferredLightProgram.mFeatures.isDeferred = true;
+ gDeferredLightProgram.mFeatures.hasShadows = true;
+
gDeferredLightProgram.mShaderFiles.clear();
gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1570,6 +1587,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i);
gDeferredMultiLightProgram[i].mFeatures.decodesNormal = true;
+ gDeferredMultiLightProgram[i].mFeatures.isDeferred = true;
+ gDeferredMultiLightProgram[i].mFeatures.hasShadows = true;
+
gDeferredMultiLightProgram[i].mShaderFiles.clear();
gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1586,6 +1606,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSpotLightProgram.mShaderFiles.clear();
gDeferredSpotLightProgram.mFeatures.hasSrgb = true;
gDeferredSpotLightProgram.mFeatures.decodesNormal = true;
+ gDeferredSpotLightProgram.mFeatures.isDeferred = true;
+ gDeferredSpotLightProgram.mFeatures.hasShadows = true;
+
gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
@@ -1599,6 +1622,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader";
gDeferredMultiSpotLightProgram.mFeatures.hasSrgb = true;
gDeferredMultiSpotLightProgram.mFeatures.decodesNormal = true;
+ gDeferredMultiSpotLightProgram.mFeatures.isDeferred = true;
+ gDeferredMultiSpotLightProgram.mFeatures.hasShadows = true;
+
gDeferredMultiSpotLightProgram.mShaderFiles.clear();
gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1628,6 +1654,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSunProgram.mName = "Deferred Sun Shader";
gDeferredSunProgram.mFeatures.decodesNormal = true;
+ gDeferredSunProgram.mFeatures.isDeferred = true;
+ gDeferredSunProgram.mFeatures.hasShadows = true;
+ gDeferredSunProgram.mFeatures.hasIndirect = true;
+
gDeferredSunProgram.mShaderFiles.clear();
gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER_ARB));
gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
@@ -1641,6 +1671,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredBlurLightProgram.mName = "Deferred Blur Light Shader";
gDeferredBlurLightProgram.mFeatures.decodesNormal = true;
+ gDeferredBlurLightProgram.mFeatures.isDeferred = true;
+
gDeferredBlurLightProgram.mShaderFiles.clear();
gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1659,11 +1691,15 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaProgram.mFeatures.isAlphaLighting = true;
gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
gDeferredAlphaProgram.mFeatures.hasSrgb = true;
- gDeferredAlphaProgram.mFeatures.hasGamma = true;
gDeferredAlphaProgram.mFeatures.decodesNormal = true;
gDeferredAlphaProgram.mFeatures.encodesNormal = true;
gDeferredAlphaProgram.mFeatures.calculatesAtmospherics = true;
gDeferredAlphaProgram.mFeatures.hasAtmospherics = true;
+ gDeferredAlphaProgram.mFeatures.hasGamma = true;
+ gDeferredAlphaProgram.mFeatures.hasTransport = true;
+ gDeferredAlphaProgram.mFeatures.isDeferred = true;
+ gDeferredAlphaProgram.mFeatures.hasShadows = true;
+ gDeferredAlphaProgram.mFeatures.hasIndirect = true;
if (mVertexShaderLevel[SHADER_DEFERRED] < 1)
{
@@ -1678,7 +1714,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1");
- gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
+ gDeferredAlphaProgram.addPermutation("HAS_SHADOW", use_sun_shadow ? "1" : "0");
gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1");
gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
@@ -1700,6 +1736,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaImpostorProgram.mFeatures.hasSrgb = true;
gDeferredAlphaImpostorProgram.mFeatures.decodesNormal = true;
gDeferredAlphaImpostorProgram.mFeatures.encodesNormal = true;
+ gDeferredAlphaImpostorProgram.mFeatures.isDeferred = true;
+ gDeferredAlphaImpostorProgram.mFeatures.hasShadows = true;
+ gDeferredAlphaImpostorProgram.mFeatures.hasIndirect = true;
+
gDeferredAlphaImpostorProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
if (mVertexShaderLevel[SHADER_DEFERRED] < 1)
{
@@ -1714,7 +1754,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAlphaImpostorProgram.addPermutation("USE_INDEXED_TEX", "1");
- gDeferredAlphaImpostorProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
+ gDeferredAlphaImpostorProgram.addPermutation("HAS_SHADOW", use_sun_shadow ? "1" : "0");
gDeferredAlphaImpostorProgram.addPermutation("USE_VERTEX_COLOR", "1");
gDeferredAlphaImpostorProgram.addPermutation("FOR_IMPOSTOR", "1");
@@ -1737,11 +1777,14 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaWaterProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
gDeferredAlphaWaterProgram.mFeatures.hasWaterFog = true;
gDeferredAlphaWaterProgram.mFeatures.hasSrgb = true;
- gDeferredAlphaWaterProgram.mFeatures.hasGamma = true;
gDeferredAlphaWaterProgram.mFeatures.decodesNormal = true;
gDeferredAlphaWaterProgram.mFeatures.encodesNormal = true;
gDeferredAlphaWaterProgram.mFeatures.calculatesAtmospherics = true;
gDeferredAlphaWaterProgram.mFeatures.hasAtmospherics = true;
+ gDeferredAlphaWaterProgram.mFeatures.hasGamma = true;
+ gDeferredAlphaWaterProgram.mFeatures.isDeferred = true;
+ gDeferredAlphaWaterProgram.mFeatures.hasShadows = true;
+ gDeferredAlphaWaterProgram.mFeatures.hasIndirect = true;
if (mVertexShaderLevel[SHADER_DEFERRED] < 1)
{
@@ -1758,7 +1801,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1");
gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1");
gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1");
- gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
+ gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", use_sun_shadow ? "1" : "0");
gDeferredAlphaWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredAlphaWaterProgram.createShader(NULL, NULL);
@@ -1778,7 +1821,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarEyesProgram.mFeatures.disableTextureIndex = true;
gDeferredAvatarEyesProgram.mFeatures.hasSrgb = true;
gDeferredAvatarEyesProgram.mFeatures.encodesNormal = true;
- gDeferredAvatarEyesProgram.mFeatures.hasGamma = true;
+ gDeferredAvatarEyesProgram.mFeatures.isDeferred = true;
+ gDeferredAvatarEyesProgram.mFeatures.hasShadows = true;
+
gDeferredAvatarEyesProgram.mShaderFiles.clear();
gDeferredAvatarEyesProgram.mShaderFiles.push_back(make_pair("deferred/avatarEyesV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarEyesProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1794,7 +1839,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightProgram.mFeatures.hasGamma = true;
gDeferredFullbrightProgram.mFeatures.hasTransport = true;
gDeferredFullbrightProgram.mFeatures.hasSrgb = true;
- gDeferredFullbrightProgram.mFeatures.hasGamma = true;
+ gDeferredFullbrightProgram.mFeatures.isDeferred = true;
+
gDeferredFullbrightProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredFullbrightProgram.mShaderFiles.clear();
gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1811,7 +1857,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true;
gDeferredFullbrightAlphaMaskProgram.mFeatures.hasTransport = true;
gDeferredFullbrightAlphaMaskProgram.mFeatures.hasSrgb = true;
- gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true;
+ gDeferredFullbrightAlphaMaskProgram.mFeatures.isDeferred = true;
+
gDeferredFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear();
gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1830,7 +1877,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightWaterProgram.mFeatures.hasTransport = true;
gDeferredFullbrightWaterProgram.mFeatures.hasWaterFog = true;
gDeferredFullbrightWaterProgram.mFeatures.hasSrgb = true;
- gDeferredFullbrightWaterProgram.mFeatures.hasGamma = true;
+ gDeferredFullbrightWaterProgram.mFeatures.isDeferred = true;
gDeferredFullbrightWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredFullbrightWaterProgram.mShaderFiles.clear();
gDeferredFullbrightWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1850,7 +1897,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasTransport = true;
gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasWaterFog = true;
gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasSrgb = true;
- gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasGamma = true;
+ gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.isDeferred = true;
gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.clear();
gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1869,6 +1916,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightShinyProgram.mFeatures.calculatesAtmospherics = true;
gDeferredFullbrightShinyProgram.mFeatures.hasGamma = true;
gDeferredFullbrightShinyProgram.mFeatures.hasTransport = true;
+ gDeferredFullbrightShinyProgram.mFeatures.isDeferred = true;
gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels-1;
gDeferredFullbrightShinyProgram.mShaderFiles.clear();
gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1887,6 +1935,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedFullbrightProgram.mFeatures.hasObjectSkinning = true;
gDeferredSkinnedFullbrightProgram.mFeatures.disableTextureIndex = true;
gDeferredSkinnedFullbrightProgram.mFeatures.hasSrgb = true;
+ gDeferredSkinnedFullbrightProgram.mFeatures.isDeferred = true;
gDeferredSkinnedFullbrightProgram.mShaderFiles.clear();
gDeferredSkinnedFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSkinnedFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1903,6 +1952,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedFullbrightShinyProgram.mFeatures.hasTransport = true;
gDeferredSkinnedFullbrightShinyProgram.mFeatures.hasObjectSkinning = true;
gDeferredSkinnedFullbrightShinyProgram.mFeatures.disableTextureIndex = true;
+ gDeferredSkinnedFullbrightShinyProgram.mFeatures.isDeferred = true;
gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.clear();
gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1917,6 +1967,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredEmissiveProgram.mFeatures.calculatesAtmospherics = true;
gDeferredEmissiveProgram.mFeatures.hasGamma = true;
gDeferredEmissiveProgram.mFeatures.hasTransport = true;
+ gDeferredEmissiveProgram.mFeatures.isDeferred = true;
gDeferredEmissiveProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredEmissiveProgram.mShaderFiles.clear();
gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveV.glsl", GL_VERTEX_SHADER_ARB));
@@ -1934,6 +1985,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWaterProgram.mFeatures.hasGamma = true;
gDeferredWaterProgram.mFeatures.hasTransport = true;
gDeferredWaterProgram.mFeatures.encodesNormal = true;
+ gDeferredWaterProgram.mFeatures.isDeferred = true;
+ gDeferredWaterProgram.mFeatures.hasShadows = true;
+ gDeferredWaterProgram.mFeatures.hasIndirect = true;
+
gDeferredWaterProgram.mShaderFiles.clear();
gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1953,6 +2008,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredUnderWaterProgram.mFeatures.hasTransport = true;
gDeferredUnderWaterProgram.mFeatures.hasSrgb = true;
gDeferredUnderWaterProgram.mFeatures.encodesNormal = true;
+ gDeferredUnderWaterProgram.mFeatures.isDeferred = true;
+ gDeferredUnderWaterProgram.mFeatures.hasShadows = true;
+ gDeferredUnderWaterProgram.mFeatures.hasIndirect = true;
+
gDeferredUnderWaterProgram.mShaderFiles.clear();
gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1969,17 +2028,29 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSoftenProgram.mFeatures.decodesNormal = true;
gDeferredSoftenProgram.mFeatures.calculatesAtmospherics = true;
gDeferredSoftenProgram.mFeatures.hasAtmospherics = true;
+ gDeferredSoftenProgram.mFeatures.hasTransport = true;
gDeferredSoftenProgram.mFeatures.hasGamma = true;
+ gDeferredSoftenProgram.mFeatures.isDeferred = true;
+ gDeferredSoftenProgram.mFeatures.hasShadows = true;
+ gDeferredSoftenProgram.mFeatures.hasIndirect = true;
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
- if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+ if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
{ //if using SSAO, take screen space light map into account as if shadows are enabled
gDeferredSoftenProgram.mShaderLevel = llmax(gDeferredSoftenProgram.mShaderLevel, 2);
}
+
+ // insure we use class3/deferred version of softenLight for advanced atmo..
+ gDeferredSoftenProgram.mShaderLevel = gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics") ? 3 : gDeferredSoftenProgram.mShaderLevel;
+
+ if (gAtmosphere && gDeferredSoftenProgram.mShaderLevel > 2)
+ {
+ gDeferredSoftenProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink();
+ }
success = gDeferredSoftenProgram.createShader(NULL, NULL);
llassert(success);
@@ -2000,7 +2071,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSoftenWaterProgram.mFeatures.decodesNormal = true;
gDeferredSoftenWaterProgram.mFeatures.calculatesAtmospherics = true;
gDeferredSoftenWaterProgram.mFeatures.hasAtmospherics = true;
+ gDeferredSoftenWaterProgram.mFeatures.hasTransport = true;
gDeferredSoftenWaterProgram.mFeatures.hasGamma = true;
+ gDeferredSoftenWaterProgram.mFeatures.isDeferred = true;
+ gDeferredSoftenWaterProgram.mFeatures.hasShadows = true;
+ gDeferredSoftenWaterProgram.mFeatures.hasIndirect = true;
+
+ if (gAtmosphere && gDeferredSoftenWaterProgram.mShaderLevel > 2)
+ {
+ gDeferredSoftenWaterProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink();
+ }
+
+ if (gAtmosphere && gDeferredSoftenWaterProgram.mShaderLevel > 2)
+ {
+ gDeferredSoftenWaterProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink();
+ }
if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
{ //if using SSAO, take screen space light map into account as if shadows are enabled
@@ -2014,6 +2099,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredShadowProgram.mName = "Deferred Shadow Shader";
+ gDeferredShadowProgram.mFeatures.isDeferred = true;
gDeferredShadowProgram.mShaderFiles.clear();
gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2026,6 +2112,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredShadowCubeProgram.mName = "Deferred Shadow Cube Shader";
+ gDeferredShadowCubeProgram.mFeatures.isDeferred = true;
gDeferredShadowCubeProgram.mShaderFiles.clear();
gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowCubeV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2039,6 +2126,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredShadowAlphaMaskProgram.mName = "Deferred Shadow Alpha Mask Shader";
gDeferredShadowAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
+ gDeferredShadowAlphaMaskProgram.mFeatures.isDeferred = true;
gDeferredShadowAlphaMaskProgram.mShaderFiles.clear();
gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2052,6 +2140,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredAvatarShadowProgram.mName = "Deferred Avatar Shadow Shader";
gDeferredAvatarShadowProgram.mFeatures.hasSkinning = true;
+ gDeferredAvatarShadowProgram.mFeatures.isDeferred = true;
gDeferredAvatarShadowProgram.mShaderFiles.clear();
gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2065,6 +2154,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredAttachmentShadowProgram.mName = "Deferred Attachment Shadow Shader";
gDeferredAttachmentShadowProgram.mFeatures.hasObjectSkinning = true;
+ gDeferredAttachmentShadowProgram.mFeatures.isDeferred = true;
gDeferredAttachmentShadowProgram.mShaderFiles.clear();
gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2078,6 +2168,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gTerrainProgram.mName = "Deferred Terrain Shader";
gDeferredTerrainProgram.mFeatures.encodesNormal = true;
+ gDeferredTerrainProgram.mFeatures.isDeferred = true;
gDeferredTerrainProgram.mShaderFiles.clear();
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2091,6 +2182,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarProgram.mName = "Avatar Shader";
gDeferredAvatarProgram.mFeatures.hasSkinning = true;
gDeferredAvatarProgram.mFeatures.encodesNormal = true;
+ gDeferredAvatarProgram.mFeatures.isDeferred = true;
gDeferredAvatarProgram.mShaderFiles.clear();
gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2114,6 +2206,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true;
gDeferredAvatarAlphaProgram.mFeatures.hasTransport = true;
gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true;
+ gDeferredAvatarAlphaProgram.mFeatures.isDeferred = true;
+ gDeferredAvatarAlphaProgram.mFeatures.hasShadows = true;
+ gDeferredAvatarAlphaProgram.mFeatures.hasIndirect = true;
gDeferredAvatarAlphaProgram.mShaderFiles.clear();
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
@@ -2134,6 +2229,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process";
gDeferredPostGammaCorrectProgram.mFeatures.hasSrgb = true;
+ gDeferredPostGammaCorrectProgram.mFeatures.isDeferred = true;
gDeferredPostGammaCorrectProgram.mShaderFiles.clear();
gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2145,6 +2241,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gFXAAProgram.mName = "FXAA Shader";
+ gFXAAProgram.mFeatures.isDeferred = true;
gFXAAProgram.mShaderFiles.clear();
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2156,6 +2253,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredPostProgram.mName = "Deferred Post Shader";
+ gFXAAProgram.mFeatures.isDeferred = true;
gDeferredPostProgram.mShaderFiles.clear();
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2178,6 +2276,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredDoFCombineProgram.mName = "Deferred DoFCombine Shader";
+ gDeferredDoFCombineProgram.mFeatures.isDeferred = true;
gDeferredDoFCombineProgram.mShaderFiles.clear();
gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/dofCombineF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2189,6 +2288,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredPostNoDoFProgram.mName = "Deferred Post Shader";
+ gDeferredPostNoDoFProgram.mFeatures.isDeferred = true;
gDeferredPostNoDoFProgram.mShaderFiles.clear();
gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoDoFF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2205,6 +2305,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLSkyProgram.mFeatures.calculatesAtmospherics = true;
gDeferredWLSkyProgram.mFeatures.hasTransport = true;
gDeferredWLSkyProgram.mFeatures.hasGamma = true;
+ gDeferredWLSkyProgram.mFeatures.hasSrgb = true;
+ gDeferredWLSkyProgram.mFeatures.isDeferred = true;
+
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];
@@ -2220,6 +2323,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLCloudProgram.mFeatures.calculatesAtmospherics = true;
gDeferredWLCloudProgram.mFeatures.hasTransport = true;
gDeferredWLCloudProgram.mFeatures.hasGamma = true;
+ gDeferredWLCloudProgram.mFeatures.hasSrgb = true;
+ gDeferredWLCloudProgram.mFeatures.isDeferred = true;
+
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];
@@ -2237,6 +2343,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLSunProgram.mFeatures.hasAtmospherics = true;
gDeferredWLSunProgram.mFeatures.isFullbright = true;
gDeferredWLSunProgram.mFeatures.disableTextureIndex = true;
+ gDeferredWLSunProgram.mFeatures.isDeferred = true;
gDeferredWLSunProgram.mShaderFiles.clear();
gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2255,6 +2362,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLMoonProgram.mFeatures.hasAtmospherics = true;
gDeferredWLMoonProgram.mFeatures.isFullbright = true;
gDeferredWLMoonProgram.mFeatures.disableTextureIndex = true;
+ gDeferredWLMoonProgram.mFeatures.isDeferred = true;
+
gDeferredWLMoonProgram.mShaderFiles.clear();
gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2267,6 +2376,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredStarProgram.mName = "Deferred Star Program";
+ gDeferredStarProgram.mFeatures.isDeferred = true;
gDeferredStarProgram.mShaderFiles.clear();
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -2279,6 +2389,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gNormalMapGenProgram.mName = "Normal Map Generation Program";
+ gNormalMapGenProgram.mFeatures.isDeferred = true;
gNormalMapGenProgram.mShaderFiles.clear();
gNormalMapGenProgram.mShaderFiles.push_back(make_pair("deferred/normgenV.glsl", GL_VERTEX_SHADER_ARB));
gNormalMapGenProgram.mShaderFiles.push_back(make_pair("deferred/normgenF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -3603,20 +3714,19 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
return TRUE;
}
-#if USE_ADVANCED_ATMOSPHERICS
-// disabled until we can determine why low-end machines crash during this init...
- if (mVertexShaderLevel[SHADER_WINDLIGHT] > 1)
+ if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics") && mVertexShaderLevel[SHADER_WINDLIGHT] > 2)
{
// Prepare precomputed atmospherics textures using libatmosphere
LLAtmosphere::initClass();
}
-#endif
if (success)
{
gWLSkyProgram.mName = "Windlight Sky Shader";
//gWLSkyProgram.mFeatures.hasGamma = true;
gWLSkyProgram.mShaderFiles.clear();
+ gWLSkyProgram.mFeatures.calculatesAtmospherics = true;
+ gWLSkyProgram.mFeatures.hasTransport = true;
gWLSkyProgram.mFeatures.hasGamma = true;
gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyV.glsl", GL_VERTEX_SHADER_ARB));
gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -3630,6 +3740,8 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
gWLCloudProgram.mName = "Windlight Cloud Program";
//gWLCloudProgram.mFeatures.hasGamma = true;
gWLCloudProgram.mShaderFiles.clear();
+ gWLCloudProgram.mFeatures.calculatesAtmospherics = true;
+ gWLCloudProgram.mFeatures.hasTransport = true;
gWLCloudProgram.mFeatures.hasGamma = true;
gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsV.glsl", GL_VERTEX_SHADER_ARB));
gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB));
diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h
index ef3f8e0361..3217d2a7e2 100644
--- a/indra/newview/llvowlsky.h
+++ b/indra/newview/llvowlsky.h
@@ -88,9 +88,9 @@ private:
std::vector< LLPointer<LLVertexBuffer> > mStripsVerts;
LLPointer<LLVertexBuffer> mStarsVerts;
- std::vector<LLVector3> mStarVertices; // Star verticies
- std::vector<LLColor4> mStarColors; // Star colors
- std::vector<F32> mStarIntensities; // Star intensities
+ std::vector<LLVector3> mStarVertices; // Star verticies
+ std::vector<LLColor4> mStarColors; // Star colors
+ std::vector<F32> mStarIntensities; // Star intensities
};
#endif // LL_VOWLSKY_H
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index f91878587f..bac6267bbd 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -853,6 +853,9 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)
return ret;
}
+ // must be even to avoid a stripe in the horizontal shadow blur
+inline U32 BlurHappySize(U32 x, U32 scale) { return (((x*scale)+1)&~1); }
+
bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
refreshCachedSettings();
@@ -921,22 +924,34 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
}
F32 scale = RenderShadowResolutionScale;
+ U32 sun_shadow_map_width = BlurHappySize(resX, scale);
+ U32 sun_shadow_map_height = BlurHappySize(resY, scale);
if (shadow_detail > 0)
{ //allocate 4 sun shadow maps
- U32 sun_shadow_map_width = ((U32(resX*scale)+1)&~1); // must be even to avoid a stripe in the horizontal shadow blur
for (U32 i = 0; i < 4; i++)
{
- if (!mShadow[i].allocate(sun_shadow_map_width,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false;
- if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false;
+ //allocate VSM sun shadow map(s)
+ if ((shadow_detail > 3) && !mShadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, GL_RGBA16F_ARB, FALSE, FALSE, LLTexUnit::TT_TEXTURE))
+ {
+ return false;
+ }
+ else if (!mShadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE))
+ {
+ return false;
+ }
+
+ if (!mShadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE))
+ {
+ return false;
+ }
}
}
else
{
for (U32 i = 0; i < 4; i++)
{
- mShadow[i].release();
- mShadowOcclusion[i].release();
+ releaseShadowTarget(i);
}
}
@@ -952,19 +967,29 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (shadow_detail > 1)
{ //allocate two spot shadow maps
- U32 spot_shadow_map_width = width;
+ U32 spot_shadow_map_width = width;
+ U32 spot_shadow_map_height = height;
for (U32 i = 4; i < 6; i++)
{
- if (!mShadow[i].allocate(spot_shadow_map_width, height, 0, TRUE, FALSE)) return false;
- if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE)) return false;
+ if ((shadow_detail > 3) && !mShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, GL_RGBA16F_ARB, FALSE, FALSE))
+ {
+ return false;
+ }
+ else if (!mShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE))
+ {
+ return false;
+ }
+ if (!mShadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE))
+ {
+ return false;
+ }
}
}
else
{
for (U32 i = 4; i < 6; i++)
{
- mShadow[i].release();
- mShadowOcclusion[i].release();
+ releaseShadowTarget(i);
}
}
@@ -978,11 +1003,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
mDeferredLight.release();
- for (U32 i = 0; i < 6; i++)
- {
- mShadow[i].release();
- mShadowOcclusion[i].release();
- }
+ releaseShadowTargets();
mFXAABuffer.release();
mScreen.release();
mDeferredScreen.release(); //make sure to release any render targets that share a depth buffer with mDeferredScreen first
@@ -1179,16 +1200,26 @@ void LLPipeline::releaseScreenBuffers()
mDeferredLight.release();
mOcclusionDepth.release();
- for (U32 i = 0; i < 6; i++)
- {
- mShadow[i].release();
- mShadowOcclusion[i].release();
- }
+ releaseShadowTargets();
mInscatter.release();
}
+void LLPipeline::releaseShadowTarget(U32 index)
+{
+ mShadow[index].release();
+ mShadowOcclusion[index].release();
+}
+
+void LLPipeline::releaseShadowTargets()
+{
+ for (U32 i = 0; i < 6; i++)
+ {
+ releaseShadowTarget(i);
+ }
+}
+
void LLPipeline::createGLBuffers()
{
stop_glerror();
@@ -8285,20 +8316,24 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n
for (U32 i = 0; i < 4; i++)
{
- channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE);
- stop_glerror();
- if (channel > -1)
- {
- stop_glerror();
- gGL.getTexUnit(channel)->bind(&mShadow[i], TRUE);
- gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
- gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
- stop_glerror();
+ LLRenderTarget* shadow_target = getShadowTarget(i);
+ if (shadow_target)
+ {
+ channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE);
+ stop_glerror();
+ if (channel > -1)
+ {
+ stop_glerror();
+ gGL.getTexUnit(channel)->bind(getShadowTarget(i), TRUE);
+ gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ stop_glerror();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
- stop_glerror();
- }
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
+ stop_glerror();
+ }
+ }
}
for (U32 i = 4; i < 6; i++)
@@ -8308,18 +8343,22 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n
if (channel > -1)
{
stop_glerror();
- gGL.getTexUnit(channel)->bind(&mShadow[i], TRUE);
- gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
- gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
- stop_glerror();
+ LLRenderTarget* shadow_target = getShadowTarget(i);
+ if (shadow_target)
+ {
+ gGL.getTexUnit(channel)->bind(shadow_target, TRUE);
+ gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+ stop_glerror();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
- stop_glerror();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
+ stop_glerror();
+ }
}
}
- channel = shader.enableTexture(LLShaderMgr::INSCATTER_RT, LLTexUnit::TT_TEXTURE);
+ /*channel = shader.enableTexture(LLShaderMgr::INSCATTER_RT, LLTexUnit::TT_TEXTURE);
stop_glerror();
if (channel > -1)
{
@@ -8332,7 +8371,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_ALWAYS);
stop_glerror();
- }
+ }*/
stop_glerror();
@@ -10600,6 +10639,10 @@ void LLPipeline::generateHighlight(LLCamera& camera)
}
}
+LLRenderTarget* LLPipeline::getShadowTarget(U32 i)
+{
+ return &mShadow[i];
+}
static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
@@ -10819,9 +10862,13 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
for (S32 j = 0; j < 4; j++)
{
- mShadow[j].bindTarget();
- mShadow[j].clear();
- mShadow[j].flush();
+ LLRenderTarget* shadow_target = getShadowTarget(j);
+ if (shadow_target)
+ {
+ shadow_target->bindTarget();
+ shadow_target->clear();
+ shadow_target->flush();
+ }
}
}
else
@@ -10887,12 +10934,16 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
mShadowCamera[j+4] = shadow_cam;
}
- mShadow[j].bindTarget();
- {
- LLGLDepthTest depth(GL_TRUE);
- mShadow[j].clear();
- }
- mShadow[j].flush();
+ LLRenderTarget* shadow_target = getShadowTarget(j);
+ if (shadow_target)
+ {
+ shadow_target->bindTarget();
+ {
+ LLGLDepthTest depth(GL_TRUE);
+ shadow_target->clear();
+ }
+ shadow_target->flush();
+ }
mShadowError.mV[j] = 0.f;
mShadowFOV.mV[j] = 0.f;
@@ -11181,20 +11232,24 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
stop_glerror();
- mShadow[j].bindTarget();
- mShadow[j].getViewport(gGLViewport);
- mShadow[j].clear();
-
- U32 target_width = mShadow[j].getWidth();
+ LLRenderTarget* shadow_target = getShadowTarget(j);
- {
- static LLCullResult result[4];
+ if (shadow_target)
+ {
+ shadow_target->bindTarget();
+ shadow_target->getViewport(gGLViewport);
+ shadow_target->clear();
- renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, TRUE, target_width);
- }
+ U32 target_width = shadow_target->getWidth();
+
+ {
+ static LLCullResult result[4];
+ renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, TRUE, target_width);
+ }
+
+ shadow_target->flush();
+ }
- mShadow[j].flush();
-
if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA))
{
LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
@@ -11327,19 +11382,23 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
stop_glerror();
- mShadow[i+4].bindTarget();
- mShadow[i+4].getViewport(gGLViewport);
- mShadow[i+4].clear();
+ LLRenderTarget* shadow_target = getShadowTarget(i + 4);
- U32 target_width = mShadow[i+4].getWidth();
-
- static LLCullResult result[2];
+ if (shadow_target)
+ {
+ shadow_target->bindTarget();
+ shadow_target->getViewport(gGLViewport);
+ shadow_target->clear();
+
+ U32 target_width = shadow_target->getWidth();
- LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4);
+ static LLCullResult result[2];
+ LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4);
- renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width);
+ renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width);
- mShadow[i+4].flush();
+ shadow_target->flush();
+ }
}
}
else
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index b292ac9358..3646aaaf45 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -209,6 +209,8 @@ public:
U32 addObject(LLViewerObject *obj);
void enableShadows(const bool enable_shadows);
+ void releaseShadowTargets();
+ void releaseShadowTarget(U32 index);
// void setLocalLighting(const bool local_lighting);
// bool isLocalLightingEnabled() const;
@@ -283,6 +285,8 @@ public:
void generateWaterReflection(LLCamera& camera);
void generateSunShadow(LLCamera& camera);
+ LLRenderTarget* getShadowTarget(U32 i);
+
void generateHighlight(LLCamera& camera);
void renderHighlight(const LLViewerObject* obj, F32 fade);
void setHighlightObject(LLDrawable* obj) { mHighlightObject = obj; }