Removed TT_RECT_TEXTURE and removed unnecessary shaders.

This commit is contained in:
Shyotl
2017-02-17 23:37:46 -06:00
parent 983a7e31dc
commit 5e501b9611
59 changed files with 338 additions and 957 deletions

View File

@@ -67,9 +67,9 @@ static LLStaticHashedString sVignettRadius("vignette_radius");
static LLStaticHashedString sVignetteDarkness("vignette_darkness");
static LLStaticHashedString sVignetteDesaturation("vignette_desaturation");
static LLStaticHashedString sVignetteChromaticAberration("vignette_chromatic_aberration");
static LLStaticHashedString sScreenRes("screen_res");
static LLStaticHashedString sHorizontalPass("horizontalPass");
static LLStaticHashedString sKern("kern");
static LLStaticHashedString sPrevProj("prev_proj");
static LLStaticHashedString sInvProj("inv_proj");
@@ -262,7 +262,6 @@ public:
getShader().uniform1f(sVignetteDarkness, mDarkness);
getShader().uniform1f(sVignetteDesaturation, mDesaturation);
getShader().uniform1f(sVignetteChromaticAberration, mChromaticAberration);
getShader().uniform2fv(sScreenRes, 1, screen_rect.mV);
return QUAD_NORMAL;
}
};
@@ -284,7 +283,11 @@ public:
/*virtual*/ S32 getDepthChannel() const { return -1; }
/*virtual*/ QuadType preDraw()
{
LLVector2 screen_rect = LLPostProcess::getInstance()->getDimensions();
mPassLoc = getShader().getUniformLocation(sHorizontalPass);
LLVector4 vec[] = { LLVector4(1.3846153846, 3.2307692308, 0, 0) / screen_rect.mV[VX], LLVector4( 0,0, 1.3846153846, 3.2307692308 ) / screen_rect.mV[VY] };
getShader().uniform4fv(sKern, LL_ARRAY_SIZE(vec), (GLfloat*)vec);
return QUAD_NORMAL;
}
/*virtual*/ bool draw(U32 pass)
@@ -322,7 +325,6 @@ public:
getShader().uniformMatrix4fv(sPrevProj, 1, GL_FALSE, prev_proj.getF32ptr());
getShader().uniformMatrix4fv(sInvProj, 1, GL_FALSE, inv_proj.getF32ptr());
getShader().uniform2fv(sScreenRes, 1, screen_rect.mV);
getShader().uniform1i(sBlurStrength, mStrength);
return QUAD_NORMAL;
@@ -411,11 +413,22 @@ void LLPostProcess::initialize(unsigned int width, unsigned int height)
mVBO->getVertexStrider(v);
mVBO->getTexCoord0Strider(uv1);
mVBO->getTexCoord1Strider(uv2);
v[0] = LLVector3( uv2[0] = uv1[0] = LLVector2(0, 0) );
v[1] = LLVector3( uv2[1] = uv1[1] = LLVector2(0, mScreenHeight) );
v[2] = LLVector3( uv2[2] = uv1[2] = LLVector2(mScreenWidth, 0) );
v[3] = LLVector3( uv2[3] = uv1[3] = LLVector2(mScreenWidth, mScreenHeight) );
uv2[0] = uv1[0] = LLVector2(0, 0);
uv2[1] = uv1[1] = LLVector2(0, 1);
uv2[2] = uv1[2] = LLVector2(1, 0);
uv2[3] = uv1[3] = LLVector2(1, 1);
LLVector3 vec1[4] = {
LLVector3(0, 0, 0),
LLVector3(0, mScreenHeight, 0),
LLVector3(mScreenWidth, 0, 0),
LLVector3(mScreenWidth, mScreenHeight, 0) };
v[0] = vec1[0];
v[1] = vec1[1];
v[2] = vec1[2];
v[3] = vec1[3];
mVBO->flush();
}
@@ -424,7 +437,7 @@ void LLPostProcess::initialize(unsigned int width, unsigned int height)
void LLPostProcess::createScreenTextures()
{
const LLTexUnit::eTextureType type = LLTexUnit::TT_RECT_TEXTURE;
const LLTexUnit::eTextureType type = LLTexUnit::TT_TEXTURE;
mRenderTarget[0].allocate(mScreenWidth,mScreenHeight,GL_RGBA,FALSE,FALSE,type,FALSE);
if(mRenderTarget[0].getFBO())//Only need pingpong between two rendertargets if FBOs are supported.
@@ -504,7 +517,7 @@ void LLPostProcess::destroyGL()
void LLPostProcess::copyFrameBuffer()
{
mRenderTarget[!!mRenderTarget[0].getFBO()].bindTexture(0,0);
glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB,0,0,0,0,0,mScreenWidth, mScreenHeight);
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,mScreenWidth, mScreenHeight);
stop_glerror();
if(mDepthTexture)
@@ -513,8 +526,8 @@ void LLPostProcess::copyFrameBuffer()
{
if((*it)->isEnabled() && (*it)->getDepthChannel()>=0)
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mDepthTexture);
glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB,0,0,0,0,0,mScreenWidth, mScreenHeight);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mDepthTexture);
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,mScreenWidth, mScreenHeight);
stop_glerror();
break;
}
@@ -594,7 +607,7 @@ void LLPostProcess::applyShaders(void)
S32 color_channel = (*it)->getColorChannel();
S32 depth_channel = (*it)->getDepthChannel();
if(depth_channel >= 0)
gGL.getTexUnit(depth_channel)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mDepthTexture);
gGL.getTexUnit(depth_channel)->bindManual(LLTexUnit::TT_TEXTURE, mDepthTexture);
U32 pass = 1;
(*it)->bindShader();
@@ -639,11 +652,11 @@ void LLPostProcess::drawOrthoQuad(QuadType type)
mVBO->getTexCoord1Strider(uv2);
float offs[2] = {
/*ll_round*/(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE),
/*ll_round*/(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE) };
/*ll_round*/((float) rand() / (float) RAND_MAX),
/*ll_round*/((float) rand() / (float) RAND_MAX) };
float scale[2] = {
(float)mScreenWidth * mNoiseTextureScale,
(float)mScreenHeight * mNoiseTextureScale };
((float)mScreenWidth * mNoiseTextureScale),
((float)mScreenHeight * mNoiseTextureScale) };
uv2[0] = LLVector2(offs[0],offs[1]);
uv2[1] = LLVector2(offs[0],offs[1]+scale[1]);

View File

@@ -2442,9 +2442,6 @@ void LLRender::debugTexUnits(void)
case LLTexUnit::TT_TEXTURE:
LL_CONT << "Texture 2D";
break;
case LLTexUnit::TT_RECT_TEXTURE:
LL_CONT << "Texture Rectangle";
break;
case LLTexUnit::TT_CUBE_MAP:
LL_CONT << "Cube Map";
break;

View File

@@ -64,7 +64,6 @@ public:
typedef enum
{
TT_TEXTURE = 0, // Standard 2D Texture
TT_RECT_TEXTURE, // Non power of 2 texture
TT_CUBE_MAP, // 6-sided cube map texture
//TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample Do not use
TT_NONE // No texture type is currently enabled

View File

@@ -228,17 +228,8 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
stop_glerror();
}
if (mUsage != LLTexUnit::TT_RECT_TEXTURE)
{
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR);
stop_glerror();
}
else
{
// ATI doesn't support mirrored repeat for rectangular textures.
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
stop_glerror();
}
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR);
stop_glerror();
if (mFBO)
{

View File

@@ -1124,8 +1124,6 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("object_plane_t");
llassert(mReservedUniforms.size() == LLShaderMgr::OBJECT_PLANE_T+1);
mReservedUniforms.push_back("viewport");
mReservedUniforms.push_back("light_position");
mReservedUniforms.push_back("light_direction");
mReservedUniforms.push_back("light_attenuation");
@@ -1216,7 +1214,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("ssao_factor");
mReservedUniforms.push_back("ssao_factor_inv");
mReservedUniforms.push_back("ssao_effect");
mReservedUniforms.push_back("screen_res");
mReservedUniforms.push_back("kern_scale");
mReservedUniforms.push_back("near_clip");
mReservedUniforms.push_back("shadow_offset");
mReservedUniforms.push_back("shadow_bias");
@@ -1232,7 +1230,6 @@ void LLShaderMgr::initAttribsAndUniforms()
llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_DOWNSAMPLED_DEPTH_SCALE+1);
mReservedUniforms.push_back("tc_scale");
mReservedUniforms.push_back("rcp_screen_res");
mReservedUniforms.push_back("rcp_frame_opt");
mReservedUniforms.push_back("rcp_frame_opt2");

