SH-2265 Fix for impostor alpha masking being broken.

master
Dave Parks 2011-08-10 14:40:39 -05:00
parent f302e11962
commit 17f46868d2
6 changed files with 77 additions and 0 deletions

View File

@ -5,6 +5,8 @@
* $/LicenseInfo$
*/
uniform float minimum_alpha;
uniform float maximum_alpha;
uniform sampler2D diffuseMap;
@ -14,6 +16,12 @@ uniform sampler2D specularMap;
void main()
{
vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
if (col.a < minimum_alpha || col.a > maximum_alpha)
{
discard;
}
gl_FragData[0] = vec4(col.rgb, col.a * 0.005);
gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);

View File

@ -0,0 +1,26 @@
/**
* @file impostorF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
uniform float minimum_alpha;
uniform float maximum_alpha;
vec3 fullbrightAtmosTransport(vec3 light);
vec3 fullbrightScaleSoftClip(vec3 light);
uniform sampler2D diffuseMap;
void main()
{
vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color;
if (color.a < minimum_alpha || color.a > maximum_alpha)
{
discard;
}
gl_FragColor = color;
}

View File

@ -0,0 +1,16 @@
/**
* @file impostorV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
void main()
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
}

View File

@ -589,12 +589,22 @@ void LLDrawPoolAvatar::beginImpostor()
LLVOAvatar::sNumVisibleAvatars = 0;
}
if (LLGLSLShader::sNoFixedFunction)
{
gImpostorProgram.bind();
gImpostorProgram.setAlphaRange(0.01f, 1.f);
}
gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
sDiffuseChannel = 0;
}
void LLDrawPoolAvatar::endImpostor()
{
if (LLGLSLShader::sNoFixedFunction)
{
gImpostorProgram.unbind();
}
gPipeline.enableLightsDynamic();
}
@ -647,6 +657,7 @@ void LLDrawPoolAvatar::beginDeferredImpostor()
sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
sVertexProgram->bind();
sVertexProgram->setAlphaRange(0.01f, 1.f);
}
void LLDrawPoolAvatar::endDeferredImpostor()

View File

@ -118,6 +118,7 @@ LLGLSLShader gAvatarProgram;
LLGLSLShader gAvatarWaterProgram;
LLGLSLShader gAvatarEyeballProgram;
LLGLSLShader gAvatarPickProgram;
LLGLSLShader gImpostorProgram;
// WindLight shader handles
LLGLSLShader gWLSkyProgram;
@ -186,6 +187,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
mShaderList.push_back(&gWaterProgram);
mShaderList.push_back(&gAvatarEyeballProgram);
mShaderList.push_back(&gObjectSimpleProgram);
mShaderList.push_back(&gImpostorProgram);
mShaderList.push_back(&gObjectSimpleAlphaMaskProgram);
mShaderList.push_back(&gObjectBumpProgram);
mShaderList.push_back(&gUIProgram);
@ -638,6 +640,7 @@ void LLViewerShaderMgr::unloadShaders()
gSolidColorProgram.unload();
gObjectSimpleProgram.unload();
gImpostorProgram.unload();
gObjectSimpleAlphaMaskProgram.unload();
gObjectBumpProgram.unload();
gObjectSimpleWaterProgram.unload();
@ -1678,6 +1681,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectFullbrightShinyWaterProgram.unload();
gObjectShinyWaterProgram.unload();
gObjectSimpleProgram.unload();
gImpostorProgram.unload();
gObjectSimpleAlphaMaskProgram.unload();
gObjectBumpProgram.unload();
gObjectSimpleWaterProgram.unload();
@ -1874,6 +1878,17 @@ BOOL LLViewerShaderMgr::loadShadersObject()
success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms);
}
if (success)
{
gImpostorProgram.mName = "Impostor Shader";
gImpostorProgram.mFeatures.disableTextureIndex = true;
gImpostorProgram.mShaderFiles.clear();
gImpostorProgram.mShaderFiles.push_back(make_pair("objects/impostorV.glsl", GL_VERTEX_SHADER_ARB));
gImpostorProgram.mShaderFiles.push_back(make_pair("objects/impostorF.glsl", GL_FRAGMENT_SHADER_ARB));
gImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gImpostorProgram.createShader(NULL, NULL);
}
if (success)
{
gObjectSimpleProgram.mName = "Simple Shader";

View File

@ -351,6 +351,7 @@ extern LLGLSLShader gAvatarProgram;
extern LLGLSLShader gAvatarWaterProgram;
extern LLGLSLShader gAvatarEyeballProgram;
extern LLGLSLShader gAvatarPickProgram;
extern LLGLSLShader gImpostorProgram;
// WindLight shader handles
extern LLGLSLShader gWLSkyProgram;