Fixup merge with vwr-dev-mat

meow-7.2.2
Graham Madarasz 2013-04-20 04:32:03 -07:00
parent 5cb597dd8e
commit ff54e85daa
6 changed files with 100 additions and 20 deletions

View File

@ -177,7 +177,6 @@ void main()
#ifndef USE_VERTEX_COLOR
vec4 diffuse_color = vec4(1,1,1,1);
#endif
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);

View File

@ -381,13 +381,11 @@ vec3 scaleSoftClip(vec3 light)
}
#else
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
#endif
uniform sampler2D diffuseMap;
@ -632,5 +630,4 @@ void main()
frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent.
frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity.
#endif
}

View File

@ -238,5 +238,7 @@ void main()
LIGHT_LOOP(7)
color.rgb += diff.rgb * vary_pointlight_col * col.rgb;
frag_color = color;
}

View File

@ -23,16 +23,6 @@
* $/LicenseInfo$
*/
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
vec3 calcDirectionalLight(vec3 n, vec3 l);
vec3 atmosAmbient(vec3 light);
vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
vec3 scaleUpLight(vec3 light);
uniform mat3 normal_matrix;
uniform mat4 texture_matrix0;
uniform mat4 projection_matrix;
@ -61,6 +51,16 @@ mat4 getSkinnedTransform();
#endif
#endif
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
float calcDirectionalLight(vec3 n, vec3 l);
vec3 atmosAmbient(vec3 light);
vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
vec3 scaleUpLight(vec3 light);
VARYING vec3 vary_ambient;
VARYING vec3 vary_directional;
VARYING vec3 vary_fragcoord;

View File

@ -275,6 +275,14 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
mShaderList.push_back(&gUnderWaterProgram);
mShaderList.push_back(&gDeferredSunProgram);
mShaderList.push_back(&gDeferredSoftenProgram);
mShaderList.push_back(&gDeferredMaterialProgram[1]);
mShaderList.push_back(&gDeferredMaterialProgram[5]);
mShaderList.push_back(&gDeferredMaterialProgram[9]);
mShaderList.push_back(&gDeferredMaterialProgram[13]);
mShaderList.push_back(&gDeferredMaterialProgram[1+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredMaterialProgram[5+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT]);
mShaderList.push_back(&gDeferredAlphaProgram);
mShaderList.push_back(&gDeferredSkinnedAlphaProgram);
mShaderList.push_back(&gDeferredFullbrightProgram);
@ -1107,6 +1115,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredPostProgram.unload();
gDeferredCoFProgram.unload();
gDeferredDoFCombineProgram.unload();
gDeferredPostGammaCorrectProgram.unload();
gFXAAProgram.unload();
gDeferredWaterProgram.unload();
gDeferredWLSkyProgram.unload();
@ -1596,8 +1605,11 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true;
gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
gDeferredAvatarAlphaProgram.mShaderFiles.clear();
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaNoColorV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAvatarAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1");
gDeferredAvatarAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1");
gDeferredAvatarAlphaProgram.addPermutation("IS_AVATAR_SKIN", "1");
gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredAvatarAlphaProgram.createShader(NULL, &mAvatarUniforms);
@ -1606,6 +1618,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true;
}
if (success)
{
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.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredPostGammaCorrectProgram.createShader(NULL, NULL);
}
if (success)
{
gFXAAProgram.mName = "FXAA Shader";

View File

@ -908,11 +908,17 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
BOOL ssao = RenderDeferredSSAO;
//allocate deferred rendering color buffers
if (!mDeferredScreen.allocate(resX, resY, GL_RGBA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
if (!addDeferredAttachments(mDeferredScreen)) return false;
if (!mScreen.allocate(resX, resY, GL_RGBA12, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
GLuint screenFormat = GL_RGBA16;
if (gGLManager.mIsATI)
{
screenFormat = GL_RGBA12;
}
if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
if (samples > 0)
{
if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
@ -1327,8 +1333,6 @@ void LLPipeline::createLUTBuffers()
// This is fine, given we only need to create our LUT once per buffer initialization.
spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n)));
spec = powf(spec, 0.6f);
// Since we use R16F, we no longer have a dynamic range issue we need to work around here.
// Though some older drivers may not like this, newer drivers shouldn't have this problem.
ls[y*lightResX+x] = spec;
@ -7107,6 +7111,47 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
gGL.setColorMask(true, true);
glClearColor(0,0,0,0);
if (sRenderDeferred)
{
mScreen.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)
{
mScreen.bindTexture(0,channel);
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight());
F32 gamma = 1.0;
if (!LLViewerCamera::getInstance()->cameraUnderWater())
{
gamma = 1.0/2.2;
}
gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, gamma);
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();
gGL.getTexUnit(channel)->unbind(mScreen.getUsage());
gDeferredPostGammaCorrectProgram.unbind();
mScreen.flush();
}
{
{
LLFastTimer ftm(FTM_RENDER_BLOOM_FBO);
@ -8267,6 +8312,10 @@ void LLPipeline::renderDeferredLighting()
continue;
}
col.mV[0] = powf(col.mV[0], 2.2f);
col.mV[1] = powf(col.mV[1], 2.2f);
col.mV[2] = powf(col.mV[2], 2.2f);
LLFastTimer ftm(FTM_LOCAL_LIGHTS);
gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);
gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s);
@ -8323,6 +8372,9 @@ void LLPipeline::renderDeferredLighting()
setupSpotLight(gDeferredSpotLightProgram, drawablep);
LLColor3 col = volume->getLightColor();
col.mV[0] = powf(col.mV[0], 2.2f);
col.mV[1] = powf(col.mV[1], 2.2f);
col.mV[2] = powf(col.mV[2], 2.2f);
gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);
gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s);
@ -8372,6 +8424,10 @@ void LLPipeline::renderDeferredLighting()
col[count] = light_colors.front();
light_colors.pop_front();
col[count].mV[0] = powf(col[count].mV[0], 2.2f);
col[count].mV[1] = powf(col[count].mV[1], 2.2f);
col[count].mV[2] = powf(col[count].mV[2], 2.2f);
far_z = llmin(light[count].mV[2]-sqrtf(light[count].mV[3]), far_z);
//col[count] = pow4fsrgb(col[count], 2.2f);
count++;
@ -8415,6 +8471,10 @@ void LLPipeline::renderDeferredLighting()
LLColor3 col = volume->getLightColor();
col.mV[0] = powf(col.mV[0], 2.2f);
col.mV[1] = powf(col.mV[1], 2.2f);
col.mV[2] = powf(col.mV[2], 2.2f);
gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v);
gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s);
gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);