View File

@@ -49,7 +49,6 @@ public:
TEXTURE_MATRIX3,
OBJECT_PLANE_S,
OBJECT_PLANE_T,
VIEWPORT,
LIGHT_POSITION,
LIGHT_DIRECTION,
LIGHT_ATTENUATION,
@@ -124,7 +123,7 @@ public:
DEFERRED_SSAO_FACTOR,
DEFERRED_SSAO_FACTOR_INV,
DEFERRED_SSAO_EFFECT,
DEFERRED_SCREEN_RES,
DEFERRED_KERN_SCALE,
DEFERRED_NEAR_CLIP,
DEFERRED_SHADOW_OFFSET,
DEFERRED_SHADOW_BIAS,
@@ -138,7 +137,6 @@ public:
DEFERRED_SHADOW_TARGET_WIDTH,
DEFERRED_DOWNSAMPLED_DEPTH_SCALE,
FXAA_TC_SCALE,
FXAA_RCP_SCREEN_RES,
FXAA_RCP_FRAME_OPT,
FXAA_RCP_FRAME_OPT2,

View File

@@ -33,18 +33,16 @@ out vec4 frag_color;
VARYING vec2 vary_fragcoord;
uniform sampler2DRect depthMapDownsampled;
uniform sampler2DRect normalMap;
uniform sampler2D depthMapDownsampled;
uniform sampler2D normalMap;
uniform sampler2D noiseMap;
uniform vec2 screen_res;
uniform mat4 inv_proj;
uniform float downsampled_depth_scale;
uniform float ssao_radius;
uniform float ssao_max_radius;
uniform float ssao_factor;
uniform vec2 kern_scale;
vec3 decode_normal (vec2 enc)
{
@@ -59,9 +57,8 @@ vec3 decode_normal (vec2 enc)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMapDownsampled, pos_screen.xy*downsampled_depth_scale).r;
float depth = texture2D(depthMapDownsampled, 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;
@@ -90,7 +87,7 @@ vec2 getKern(int i)
float calcAmbientOcclusion(vec4 pos, vec3 norm)
{
vec2 pos_screen = vary_fragcoord.xy;
vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy / kern_scale / 128).xy;
// We treat the first sample as the origin, which definitely doesn't obscure itself thanks to being visible for sampling in the first place.
float points = 1.0;
@@ -98,13 +95,13 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
// use a kernel scale that diminishes with distance.
// a scale of less than 32 is just wasting good samples, though.
float scale = max(32.0, min(ssao_radius / -pos.z, ssao_max_radius));
vec2 scale = max(32.0, min(ssao_radius / -pos.z, ssao_max_radius)) * kern_scale;
// 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 samppos_world = getPosition(samppos_screen).xyz;
vec3 diff = samppos_world - pos.xyz;
@@ -119,8 +116,9 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
points += 1.0;
}
}
angle_hidden /= points;
float rtn = (1.0 - angle_hidden);
return (rtn * rtn) * (rtn * rtn); //Pow2 to increase darkness to match previous behavior.
}
@@ -133,7 +131,7 @@ void main()
vec4 pos = getPosition(pos_screen);
vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
vec3 norm = texture2D(normalMap, pos_screen).xyz;
norm = decode_normal(norm.xy);
frag_color = vec4(calcAmbientOcclusion(pos,norm),0,0,0);

View File

@@ -93,7 +93,6 @@ vec3 vary_AdditiveColor;
vec3 vary_AtmosAttenuation;
uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
@@ -486,7 +485,6 @@ void main()
#if HAS_SHADOW
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
frag *= screen_res;
vec4 spos = pos;
if (spos.z > -shadow_clip.w)

View File

