summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-01-30 13:26:35 -0800
committerGraham Linden <graham@lindenlab.com>2019-01-30 13:26:35 -0800
commitdeb6110098569fb90ca7e5073c2e98fabbb23a82 (patch)
tree3958b309a3acab40775f1c286ffc0e3eb618149d /indra/newview
parent08440def112395487d57a9d6e719c7700d7134b5 (diff)
Eliminate helper GLSL modules depending on further GLSL modules to give Intel HD x000 compiler a fighting chance.
More WIP for edge-specific water shader for 9996.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl34
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl8
-rw-r--r--indra/newview/lldrawpoolwater.cpp169
-rw-r--r--indra/newview/lldrawpoolwater.h2
4 files changed, 127 insertions, 86 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl
index 3bb59dd7f9..23adbded5e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl
@@ -24,13 +24,43 @@
*/
uniform sampler2D noiseMap;
+uniform sampler2DRect normalMap;
+uniform sampler2DRect depthMap;
uniform float ssao_radius;
uniform float ssao_max_radius;
uniform float ssao_factor;
uniform float ssao_factor_inv;
-vec4 getPosition(vec2 pos_screen);
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+vec2 getScreenCoordinateAo(vec2 screenpos)
+{
+ vec2 sc = screenpos.xy * 2.0;
+ if (screen_res.x > 0 && screen_res.y > 0)
+ {
+ sc /= screen_res;
+ }
+ return sc - vec2(1.0, 1.0);
+}
+
+float getDepthAo(vec2 pos_screen)
+{
+ float depth = texture2DRect(depthMap, pos_screen).r;
+ return depth;
+}
+
+vec4 getPositionAo(vec2 pos_screen)
+{
+ float depth = getDepthAo(pos_screen);
+ vec2 sc = getScreenCoordinateAo(pos_screen);
+ 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)
{
@@ -64,7 +94,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)
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 samppos_world = getPositionAo(samppos_screen).xyz;
vec3 diff = pos_world - samppos_world;
float dist2 = dot(diff, diff);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index cef9938192..843901ea6a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -25,7 +25,6 @@
uniform sampler2DRect normalMap;
uniform sampler2DRect depthMap;
-uniform sampler2D noiseMap;
uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
@@ -33,11 +32,6 @@ uniform sampler2DShadow shadowMap3;
uniform sampler2DShadow shadowMap4;
uniform sampler2DShadow shadowMap5;
-uniform float ssao_radius;
-uniform float ssao_max_radius;
-uniform float ssao_factor;
-uniform float ssao_factor_inv;
-
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform vec2 shadow_res;
@@ -52,8 +46,6 @@ uniform float sun_up_factor;
uniform mat4 inv_proj;
uniform vec2 screen_res;
-vec3 decode_normal(vec2 enc);
-
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)
{
stc.xyz /= stc.w;
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 514ce41d5a..826aa1cf24 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -477,85 +477,14 @@ void LLDrawPoolWater::renderReflection(LLFace* face)
face->renderIndexed();
}
-void LLDrawPoolWater::shade()
+void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& light_diffuse, const LLVector3& light_dir, F32 light_exp)
{
- if (!deferred_render)
- {
- gGL.setColorMask(true, true);
- }
-
- LLVOSky *voskyp = gSky.mVOSkyp;
-
- if(voskyp == NULL)
- {
- return;
- }
-
- LLGLDisable blend(GL_BLEND);
-
- LLColor3 light_diffuse(0,0,0);
- F32 light_exp = 0.0f;
- LLVector3 light_dir;
+ F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();
LLEnvironment& environment = LLEnvironment::instance();
LLSettingsWater::ptr_t pwater = environment.getCurrentWater();
LLSettingsSky::ptr_t psky = environment.getCurrentSky();
- light_dir = environment.getLightDirection();
- light_dir.normalize();
-
- bool sun_up = environment.getIsSunUp();
- bool moon_up = environment.getIsMoonUp();
-
- if (sun_up)
- {
- light_diffuse += voskyp->getSun().getColorCached();
- }
- // moonlight is several orders of magnitude less bright than sunlight,
- // so only use this color when the moon alone is showing
- else if (moon_up)
- {
- light_diffuse += psky->getMoonDiffuse();
- }
-
- light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
-
- light_diffuse.normalize();
- light_diffuse *= (light_exp + 0.25f);
-
- light_exp *= light_exp;
- light_exp *= light_exp;
- light_exp *= light_exp;
- light_exp *= light_exp;
- light_exp *= 256.f;
- light_exp = light_exp > 32.f ? light_exp : 32.f;
-
- light_diffuse *= 6.f;
-
- LLGLSLShader* shader;
-
- F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();
-
- if (eyedepth < 0.f && LLPipeline::sWaterReflections)
- {
- if (deferred_render)
- {
- shader = &gDeferredUnderWaterProgram;
- }
- else
- {
- shader = &gUnderWaterProgram;
- }
- }
- else if (deferred_render)
- {
- shader = &gDeferredWaterProgram;
- }
- else
- {
- shader = &gWaterProgram;
- }
-
shader->bind();
if (deferred_render)
@@ -721,9 +650,11 @@ void LLDrawPoolWater::shade()
LLVOWater* water = (LLVOWater*) face->getViewerObject();
gGL.getTexUnit(diffTex)->bind(face->getTexture());
- bool edge = water && water->getIsEdgePatch();
- shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0);
- face->renderIndexed();
+ bool edge_patch = water && water->getIsEdgePatch();
+ if (edge_patch == edge)
+ {
+ face->renderIndexed();
+ }
}
}
}
@@ -736,6 +667,92 @@ void LLDrawPoolWater::shade()
shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
shader->unbind();
+}
+
+void LLDrawPoolWater::shade()
+{
+ if (!deferred_render)
+ {
+ gGL.setColorMask(true, true);
+ }
+
+ LLVOSky *voskyp = gSky.mVOSkyp;
+
+ if(voskyp == NULL)
+ {
+ return;
+ }
+
+ LLGLDisable blend(GL_BLEND);
+
+ LLColor3 light_diffuse(0,0,0);
+ F32 light_exp = 0.0f;
+ LLVector3 light_dir;
+
+ LLEnvironment& environment = LLEnvironment::instance();
+ LLSettingsWater::ptr_t pwater = environment.getCurrentWater();
+ LLSettingsSky::ptr_t psky = environment.getCurrentSky();
+
+ light_dir = environment.getLightDirection();
+ light_dir.normalize();
+
+ bool sun_up = environment.getIsSunUp();
+ bool moon_up = environment.getIsMoonUp();
+
+ if (sun_up)
+ {
+ light_diffuse += voskyp->getSun().getColorCached();
+ }
+ // moonlight is several orders of magnitude less bright than sunlight,
+ // so only use this color when the moon alone is showing
+ else if (moon_up)
+ {
+ light_diffuse += psky->getMoonDiffuse();
+ }
+
+ light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
+
+ light_diffuse.normalize();
+ light_diffuse *= (light_exp + 0.25f);
+
+ light_exp *= light_exp;
+ light_exp *= light_exp;
+ light_exp *= light_exp;
+ light_exp *= light_exp;
+ light_exp *= 256.f;
+ light_exp = light_exp > 32.f ? light_exp : 32.f;
+
+ light_diffuse *= 6.f;
+
+ LLGLSLShader* shader = nullptr;
+ LLGLSLShader* edge_shader = nullptr;
+
+ F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();
+
+ if (eyedepth < 0.f && LLPipeline::sWaterReflections)
+ {
+ if (deferred_render)
+ {
+ shader = &gDeferredUnderWaterProgram;
+ }
+ else
+ {
+ shader = &gUnderWaterProgram;
+ }
+ }
+ else if (deferred_render)
+ {
+ shader = &gDeferredWaterProgram;
+ //edge_shader = &gDeferredWaterEdgeProgram;
+ }
+ else
+ {
+ shader = &gWaterProgram;
+ //edge_shader = &gWaterEdgeProgram;
+ }
+
+ shade2(false, shader, light_diffuse, light_dir, light_exp);
+ shade2(true, edge_shader ? edge_shader : shader, light_diffuse, light_dir, light_exp);
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h
index f14ac1f6d2..f94baefc41 100644
--- a/indra/newview/lldrawpoolwater.h
+++ b/indra/newview/lldrawpoolwater.h
@@ -33,6 +33,7 @@
class LLFace;
class LLHeavenBody;
class LLWaterSurface;
+class LLGLSLShader;
class LLDrawPoolWater: public LLFacePool
{
@@ -81,6 +82,7 @@ public:
void renderReflection(LLFace* face);
void shade();
+ void shade2(bool edge, LLGLSLShader* shader, const LLColor3& light_diffuse, const LLVector3& light_dir, F32 light_exp);
void setTransparentTextures(const LLUUID& transparentTextureId, const LLUUID& nextTransparentTextureId);
void setOpaqueTexture(const LLUUID& opaqueTextureId);