@@ -31,20 +31,18 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform sampler2D lightMap;
uniform float dist_factor;
uniform float blur_size;
uniform vec2 delta;
//uniform vec3 kern[4];
uniform float kern_scale;
uniform vec2 kern_scale;
VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec2 getKern(int i)
{
@@ -59,9 +57,8 @@ vec2 getKern(int i)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -90,13 +87,13 @@ vec3 decode_normal (vec2 enc)
void main()
{
vec2 tc = vary_fragcoord.xy;
vec3 norm = texture2DRect(normalMap, tc).xyz;
vec3 norm = texture2D(normalMap, tc).xyz;
norm = decode_normal(norm.xy); // unpack norm
vec3 pos = getPosition(tc).xyz;
vec4 ccol = texture2DRect(lightMap, tc).rgba;
vec2 dlt = kern_scale * delta / (vec2(1.0)+norm.xy*norm.xy);
vec4 ccol = texture2D(lightMap, tc).rgba;
vec2 dlt = delta / (vec2(1.0)+norm.xy*norm.xy);
dlt /= max(-pos.z*dist_factor, 1.0);
vec2 defined_weight = getKern(0).xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
@@ -106,9 +103,9 @@ void main()
float pointplanedist_tolerance_pow2 = pos.z*-0.001;
// perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large
vec2 tc_v = fract(0.5 * tc.xy); // we now have floor(mod(tc,2.0))*0.5
vec2 tc_v = fract(0.5 * tc.xy / kern_scale); // we now have floor(mod(tc,2.0))*0.5
float tc_mod = 2.0 * abs(tc_v.x - tc_v.y); // diff of x,y makes checkerboard
tc += ( (tc_mod - 0.5) * dlt * 0.5 );
tc += ( (tc_mod - 0.5) * dlt * 0.5 ) * kern_scale;
for (int i = 1; i < 4; i++)
{
@@ -119,7 +116,7 @@ void main()
if (d*d <= pointplanedist_tolerance_pow2)
{
vec4 weight = getKern(i).xyxx;
col += texture2DRect(lightMap, samptc)*weight;
col += texture2D(lightMap, samptc)*weight;
defined_weight += weight.xy;
}
}
@@ -132,7 +129,7 @@ void main()
if (d*d <= pointplanedist_tolerance_pow2)
{
vec4 weight = getKern(i).xyxx;
col += texture2DRect(lightMap, samptc)*weight;
col += texture2D(lightMap, samptc)*weight;
defined_weight += weight.xy;
}
}

View File

@@ -1,39 +0,0 @@
/**
* @file blurLightF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
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;
}

View File

@@ -31,8 +31,8 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect depthMap;
uniform sampler2D diffuseRect;
uniform sampler2D depthMap;
uniform sampler2D bloomMap;
uniform float depth_cutoff;
@@ -44,13 +44,12 @@ uniform float magnification;
uniform float max_cof;
uniform mat4 inv_proj;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
float getDepth(vec2 pos_screen)
{
float z = texture2DRect(depthMap, pos_screen.xy).r;
float z = texture2D(depthMap, pos_screen.xy).r;
z = z*2.0-1.0;
vec4 ndc = vec4(0.0, 0.0, z, 1.0);
vec4 p = inv_proj*ndc;
@@ -78,13 +77,13 @@ void main()
float depth = getDepth(tc);
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
float sc = calc_cof(depth);
sc = min(sc, max_cof);
sc = max(sc, -max_cof);
vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy);
frag_color.rgb = diff.rgb + bloom.rgb;
frag_color.a = sc/max_cof*0.5+0.5;
}

View File

@@ -31,11 +31,10 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect lightMap;
uniform sampler2D diffuseRect;
uniform sampler2D lightMap;
uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform float max_cof;
uniform float res_scale;
@@ -44,12 +43,12 @@ uniform float dof_height;
VARYING vec2 vary_fragcoord;
vec4 dofSample(sampler2DRect tex, vec2 tc)
vec4 dofSample(sampler2D tex, vec2 tc)
{
tc.x = min(tc.x, dof_width);
tc.y = min(tc.y, dof_height);
return texture2DRect(tex, tc);
return texture2D(tex, tc);
}
void main()
@@ -58,7 +57,7 @@ void main()
vec4 dof = dofSample(diffuseRect, vary_fragcoord.xy*res_scale);
vec4 diff = texture2DRect(lightMap, vary_fragcoord.xy);
vec4 diff = texture2D(lightMap, vary_fragcoord.xy);
float a = min(abs(diff.a*2.0-1.0) * max_cof*res_scale*res_scale, 1.0);
@@ -67,10 +66,10 @@ void main()
float sc = a/res_scale;
vec4 col;
col = texture2DRect(lightMap, vary_fragcoord.xy+vec2(sc,sc));
col += texture2DRect(lightMap, vary_fragcoord.xy+vec2(-sc,sc));
col += texture2DRect(lightMap, vary_fragcoord.xy+vec2(sc,-sc));
col += texture2DRect(lightMap, vary_fragcoord.xy+vec2(-sc,-sc));
col = texture2D(lightMap, vary_fragcoord.xy+vec2(sc,sc));
col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,sc));
col += texture2D(lightMap, vary_fragcoord.xy+vec2(sc,-sc));
col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,-sc));
diff = mix(diff, col*0.25, a);
}

View File

@@ -31,11 +31,11 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2D depthMap;
VARYING vec2 vary_fragcoord;
void main()
{
gl_FragDepth = texture2DRect(depthMap, vary_fragcoord.xy).r;
gl_FragDepth = texture2D(depthMap, vary_fragcoord.xy).r;
}

View File

@@ -34,7 +34,9 @@ out vec4 frag_color;
#define FXAA_PC 1
//#define FXAA_GLSL_130 1
#ifndef FXAA_QUALITY_M_PRESET
#define FXAA_QUALITY_M_PRESET 12
#endif
/*============================================================================
@@ -2109,11 +2111,10 @@ uniform vec2 rcp_screen_res;
uniform vec4 rcp_frame_opt;
uniform vec4 rcp_frame_opt2;
VARYING vec2 vary_fragcoord;
VARYING vec2 vary_tc;
void main()
{
vec4 diff = FxaaPixelShader(vary_tc, //pos
vec4 diff = FxaaPixelShader(vary_fragcoord, //pos
vec4(vary_fragcoord.xy, 0, 0), //fxaaConsolePosPos
diffuseMap, //tex
diffuseMap,

View File

@@ -1,39 +0,0 @@
/**
* @file luminanceF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform sampler2DRect diffuseMap;
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec2 vary_fragcoord;
void main()
{
frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
}

View File

@@ -1,45 +0,0 @@
/**
* @file giV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
VARYING vec2 vary_fragcoord;
VARYING vec4 vertex_color;
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;
vertex_color = diffuse_color;
}

View File

@@ -147,7 +147,6 @@ vec3 vary_AdditiveColor;
vec3 vary_AtmosAttenuation;
uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
@@ -276,7 +275,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;

View File

@@ -46,7 +46,6 @@ uniform mat4 modelview_matrix;
VARYING vec3 vary_position;
#if HAS_SUN_SHADOW
VARYING vec2 vary_fragcoord;
uniform vec2 screen_res;
#endif
#endif
@@ -144,7 +143,7 @@ vary_normal = n;
vary_position = pos;
#endif
#if HAS_SUN_SHADOW
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
vary_fragcoord = (pos.xy*0.5+0.5);
#endif
#endif
}

View File

@@ -31,10 +31,10 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2D depthMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
@@ -49,7 +49,6 @@ uniform vec4 light[LIGHT_COUNT];
uniform vec4 light_col[LIGHT_COUNT];
VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
uniform float far_z;
@@ -74,9 +73,8 @@ vec3 decode_normal (vec2 enc)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -87,18 +85,18 @@ vec4 getPosition(vec2 pos_screen)
void main()
{
vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res;
vec2 frag = (vary_fragcoord.xy*0.5+0.5);
vec3 pos = getPosition(frag.xy).xyz;
if (pos.z < far_z)
{
discard;
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
vec3 norm = texture2D(normalMap, frag.xy).xyz;
norm = decode_normal(norm.xy); // unpack norm
norm = normalize(norm);
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
vec4 spec = texture2D(specularRect, frag.xy);
vec3 diff = texture2D(diffuseRect, frag.xy).rgb;
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 out_col = vec3(0,0,0);

View File

@@ -34,10 +34,10 @@ out vec4 frag_color;
//#extension GL_ARB_texture_rectangle : enable
//#extension GL_ARB_shader_texture_lod : enable
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
@@ -64,7 +64,6 @@ uniform float falloff;
uniform float size;
VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
uniform mat4 inv_proj;
@@ -153,9 +152,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -169,7 +167,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = center.xyz-pos.xyz;
@@ -180,7 +177,7 @@ void main()
discard;
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
@@ -212,7 +209,7 @@ void main()
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy/128.0).b;
@@ -251,7 +248,7 @@ void main()
}
vec4 spec = texture2DRect(specularRect, frag.xy);
vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{

View File

@@ -31,13 +31,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
uniform sampler2DRect depthMap;
uniform sampler2D depthMap;
uniform vec3 env_mat[3];
uniform float sun_wash;
@@ -49,8 +49,6 @@ uniform float size;
VARYING vec4 vary_fragcoord;
VARYING vec3 trans_center;
uniform vec2 screen_res;
uniform mat4 inv_proj;
uniform vec4 viewport;
@@ -73,9 +71,8 @@ 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;
float depth = texture2D(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
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;
@@ -89,7 +86,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = trans_center.xyz-pos;
@@ -100,7 +96,7 @@ void main()
discard;
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
vec3 norm = texture2D(normalMap, frag.xy).xyz;
norm = decode_normal(norm.xy); // unpack norm
float da = dot(norm, lv);
if (da < 0.0)
@@ -114,7 +110,7 @@ void main()
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
vec3 col = texture2D(diffuseRect, frag.xy).rgb;
float fa = falloff+1.0;
float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
dist_atten *= dist_atten;
@@ -124,7 +120,7 @@ void main()
col = color.rgb*lit*col;
vec4 spec = texture2DRect(specularRect, frag.xy);
vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
lit = min(da*6.0, 1.0) * dist_atten;

View File

@@ -31,10 +31,9 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2D diffuseRect;
uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform float max_cof;
uniform float res_scale;
@@ -42,7 +41,7 @@ VARYING vec2 vary_fragcoord;
void dofSample(inout vec4 diff, inout float w, float min_sc, vec2 tc)
{
vec4 s = texture2DRect(diffuseRect, tc);
vec4 s = texture2D(diffuseRect, tc);
float sc = abs(s.a*2.0-1.0)*max_cof;
@@ -61,7 +60,7 @@ void dofSample(inout vec4 diff, inout float w, float min_sc, vec2 tc)
void dofSampleNear(inout vec4 diff, inout float w, float min_sc, vec2 tc)
{
vec4 s = texture2DRect(diffuseRect, tc);
vec4 s = texture2D(diffuseRect, tc);
float wg = 0.25;
@@ -77,7 +76,7 @@ void main()
{
vec2 tc = vary_fragcoord.xy;
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
{
float w = 1.0;

View File

@@ -31,9 +31,8 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2D diffuseRect;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
//uniform float display_gamma;
@@ -60,7 +59,7 @@ vec3 linear_to_srgb(vec3 cl)
void main()
{
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
vec4 diff = texture2D(diffuseRect, vary_fragcoord);
diff.rgb = linear_to_srgb(diff.rgb);
frag_color = diff;
}

View File

@@ -31,17 +31,16 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2D diffuseRect;
uniform sampler2D bloomMap;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
void main()
{
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy);
frag_color = diff + bloom;
}

View File

@@ -29,12 +29,10 @@ ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
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;
vary_fragcoord = (pos.xy*0.5+0.5);
}

View File

@@ -1,44 +0,0 @@
/**
* @file postDeferredV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
VARYING vec2 vary_tc;
uniform vec2 tc_scale;
uniform vec2 screen_res;
void main()
{
//transform vertex
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_tc = (pos.xy*0.5+0.5)*tc_scale;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@@ -32,12 +32,11 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect positionMap;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
uniform sampler2DRect depthMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D normalMap;
uniform sampler2D lightMap;
uniform sampler2D depthMap;
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
@@ -76,7 +75,6 @@ vec3 vary_AdditiveColor;
vec3 vary_AtmosAttenuation;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec3 srgb_to_linear(vec3 cs)
{
@@ -129,7 +127,6 @@ 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;
@@ -140,7 +137,7 @@ vec4 getPosition_d(vec2 pos_screen, float depth)
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;
float depth = texture2D(depthMap, pos_screen.xy).a;
return getPosition_d(pos_screen, depth);
}
@@ -381,13 +378,13 @@ float luminance(vec3 color)
void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).r;
float depth = texture2D(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec4 norm = texture2DRect(normalMap, tc);
vec4 norm = texture2D(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = decode_normal(norm.xy); // unpack norm
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 diffuse = texture2D(diffuseRect, tc);
//convert to gamma space
diffuse.rgb = linear_to_srgb(diffuse.rgb);
@@ -395,7 +392,7 @@ void main()
vec3 col;
float bloom = 0.0;
{
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec4 spec = texture2D(specularRect, vary_fragcoord.xy);
bloom = spec.r*norm.w;
if (norm.w < 0.5)
{
@@ -470,7 +467,7 @@ void main()
//col.g = envIntensity;
}
frag_color.rgb = col.rgb;
frag_color.rgb = col;
frag_color.a = bloom;
}

View File

@@ -1,40 +0,0 @@
/**
* @file softenLightF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* 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;
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;
}

View File

@@ -34,10 +34,10 @@ out vec4 frag_color;
//class 1 -- no shadows
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
@@ -64,7 +64,6 @@ uniform float falloff;
VARYING vec3 trans_center;
VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
uniform mat4 inv_proj;
@@ -159,9 +158,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -175,7 +173,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = trans_center.xyz-pos.xyz;
@@ -187,7 +184,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
@@ -218,9 +215,9 @@ void main()
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec4 spec = texture2DRect(specularRect, frag.xy);
vec4 spec = texture2D(specularRect, frag.xy);

View File

@@ -27,8 +27,6 @@ uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
uniform vec2 screen_res;
void main()
{
//transform vertex

View File

@@ -33,17 +33,15 @@ out vec4 frag_color;
VARYING vec2 vary_fragcoord;
uniform sampler2DRect depthMapDownsampled;
uniform sampler2DRect depthMap;
uniform sampler2D depthMapDownsampled;
uniform sampler2D depthMap;
uniform sampler2DRect diffuseRect;
uniform float downsampled_depth_scale;
uniform vec2 screen_res;
uniform sampler2D diffuseRect;
void main()
{
frag_color[0] = 1.0;
frag_color[1] = texture2DRect(diffuseRect,vary_fragcoord.xy*downsampled_depth_scale).r;
frag_color[1] = texture2D(diffuseRect,vary_fragcoord.xy).r;
frag_color[2] = 1.0;
frag_color[3] = 1.0;
}

View File

@@ -1,41 +0,0 @@
/**
* @file sunLightF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
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;
}

View File

@@ -58,7 +58,6 @@ uniform vec3 normScale;
uniform float fresnelScale;
uniform float fresnelOffset;
uniform float blurMultiplier;
uniform vec2 screen_res;
uniform mat4 norm_mat; //region space to screen space
//bigWave is (refCoord.w, view.w);

View File

@@ -13,11 +13,10 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect tex0;
uniform sampler2DRect tex1;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform mat4 inv_proj;
uniform mat4 prev_proj;
uniform vec2 screen_res;
uniform int blur_strength;
VARYING vec2 vary_texcoord0;
@@ -26,9 +25,8 @@ VARYING vec2 vary_texcoord0;
vec4 getPosition(vec2 pos_screen, out vec4 ndc)
{
float depth = texture2DRect(tex1, pos_screen.xy).r;
float depth = texture2D(tex1, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
vec4 pos = inv_proj * ndc;
@@ -44,14 +42,14 @@ void main(void)
vec4 prev_pos = prev_proj * pos;
prev_pos/=prev_pos.w;
prev_pos.w = 1.0;
vec2 vel = ((ndc.xy-prev_pos.xy) * .5) * screen_res * .01 * blur_strength * 1.0/SAMPLE_COUNT;
vec2 vel = ((ndc.xy-prev_pos.xy) * .5) * .01 * blur_strength * 1.0/SAMPLE_COUNT;
float len = length(vel);
vel = normalize(vel) * min(len, 50);
vec3 color = texture2DRect(tex0, vary_texcoord0.st).rgb;
vec3 color = texture2D(tex0, vary_texcoord0.st).rgb;
vec2 texcoord = vary_texcoord0 + vel;
for(int i = 1; i < SAMPLE_COUNT; ++i, texcoord += vel)
{
color += texture2DRect(tex0, texcoord.st).rgb;
color += texture2D(tex0, texcoord.st).rgb;
}
frag_color = vec4(color / SAMPLE_COUNT, 1.0);
}

View File

@@ -13,13 +13,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect tex0;
uniform sampler2D tex0;
uniform int layerCount;
VARYING vec2 vary_texcoord0;
void main(void)
{
vec3 color = pow(floor(pow(vec3(texture2DRect(tex0, vary_texcoord0.st)),vec3(.6)) * layerCount)/layerCount,vec3(1.66666));
vec3 color = pow(floor(pow(vec3(texture2D(tex0, vary_texcoord0.st)),vec3(.6)) * layerCount)/layerCount,vec3(1.66666));
frag_color = vec4(color, 1.0);
}

View File

@@ -13,13 +13,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect tex0;
uniform sampler2D tex0;
uniform float vignette_strength; //0 - 1
uniform float vignette_radius; //0 - 8
uniform float vignette_darkness; //0 - 1
uniform float vignette_desaturation; //0 - 10
uniform float vignette_chromatic_aberration; //0 - .1
uniform vec2 screen_res;
VARYING vec2 vary_texcoord0;
@@ -32,16 +31,15 @@ float luminance(vec3 color)
void main(void)
{
vec3 color = texture2DRect(tex0, vary_texcoord0).rgb;
vec2 norm_texcood = (vary_texcoord0/screen_res);
vec2 offset = norm_texcood-vec2(.5);
vec3 color = texture2D(tex0, vary_texcoord0).rgb;
vec2 offset = vary_texcoord0-vec2(.5);
float vignette = clamp(pow(1 - dot(offset,offset),vignette_radius) + 1-vignette_strength, 0.0, 1.0);
float inv_vignette = 1-vignette;
//vignette chromatic aberration (g
vec2 shift = screen_res * offset * vignette_chromatic_aberration * inv_vignette;
float g = texture2DRect(tex0,vary_texcoord0-shift).g;
float b = texture2DRect(tex0,vary_texcoord0-2*shift).b;
vec2 shift = offset * vignette_chromatic_aberration * inv_vignette;
float g = texture2D(tex0,vary_texcoord0-shift).g;
float b = texture2D(tex0,vary_texcoord0-2*shift).b;
color.gb = vec2(g,b);
//vignette 'black' overlay.

View File

@@ -14,7 +14,7 @@ out vec4 frag_color;
#endif
uniform sampler2DRect tex0;
uniform sampler2D tex0;
uniform float brightness;
uniform float contrast;
uniform vec3 contrastBase;
@@ -34,7 +34,7 @@ float luminance(vec3 color)
void main(void)
{
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0.st));
vec3 color = vec3(texture2D(tex0, vary_texcoord0.st));
/// Apply gamma
color = pow(color, vec3(1.0/gamma));

View File

@@ -6,32 +6,22 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect tex0;
uniform sampler2D tex0;
uniform int horizontalPass;
VARYING vec2 vary_texcoord0;
vec2 offset = vec2( 1.3846153846, 3.2307692308 );
uniform vec4 kern[2];
vec3 weight = vec3( 0.2270270270, 0.3162162162, 0.0702702703 );
void main(void)
{
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0))*weight.x;
vec3 color = vec3(texture2D(tex0, vary_texcoord0))*weight.x;
if(horizontalPass == 1)
{
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s+offset.s,vary_texcoord0.t)));
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s-offset.s,vary_texcoord0.t)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s+offset.t,vary_texcoord0.t)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s-offset.t,vary_texcoord0.t)));
}
else
{
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t+offset.s)));
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t-offset.s)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t+offset.t)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t-offset.t)));
}
color += weight.y * vec3(texture2D(tex0, vec2(vary_texcoord0.s+kern[horizontalPass%2].s,vary_texcoord0.t+kern[horizontalPass].s)));
color += weight.y * vec3(texture2D(tex0, vec2(vary_texcoord0.s-kern[horizontalPass%2].s,vary_texcoord0.t-kern[horizontalPass].s)));
color += weight.z * vec3(texture2D(tex0, vec2(vary_texcoord0.s+kern[horizontalPass%2].t,vary_texcoord0.t+kern[horizontalPass].t)));
color += weight.z * vec3(texture2D(tex0, vec2(vary_texcoord0.s-kern[horizontalPass%2].t,vary_texcoord0.t-kern[horizontalPass].t)));
frag_color = vec4(color.xyz,1.0);
}

View File

@@ -31,7 +31,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseMap;
uniform sampler2D diffuseMap;
uniform float minLuminance;
uniform float maxExtractAlpha;
uniform vec3 lumWeights;
@@ -42,7 +42,7 @@ VARYING vec2 vary_texcoord0;
void main()
{
vec4 col = texture2DRect(diffuseMap, vary_texcoord0.xy);
vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// http://en.wikipedia.org/wiki/Luma_%28video%29
float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );

View File

@@ -13,7 +13,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect tex0;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform float brightMult;
uniform float noiseStrength;
@@ -32,7 +32,7 @@ float luminance(vec3 color)
void main(void)
{
/// Get scene color
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0));
vec3 color = vec3(texture2D(tex0, vary_texcoord0));
/// Extract luminance and scale up by night vision brightness
float lum = luminance(color) * brightMult;

View File

@@ -1,67 +0,0 @@
/**
* @file debugF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
//#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
VARYING vec2 tc0;
VARYING vec2 tc1;
VARYING vec2 tc2;
VARYING vec2 tc3;
VARYING vec2 tc4;
VARYING vec2 tc5;
VARYING vec2 tc6;
VARYING vec2 tc7;
VARYING vec2 tc8;
void main()
{
vec4 depth1 =
vec4(texture2DRect(depthMap, tc0).r,
texture2DRect(depthMap, tc1).r,
texture2DRect(depthMap, tc2).r,
texture2DRect(depthMap, tc3).r);
vec4 depth2 =
vec4(texture2DRect(depthMap, tc4).r,
texture2DRect(depthMap, tc5).r,
texture2DRect(depthMap, tc6).r,
texture2DRect(depthMap, tc7).r);
depth1 = min(depth1, depth2);
float depth = min(depth1.x, depth1.y);
depth = min(depth, depth1.z);
depth = min(depth, depth1.w);
depth = min(depth, texture2DRect(depthMap, tc8).r);
gl_FragDepth = depth;
}

View File

@@ -27,8 +27,6 @@ uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
uniform vec2 screen_res;
uniform vec2 delta;
VARYING vec2 tc0;
@@ -45,7 +43,7 @@ void main()
{
gl_Position = vec4(position, 1.0);
vec2 tc = (position.xy*0.5+0.5)*screen_res;
vec2 tc = (position.xy*0.5+0.5);
tc0 = tc+vec2(-delta.x,-delta.y);
tc1 = tc+vec2(0,-delta.y);
tc2 = tc+vec2(delta.x,-delta.y);

View File

@@ -32,7 +32,7 @@ out vec4 frag_color;
//#extension GL_ARB_texture_rectangle : enable
uniform sampler2D glowMap;
uniform sampler2DRect screenMap;
uniform sampler2D screenMap;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
@@ -40,5 +40,5 @@ VARYING vec2 vary_texcoord1;
void main()
{
frag_color = texture2D(glowMap, vary_texcoord1.xy) +
texture2DRect(screenMap, vary_texcoord0.xy);
texture2D(screenMap, vary_texcoord0.xy);
}

View File

@@ -31,14 +31,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2D diffuseRect;
uniform vec2 screen_res;
VARYING vec2 vary_tc;
void main()
{
vec3 col = texture2DRect(diffuseRect, vary_tc*screen_res).rgb;
vec3 col = texture2D(diffuseRect, vary_tc).rgb;
frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
}

View File

@@ -31,12 +31,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect screenMap;
uniform sampler2D screenMap;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void main()
{
frag_color = texture2DRect(screenMap, vary_texcoord0.xy) * vertex_color;
frag_color = texture2D(screenMap, vary_texcoord0.xy) * vertex_color;
}

View File

@@ -1,62 +0,0 @@
/**
* @file eyeballV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat3 normal_matrix;
uniform mat4 texture_matrix0;
uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec2 texcoord0;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
void main()
{
//transform vertex
vec3 pos = (modelview_matrix * vec4(position.xyz, 1.0)).xyz;
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
vec3 norm = normalize(normal_matrix * normal);
calcAtmospherics(pos.xyz);
// vec4 specular = specularColor;
vec4 specular = vec4(1.0);
vec4 color = calcLightingSpecular(pos, norm, diffuse_color, specular, vec4(0.0));
vertex_color = color;
}

View File

@@ -32,12 +32,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -60,15 +60,32 @@ uniform int proj_shadow_idx;
uniform float shadow_fade;
uniform vec3 center;
uniform float size;
uniform vec3 color;
uniform float falloff;
uniform float size;
VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
uniform mat4 inv_proj;
vec2 encode_normal(vec3 n)
{
float f = sqrt(8 * n.z + 8);
return n.xy / f + 0.5;
}
vec3 decode_normal (vec2 enc)
{
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec3 srgb_to_linear(vec3 cs)
{
vec3 low_range = cs / vec3(12.92);
@@ -87,32 +104,10 @@ vec3 srgb_to_linear(vec3 cs)
}
vec2 encode_normal(vec3 n)
{
float f = sqrt(8 * n.z + 8);
return n.xy / f + 0.5;
}
vec3 decode_normal (vec2 enc)
{
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec4 correctWithGamma(vec4 col)
{
return vec4(srgb_to_linear(col.rgb), col.a);
}
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = tc-vec2(0.5);
@@ -128,7 +123,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -146,7 +141,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = tc-vec2(0.5);
@@ -160,9 +155,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -176,7 +170,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = center.xyz-pos.xyz;
@@ -191,14 +184,14 @@ void main()
if (proj_shadow_idx >= 0)
{
vec4 shd = texture2DRect(lightMap, frag.xy);
vec4 shd = texture2D(lightMap, frag.xy);
float sh[2];
sh[0] = shd.b;
sh[1] = shd.a;
shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
@@ -219,6 +212,7 @@ void main()
float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0);
dist_atten *= dist_atten;
dist_atten *= 2.0;
if (dist_atten <= 0.0)
{
discard;
@@ -230,10 +224,7 @@ void main()
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy/128.0).b;
@@ -243,12 +234,11 @@ void main()
proj_tc.x > 0.0 &&
proj_tc.y > 0.0)
{
float amb_da = proj_ambiance;
float lit = 0.0;
float amb_da = proj_ambiance;
if (da > 0.0)
{
lit = da * dist_atten * noise;
float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
float lod = diff * proj_lod;
@@ -257,6 +247,8 @@ void main()
dlit = color.rgb * plcol.rgb * plcol.a;
lit = da * dist_atten * noise;
col = dlit*lit*diff_tex*shadow;
amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
}
@@ -270,14 +262,17 @@ void main()
amb_da = min(amb_da, 1.0-lit);
col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
col += amb_da*color.rgb*diff_tex*amb_plcol.rgb*amb_plcol.a;
}
vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
vec3 npos = -normalize(pos);
dlit *= min(da*6.0, 1.0) * dist_atten;
vec3 npos = -normalize(pos);
//vec3 ref = dot(pos+lv, norm);
vec3 h = normalize(lv+npos);
@@ -297,10 +292,6 @@ void main()
//col += spec.rgb;
}
}
if (envIntensity > 0.0)
{

View File

@@ -31,11 +31,11 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
uniform sampler2DRect depthMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D normalMap;
uniform sampler2D lightMap;
uniform sampler2D depthMap;
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
@@ -76,7 +76,6 @@ vec3 vary_AdditiveColor;
vec3 vary_AtmosAttenuation;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec3 srgb_to_linear(vec3 cs)
{
@@ -135,7 +134,6 @@ 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;
@@ -146,7 +144,7 @@ vec4 getPosition_d(vec2 pos_screen, float depth)
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;
float depth = texture2D(depthMap, pos_screen.xy).r;
return getPosition_d(pos_screen, depth);
}
@@ -196,6 +194,52 @@ void setAtmosAttenuation(vec3 v)
vary_AtmosAttenuation = v;
}
#ifdef WATER_FOG
uniform vec4 waterPlane;
uniform vec4 waterFogColor;
uniform float waterFogDensity;
uniform float waterFogKS;
vec4 applyWaterFogDeferred(vec3 pos, vec4 color)
{
//normalize view vector
vec3 view = normalize(pos);
float es = -(dot(view, waterPlane.xyz));
//find intersection point with water plane and eye vector
//get eye depth
float e0 = max(-waterPlane.w, 0.0);
vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0);
//get object depth
float depth = length(pos - int_v);
//get "thickness" of water
float l = max(depth, 0.1);
float kd = waterFogDensity;
float ks = waterFogKS;
vec4 kc = waterFogColor;
float F = 0.98;
float t1 = -kd * pow(F, ks * e0);
float t2 = kd + ks * es;
float t3 = pow(F, t2*l) - 1.0;
float L = min(t1/t2*t3, 1.0);
float D = pow(0.98, l*kd);
color.rgb = color.rgb * D + kc.rgb * L;
color.a = kc.a + color.a;
return color;
}
#endif
void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
vec3 P = inPositionEye;
@@ -276,52 +320,6 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
}
#ifdef WATER_FOG
uniform vec4 waterPlane;
uniform vec4 waterFogColor;
uniform float waterFogDensity;
uniform float waterFogKS;
vec4 applyWaterFogDeferred(vec3 pos, vec4 color)
{
//normalize view vector
vec3 view = normalize(pos);
float es = -(dot(view, waterPlane.xyz));
//find intersection point with water plane and eye vector
//get eye depth
float e0 = max(-waterPlane.w, 0.0);
vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0);
//get object depth
float depth = length(pos - int_v);
//get "thickness" of water
float l = max(depth, 0.1);
float kd = waterFogDensity;
float ks = waterFogKS;
vec4 kc = waterFogColor;
float F = 0.98;
float t1 = -kd * pow(F, ks * e0);
float t2 = kd + ks * es;
float t3 = pow(F, t2*l) - 1.0;
float L = min(t1/t2*t3, 1.0);
float D = pow(0.98, l*kd);
color.rgb = color.rgb * D + kc.rgb * L;
color.a = kc.a + color.a;
return color;
}
#endif
vec3 atmosLighting(vec3 light)
{
light *= getAtmosAttenuation().r;
@@ -394,13 +392,13 @@ float luminance(vec3 color)
void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).r;
float depth = texture2D(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec4 norm = texture2DRect(normalMap, tc);
vec4 norm = texture2D(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = decode_normal(norm.xy); // unpack norm
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 diffuse = texture2D(diffuseRect, tc);
//convert to gamma space
diffuse.rgb = linear_to_srgb(diffuse.rgb);
@@ -408,7 +406,7 @@ void main()
vec3 col;
float bloom = 0.0;
{
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec4 spec = texture2D(specularRect, vary_fragcoord.xy);
bloom = spec.r*norm.w;
if (norm.w < 0.5)
@@ -419,7 +417,7 @@ void main()
float light_gamma = 1.0/1.3;
da = pow(da, light_gamma);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
vec2 scol_ambocc = texture2D(lightMap, vary_fragcoord.xy).rg;
scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
float scol = max(scol_ambocc.r, diffuse.a);

View File

@@ -1,42 +0,0 @@
/**
* @file softenLightF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* 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;
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;
}

View File

@@ -32,12 +32,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -65,7 +65,6 @@ uniform float falloff;
VARYING vec3 trans_center;
VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
uniform mat4 inv_proj;
@@ -160,9 +159,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -176,7 +174,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = trans_center.xyz-pos.xyz;
@@ -191,14 +188,14 @@ void main()
if (proj_shadow_idx >= 0)
{
vec4 shd = texture2DRect(lightMap, frag.xy);
vec4 shd = texture2D(lightMap, frag.xy);
float sh[2];
sh[0] = shd.b;
sh[1] = shd.a;
shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
@@ -229,13 +226,13 @@ void main()
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);
vec4 spec = texture2D(specularRect, frag.xy);
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 dlit = vec3(0, 0, 0);
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&

View File

@@ -33,8 +33,8 @@ out vec4 frag_color;
//class 2, shadows, no SSAO
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
@@ -54,7 +54,6 @@ uniform float ssao_factor_inv;
VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform vec2 proj_shadow_res;
uniform vec3 sun_dir;
@@ -84,9 +83,8 @@ vec3 decode_normal (vec2 enc)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -145,7 +143,7 @@ void main()
vec4 pos = getPosition(pos_screen);
vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
vec3 norm = texture2D(normalMap, pos_screen).xyz;
norm = decode_normal(norm.xy); // unpack norm
/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL

View File

@@ -32,9 +32,9 @@ out vec4 frag_color;
//class 2 -- shadows and SSAO
uniform sampler2DRect diffuseRect;
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2D diffuseRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
@@ -51,7 +51,6 @@ uniform vec4 shadow_clip;
VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform vec2 proj_shadow_res;
uniform vec3 sun_dir;
@@ -63,8 +62,6 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
uniform float downsampled_depth_scale;
vec2 encode_normal(vec3 n)
{
float f = sqrt(8 * n.z + 8);
@@ -84,9 +81,8 @@ vec3 decode_normal (vec2 enc)
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
float depth = texture2D(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;
@@ -144,7 +140,7 @@ void main()
vec4 pos = getPosition(pos_screen);
vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
vec3 norm = texture2D(normalMap, pos_screen).xyz;
norm = decode_normal(norm.xy); // unpack norm
/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
@@ -245,7 +241,7 @@ void main()
}
frag_color[0] = shadow;
frag_color[1] = texture2DRect(diffuseRect,vary_fragcoord*downsampled_depth_scale).r;
frag_color[1] = texture2D(diffuseRect,vary_fragcoord).r;
spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);

View File

@@ -1,41 +0,0 @@
/**
* @file sunLightV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
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;
}

View File

@@ -1,5 +1,5 @@
/**
* @file sumLightsV.glsl
* @file sumLightsSpecularV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code

View File

@@ -649,14 +649,6 @@ void LLDrawPoolWater::shade()
sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
}
F32 screenRes[] =
{
1.f/gGLViewport[2],
1.f/gGLViewport[3]
};
shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
stop_glerror();
S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
stop_glerror();

View File

@@ -102,7 +102,6 @@ LLGLSLShader gOneTextureNoColorProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gDebugProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gClipProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gDownsampleDepthProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gDownsampleDepthRectProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gAlphaMaskProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gUIProgram(LLViewerShaderMgr::SHADER_INTERFACE);
@@ -895,7 +894,6 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
shaderUniforms.reserve(3);
shaderUniforms.push_back(LLStaticHashedString("inv_proj"));
shaderUniforms.push_back(LLStaticHashedString("prev_proj"));
shaderUniforms.push_back(LLStaticHashedString("screen_res"));
}
gPostMotionBlurProgram.mName = "Motion Blur Shader (Post)";
@@ -918,7 +916,6 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
shaderUniforms.reserve(3);
shaderUniforms.push_back(LLStaticHashedString("vignette_darkness"));
shaderUniforms.push_back(LLStaticHashedString("vignette_radius"));
shaderUniforms.push_back(LLStaticHashedString("screen_res"));
}
gPostVignetteProgram.mName = "Vignette Shader (Post)";
@@ -1234,7 +1231,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
std::string fragment;
std::string vertex = "deferred/sunLightV.glsl";
std::string vertex = "deferred/postDeferredNoTCV.glsl";
if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
{
@@ -1263,7 +1260,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredSSAOProgram.mName = "Deferred Ambient Occlusion Shader";
gDeferredSSAOProgram.mShaderFiles.clear();
gDeferredSSAOProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSSAOProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSSAOProgram.mShaderFiles.push_back(make_pair("deferred/SSAOF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredSSAOProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredSSAOProgram.createShader(NULL, NULL);
@@ -1273,7 +1270,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredDownsampleDepthNearestProgram.mName = "Deferred Nearest Downsample Depth Shader";
gDeferredDownsampleDepthNearestProgram.mShaderFiles.clear();
gDeferredDownsampleDepthNearestProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredDownsampleDepthNearestProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredDownsampleDepthNearestProgram.mShaderFiles.push_back(make_pair("deferred/downsampleDepthNearestF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredDownsampleDepthNearestProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredDownsampleDepthNearestProgram.createShader(NULL, NULL);
@@ -1284,7 +1281,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredBlurLightProgram.mName = "Deferred Blur Light Shader";
gDeferredBlurLightProgram.mShaderFiles.clear();
gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredBlurLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredBlurLightProgram.createShader(NULL, NULL);
@@ -1540,7 +1537,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredSoftenProgram.mName = "Deferred Soften Shader";
gDeferredSoftenProgram.mShaderFiles.clear();
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
@@ -1557,7 +1554,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader";
gDeferredSoftenWaterProgram.mShaderFiles.clear();
gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredSoftenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
@@ -1673,7 +1670,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process";
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));
gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrectF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredPostGammaCorrectProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredPostGammaCorrectProgram.createShader(NULL, NULL);
}
@@ -1682,8 +1679,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
gFXAAProgram.mName = "FXAA Shader";
gFXAAProgram.mShaderFiles.clear();
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER_ARB));
static LLCachedControl<uint32_t> fxaaQuality("FXAAQuality", 12);
gFXAAProgram.addPermutation("FXAA_QUALITY_M_PRESET", std::to_string(fxaaQuality.get()));
gFXAAProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gFXAAProgram.createShader(NULL, NULL);
}
@@ -2370,16 +2369,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
success = gDownsampleDepthProgram.createShader(NULL, NULL);
}
if (success)
{
gDownsampleDepthRectProgram.mName = "DownsampleDepthRect Shader";
gDownsampleDepthRectProgram.mShaderFiles.clear();
gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB));
gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB));
gDownsampleDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
success = gDownsampleDepthRectProgram.createShader(NULL, NULL);
}
if (success)
{
gAlphaMaskProgram.mName = "Alpha Mask Shader";

View File

@@ -209,7 +209,6 @@ extern LLGLSLShader gGlowCombineFXAAProgram;
extern LLGLSLShader gDebugProgram;
extern LLGLSLShader gClipProgram;
extern LLGLSLShader gDownsampleDepthProgram;
extern LLGLSLShader gDownsampleDepthRectProgram;
//output tex0[tc0] + tex1[tc1]
extern LLGLSLShader gTwoTextureAddProgram;

View File

@@ -213,7 +213,6 @@ static LLStaticHashedString sNormMat("norm_mat");
//static LLStaticHashedString sOffset("offset");
static LLStaticHashedString sDelta("delta");
static LLStaticHashedString sDistFactor("dist_factor");
static LLStaticHashedString sKern("kern");
static LLStaticHashedString sKernScale("kern_scale");
//----------------------------------------
@@ -666,7 +665,7 @@ void LLPipeline::allocatePhysicsBuffer()
if (mPhysicsDisplay.getWidth() != resX || mPhysicsDisplay.getHeight() != resY)
{
mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE);
}
}
@@ -790,9 +789,9 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
const U32 occlusion_divisor = 3;
//allocate deferred rendering color buffers
if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mOcclusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if (!mOcclusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if (!addDeferredAttachments(mDeferredScreen)) return false;
GLuint screenFormat = GL_RGBA16;
@@ -806,8 +805,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
screenFormat = GL_RGBA16F_ARB;
}
if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mFinalScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if (!mFinalScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if (samples > 0)
{
if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
@@ -819,11 +818,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0)
{ //only need mDeferredLight for shadows OR ssao OR dof OR fxaa
if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if(ssao)
{
F32 scale = llclamp(RenderSSAOResolutionScale.get(),.01f,1.f);
if( scale < 1.f && !mDeferredDownsampledDepth.allocate(llceil(F32(resX)*scale), llceil(F32(resY)*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE) ) return false;
if( scale < 1.f && !mDeferredDownsampledDepth.allocate(llceil(F32(resX)*scale), llceil(F32(resY)*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE) ) return false;
}
}
else
@@ -895,10 +894,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
mDeferredDownsampledDepth.release();
mOcclusionDepth.release();
if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
if(samples > 1 && mScreen.getFBO())
{
if(mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples))
if(mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_TEXTURE,FALSE,samples))
mScreen.setSampleBuffer(&mSampleBuffer);
else
{
@@ -1031,6 +1030,8 @@ void LLPipeline::releaseScreenBuffers()
}
mSampleBuffer.release();
mDebugDisplay.release();
}
@@ -2501,20 +2502,9 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d
dest.bindTarget();
dest.clear(GL_DEPTH_BUFFER_BIT);
if (source.getUsage() == LLTexUnit::TT_RECT_TEXTURE)
{
shader = &gDownsampleDepthRectProgram;
shader->bind();
shader->uniform2f(sDelta, 1.f, 1.f);
shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight());
}
else
{
shader = &gDownsampleDepthProgram;
shader->bind();
shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight());
shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f);
}
shader = &gDownsampleDepthProgram;
shader->bind();
shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight());
gGL.getTexUnit(0)->bind(scratch_space ? scratch_space : &source, TRUE);
@@ -7000,14 +6990,15 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
mFinalScreen.bindTexture(0, 0);
LLRenderTarget& render_target = LLPipeline::sRenderDeferred ? mFinalScreen : mScreen;
render_target.bindTexture(0, 0);
gGL.color4f(1,1,1,1);
gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
gGL.getTexUnit(0)->unbind(mFinalScreen.getUsage());
gGL.getTexUnit(0)->unbind(render_target.getUsage());
mGlow[1].flush();
}
@@ -7366,12 +7357,9 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
F32 scale_x = (F32) width/mFXAABuffer.getWidth();
F32 scale_y = (F32) height/mFXAABuffer.getHeight();
shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y);
shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f/width*scale_x, 1.f/height*scale_y);
shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f/width*scale_x, -0.5f/height*scale_y, 0.5f/width*scale_x, 0.5f/height*scale_y);
shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f/width*scale_x, -2.f/height*scale_y, 2.f/width*scale_x, 2.f/height*scale_y);
shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f/width, 1.f/height);
shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f/width, -0.5f/height, 0.5f/width, 0.5f/height);
shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f/width, -2.f/height, 2.f/width, 2.f/height);
drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
@@ -7440,9 +7428,9 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
gGL.begin(LLRender::TRIANGLES);
gGL.texCoord2f(0.f, 0.f);
gGL.vertex2f(-1.f, -1.f);
gGL.texCoord2f(0.f, mScreen.getHeight() * 2.f);
gGL.texCoord2f(0.f,2.f);
gGL.vertex2f(-1.f, 3.f);
gGL.texCoord2f(mScreen.getWidth() * 2.f, 0.f);
gGL.texCoord2f(2.f, 0.f);
gGL.vertex2f( 3.f, -1.f);
gGL.end();
gGL.flush();
@@ -7550,10 +7538,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
inv_proj.invert();
shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.getF32ptr());
shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0],
(F32) gGLViewport[1],
(F32) gGLViewport[2],
(F32) gGLViewport[3]);
}
channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE);
@@ -7664,10 +7648,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
LLVector3 ssao_effect = RenderSSAOEffect;
shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_EFFECT, ssao_effect[0]);
shader.uniform2f(LLShaderMgr::DEFERRED_KERN_SCALE, 1.f / mDeferredScreen.getWidth(), 1.f / mDeferredScreen.getHeight());
//F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2])/3000.f;
shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear()*2.f);
shader.uniform1f (LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error);
shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, RenderShadowBias+shadow_bias_error);
@@ -7689,7 +7674,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.getF32ptr());
}
shader.uniform1f(LLShaderMgr::DEFERRED_DOWNSAMPLED_DEPTH_SCALE, llclamp(RenderSSAOResolutionScale.get(),.01f,1.f));
//shader.uniform1f(LLShaderMgr::DEFERRED_DOWNSAMPLED_DEPTH_SCALE, llclamp(RenderSSAOResolutionScale.get(),.01f,1.f));
}
static LLFastTimer::DeclareTimer FTM_GI_TRACE("Trace");
@@ -7775,7 +7760,6 @@ void LLPipeline::renderDeferredLighting()
mDeferredDownsampledDepth.bindTarget();
mDeferredDownsampledDepth.clear(GL_DEPTH_BUFFER_BIT);
bindDeferredShader(gDeferredDownsampleDepthNearestProgram);
gDeferredDownsampleDepthNearestProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
{
LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS);
drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
@@ -7794,7 +7778,6 @@ void LLPipeline::renderDeferredLighting()
if(ssao_scale < 1.f)
{
glViewport(0,0,mDeferredDownsampledDepth.getWidth(),mDeferredDownsampledDepth.getHeight());
gDeferredSSAOProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
}
{
LLGLDepthTest depth(GL_FALSE);
@@ -7815,8 +7798,6 @@ void LLPipeline::renderDeferredLighting()
mDeferredLight.clear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,0);
gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight());
//Enable bilinear filtering, as the screen tex resolution may not match current framebuffer resolution. Eg, half-res SSAO
// diffuse map should only be found if the sun shader is the SSAO variant.
S32 channel = gDeferredSunProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
@@ -7861,20 +7842,8 @@ void LLPipeline::renderDeferredLighting()
// sample symmetrically with the middle sample falling exactly on 0.0
F32 x = 0.f;
LLVector3 gauss[32]; // xweight, yweight, offset
for (U32 i = 0; i < kern_length; i++)
{
gauss[i].mV[0] = llgaussian(x, go.mV[0]);
gauss[i].mV[1] = llgaussian(x, go.mV[1]);
gauss[i].mV[2] = x;
x += 1.f;
}
gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f);
gDeferredBlurLightProgram.uniform2f(sDelta, (blur_size * (kern_length / 2.f - 0.5f)) / mScreen.getWidth(), 0.f);
gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV);
gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f));
{
LLGLDisable blend(GL_BLEND);
@@ -7888,7 +7857,7 @@ void LLPipeline::renderDeferredLighting()
bindDeferredShader(gDeferredBlurLightProgram, &mScreen, &mScreen);
mDeferredLight.bindTarget();
gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f);
gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, (blur_size * (kern_length / 2.f - 0.5f)) / mScreen.getHeight());
{
LLGLDisable blend(GL_BLEND);
@@ -8237,8 +8206,6 @@ void LLPipeline::renderDeferredLighting()
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight());
drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
gGL.getTexUnit(channel)->unbind(mScreen.getUsage());
@@ -8375,7 +8342,6 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
mDeferredDownsampledDepth.bindTarget();
mDeferredDownsampledDepth.clear(GL_DEPTH_BUFFER_BIT);
bindDeferredShader(gDeferredDownsampleDepthNearestProgram);
gDeferredDownsampleDepthNearestProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
{
LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS);
drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
@@ -8393,8 +8359,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
bindDeferredShader(gDeferredSSAOProgram);
if(ssao_scale < 1.f)
{
glViewport(0,0,mDeferredDownsampledDepth.getWidth(),mDeferredDownsampledDepth.getHeight());
gDeferredSSAOProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
glViewport(0,0,mDeferredDownsampledDepth.getWidth(),mDeferredDownsampledDepth.getHeight());
}
{
LLGLDepthTest depth(GL_FALSE);
@@ -8414,8 +8379,6 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
glClearColor(1,1,1,1);
mDeferredLight.clear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,0);
gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight());
//Enable bilinear filtering, as the screen tex resolution may not match current framebuffer resolution. Eg, half-res SSAO
// diffuse map should only be found if the sun shader is the SSAO variant.
@@ -8777,14 +8740,9 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
{
LLGLDepthTest depth(GL_FALSE, GL_FALSE);
LLVector2 tc1(0,0);
LLVector2 tc2((F32) mScreen.getWidth()*2,
(F32) mScreen.getHeight()*2);
mFinalScreen.bindTarget();
// Apply gamma correction to the frame here.
gDeferredPostGammaCorrectProgram.bind();
//mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
S32 channel = 0;
channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
if (channel > -1)
@@ -8793,23 +8751,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight());
F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma");
gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f));
gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
gGL.vertex2f(-1,-1);
gGL.texCoord2f(tc1.mV[0], tc2.mV[1]);
gGL.vertex2f(-1,3);
gGL.texCoord2f(tc2.mV[0], tc1.mV[1]);
gGL.vertex2f(3,-1);
gGL.end();
drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
gGL.getTexUnit(channel)->unbind(mScreen.getUsage());
gDeferredPostGammaCorrectProgram.unbind();
@@ -11012,22 +10954,17 @@ void LLPipeline::drawFullScreenRect(U32 data_mask)
mAuxScreenRectVB = new LLVertexBuffer(AUX_VB_MASK, 0);
mAuxScreenRectVB->allocateBuffer(3, 0, true);
LLStrider<LLVector3> vert;
LLStrider<LLVector2> tc0, tc1;
LLStrider<LLVector2> tc0;
mAuxScreenRectVB->getVertexStrider(vert);
mAuxScreenRectVB->getTexCoord0Strider(tc0);
mAuxScreenRectVB->getTexCoord1Strider(tc1);
vert[0].set(-1.f,-1.f,0.f);
vert[1].set(3.f,-1.f,0.f);
vert[2].set(-1.f,3.f,0.f);
tc0[0].set(0.f, 0.f);
tc0[1].set(mScreen.getWidth()*2.f, 0.f);
tc0[2].set(0.f, mScreen.getHeight()*2.f);
tc1[0].set(0.f, 0.f);
tc1[1].set(2.f, 0.f);
tc1[2].set(0.f, 2.f);
tc0[1].set(2.f, 0.f);
tc0[2].set(0.f, 2.f);
}
mAuxScreenRectVB->setBuffer(data_mask);
mAuxScreenRectVB->drawArrays(LLRender::TRIANGLES, 0, 3);

View File

@@ -601,6 +601,8 @@ public:
private:
LLRenderTarget mPhysicsDisplay;
LLRenderTarget mDebugDisplay;
//utility buffer for rendering post effects, gets abused by renderDeferredLighting
LLPointer<LLVertexBuffer> mAuxScreenRectVB;