diff options
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | 9 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 37 | ||||
-rwxr-xr-x | indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 40 | ||||
-rwxr-xr-x | indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl | 4 | ||||
-rwxr-xr-x | indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 67 | ||||
-rwxr-xr-x | indra/newview/lldrawpool.cpp | 28 | ||||
-rwxr-xr-x | indra/newview/lldrawpool.h | 3 | ||||
-rwxr-xr-x | indra/newview/lldrawpoolalpha.cpp | 114 | ||||
-rwxr-xr-x | indra/newview/lldrawpoolalpha.h | 9 | ||||
-rwxr-xr-x | indra/newview/lldrawpoolavatar.cpp | 54 | ||||
-rwxr-xr-x | indra/newview/lldrawpoolsimple.cpp | 214 | ||||
-rwxr-xr-x | indra/newview/lldrawpoolsimple.h | 53 | ||||
-rwxr-xr-x | indra/newview/llface.cpp | 49 | ||||
-rwxr-xr-x | indra/newview/llviewershadermgr.cpp | 31 | ||||
-rwxr-xr-x | indra/newview/llviewershadermgr.h | 1 | ||||
-rwxr-xr-x | indra/newview/llvovolume.cpp | 69 | ||||
-rwxr-xr-x | indra/newview/pipeline.cpp | 65 | ||||
-rwxr-xr-x | indra/newview/pipeline.h | 4 |
18 files changed, 639 insertions, 212 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index efb4d48845..5c164f7759 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -31,6 +31,10 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +#if !HAS_DIFFUSE_LOOKUP +uniform sampler2D diffuseMap; +#endif + VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -40,7 +44,12 @@ vec3 fullbrightScaleSoftClip(vec3 light); void main() { +#if HAS_DIFFUSE_LOOKUP vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; +#else + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy)*vertex_color; +#endif + color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f)); color.rgb = fullbrightAtmosTransport(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 539efa3499..17aa0e32a7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -28,9 +28,7 @@ #define DIFFUSE_ALPHA_MODE_MASK 2 #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 -#if DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE uniform float emissive_brightness; -#endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -388,6 +386,18 @@ vec3 scaleSoftClip(vec3 light) return light; } +vec3 fullbrightAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +} + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + //soft clip effect: + return light; +} + #else #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -446,6 +456,7 @@ void main() #endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + vec3 old_diffcol = diffcol.rgb; diffcol.rgb = pow(diffcol.rgb, vec3(2.2)); #endif @@ -475,6 +486,8 @@ void main() #if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE) final_color.a = emissive_brightness; +#else + final_color.a = max(final_color.a, emissive_brightness); #endif vec4 final_specular = spec; @@ -613,24 +626,33 @@ void main() col += spec_contrib; } + col = mix(col.rgb, old_diffcol.rgb, diffuse.a); + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - vec3 refcol = pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2; + float exponent = mix(2.2, 1.0, diffuse.a); + + vec3 refcol = pow(textureCube(environmentMap, env_vec).rgb, vec3(exponent))*exponent; col = mix(col.rgb, refcol, - max(envIntensity-diffuse.a*2.0, 0.0)); - + envIntensity); + float cur_glare = max(refcol.r, refcol.g); cur_glare = max(cur_glare, refcol.b); cur_glare *= envIntensity*4.0; glare += cur_glare; } + + float exponent = mix(1.0, 2.2, diffuse.a); + col = pow(col, vec3(exponent)); + - col = atmosLighting(col); - col = scaleSoftClip(col); + col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + vec3 npos = normalize(-pos.xyz); #define LIGHT_LOOP(i) col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); @@ -646,7 +668,6 @@ void main() frag_color.rgb = col.rgb; glare = min(glare, 1.0); frag_color.a = max(diffcol.a*vertex_color.a, glare); - #else frag_data[0] = final_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index b688c1a70c..45d672c290 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -248,6 +248,15 @@ vec3 atmosTransport(vec3 light) { light += getAdditiveColor() * 2.0; return light; } + +vec3 fullbrightAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +} + + + vec3 atmosGetDiffuseSunlightColor() { return getSunlitColor(); @@ -282,6 +291,13 @@ vec3 scaleSoftClip(vec3 light) return light; } + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + //soft clip effect: + return light; +} + void main() { vec2 tc = vary_fragcoord.xy; @@ -328,32 +344,36 @@ void main() col += spec_contrib; } - col = mix(col.rgb, diffuse.rgb, diffuse.a); - + + col = mix(col.rgb, pow(diffuse.rgb, vec3(1.0/2.2)), diffuse.a); + + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; float exponent = mix(2.2, 1.0, diffuse.a); + vec3 refcol = pow(textureCube(environmentMap, env_vec).rgb, vec3(exponent))*exponent; - col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(exponent)) * exponent, - envIntensity); + col = mix(col.rgb, refcol, + envIntensity); - exponent = mix(1.0, 2.2, diffuse.a); - col.rgb = pow(col.rgb, vec3(exponent))/exponent; } + float exponent = mix(1.0, 2.2, diffuse.a); + col = pow(col, vec3(exponent)); + if (norm.w < 0.5) { - col = atmosLighting(col); - col = scaleSoftClip(col); + col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } + //col = vec3(1,0,1); //col.g = envIntensity; } frag_color.rgb = col; - //frag_color.a = bloom; - frag_color.a = 0.0; + frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl index 2ff7f795b0..361f316065 100755 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl @@ -32,6 +32,8 @@ out vec4 frag_color; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +uniform float texture_gamma; + vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); @@ -39,6 +41,8 @@ void fullbright_lighting() { vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; + color.rgb = pow(color.rgb, vec3(texture_gamma)); + color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index ee6aaddb00..31b2a32f7f 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -38,7 +38,6 @@ uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; uniform samplerCube environmentMap; uniform sampler2D lightFunc; -uniform vec3 gi_quad; uniform float blur_size; uniform float blur_fidelity; @@ -66,11 +65,7 @@ uniform mat3 env_mat; uniform vec4 shadow_clip; uniform mat3 ssao_effect_mat; -uniform mat4 inv_proj; -uniform vec2 screen_res; - uniform vec3 sun_dir; - VARYING vec2 vary_fragcoord; vec3 vary_PositionEye; @@ -80,6 +75,9 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; +uniform mat4 inv_proj; +uniform vec2 screen_res; + vec3 decode_normal (vec2 enc) { vec2 fenc = enc*4-2; @@ -130,7 +128,6 @@ vec3 getAtmosAttenuation() return vary_AtmosAttenuation; } - void setPositionEye(vec3 v) { vary_PositionEye = v; @@ -251,6 +248,15 @@ vec3 atmosTransport(vec3 light) { light += getAdditiveColor() * 2.0; return light; } + +vec3 fullbrightAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +} + + + vec3 atmosGetDiffuseSunlightColor() { return getSunlitColor(); @@ -285,6 +291,13 @@ vec3 scaleSoftClip(vec3 light) return light; } + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + //soft clip effect: + return light; +} + void main() { vec2 tc = vary_fragcoord.xy; @@ -292,14 +305,14 @@ void main() vec3 pos = getPosition_d(tc, depth).xyz; vec4 norm = texture2DRect(normalMap, tc); float envIntensity = norm.z; - norm.xyz = decode_normal(norm.xy); + norm.xyz = decode_normal(norm.xy); // unpack norm + float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); vec3 col; float bloom = 0.0; - { vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); @@ -310,15 +323,14 @@ void main() calcAtmospherics(pos.xyz, ambocc); col = atmosAmbient(vec3(0)); - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); - col *= ambient; + col.rgb *= ambient; - col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, diffuse.a)); + col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, 0.0)); col *= diffuse.rgb; @@ -331,27 +343,42 @@ void main() float sa = dot(refnormpersp, sun_dir.xyz); vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); - + // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; bloom = dot(spec_contrib, spec_contrib) / 6; col += spec_contrib; } - + + + col = mix(col.rgb, pow(diffuse.rgb, vec3(1.0/2.2)), diffuse.a); + + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2, - envIntensity); - } - col = atmosLighting(col); - col = scaleSoftClip(col); + float exponent = mix(2.2, 1.0, diffuse.a); + vec3 refcol = pow(textureCube(environmentMap, env_vec).rgb, vec3(exponent))*exponent; + + col = mix(col.rgb, refcol, + envIntensity); + + } - col = mix(col.rgb, diffuse.rgb, diffuse.a); + float exponent = mix(1.0, 2.2, diffuse.a); + col = pow(col, vec3(exponent)); + + if (norm.w < 0.5) + { + col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + } + + //col = vec3(1,0,1); + //col.g = envIntensity; } - frag_color.rgb = col; frag_color.a = bloom; } diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index fc5571aa58..04e31e6486 100755 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -48,6 +48,7 @@ #include "llspatialpartition.h" #include "llviewercamera.h" #include "lldrawpoolwlsky.h" +#include "llglslshader.h" S32 LLDrawPool::sNumDrawPools = 0; @@ -65,6 +66,12 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) case POOL_GRASS: poolp = new LLDrawPoolGrass(); break; + case POOL_ALPHA_MASK: + poolp = new LLDrawPoolAlphaMask(); + break; + case POOL_FULLBRIGHT_ALPHA_MASK: + poolp = new LLDrawPoolFullbrightAlphaMask(); + break; case POOL_FULLBRIGHT: poolp = new LLDrawPoolFullbright(); break; @@ -415,6 +422,27 @@ void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_text } } +void LLRenderPass::pushMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) +{ + for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + { + LLDrawInfo* pparams = *i; + if (pparams) + { + if (LLGLSLShader::sCurBoundShaderPtr) + { + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); + } + else + { + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, pparams->mAlphaMaskCutoff); + } + + pushBatch(*pparams, mask, texture, batch_textures); + } + } +} + void LLRenderPass::applyModelMatrix(LLDrawInfo& params) { if (params.mModelMatrix != gGLLastMatrix) diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 93656c34e4..3bde0d29be 100755 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -55,6 +55,8 @@ public: POOL_SKY, POOL_WL_SKY, POOL_TREE, + POOL_ALPHA_MASK, + POOL_FULLBRIGHT_ALPHA_MASK, POOL_GRASS, POOL_INVISIBLE, // see below * POOL_AVATAR, @@ -168,6 +170,7 @@ public: static void applyModelMatrix(LLDrawInfo& params); virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); + virtual void pushMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE); virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); virtual void renderGroups(U32 type, U32 mask, BOOL texture = TRUE); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index bfb66fce22..90474ea6f6 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -71,52 +71,6 @@ void LLDrawPoolAlpha::prerender() mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } -S32 LLDrawPoolAlpha::getNumDeferredPasses() -{ - return 1; -} - -void LLDrawPoolAlpha::beginDeferredPass(S32 pass) -{ - -} - -void LLDrawPoolAlpha::endDeferredPass(S32 pass) -{ - -} - -void LLDrawPoolAlpha::renderDeferred(S32 pass) -{ - LLFastTimer t(FTM_RENDER_GRASS); - gDeferredDiffuseAlphaMaskProgram.bind(); - gDeferredDiffuseAlphaMaskProgram.setMinimumAlpha(0.33f); - pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - gDeferredDiffuseAlphaMaskProgram.unbind(); -} - -void LLDrawPoolAlpha::pushMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) -{ - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) - { - LLDrawInfo* pparams = *i; - if (pparams) - { - if (LLGLSLShader::sCurBoundShaderPtr) - { - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - } - else - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, pparams->mAlphaMaskCutoff); - } - - pushBatch(*pparams, mask, texture, batch_textures); - } - } -} - - S32 LLDrawPoolAlpha::getNumPostDeferredPasses() { if (LLPipeline::sImpostorRender) @@ -235,53 +189,7 @@ void LLDrawPoolAlpha::render(S32 pass) { gGL.setColorMask(true, true); } - - if (LLPipeline::sAutoMaskAlphaNonDeferred) - { - mColorSFactor = LLRender::BF_ONE; // } - mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow - mAlphaSFactor = LLRender::BF_ZERO; - mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds - gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); - - if (mVertexShaderLevel > 0) - { - if (!LLPipeline::sRenderDeferred || !deferred_render) - { - simple_shader->bind(); - simple_shader->setMinimumAlpha(0.33f); - - pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_SPECMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_NORMMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_NORMSPEC_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - } - if (fullbright_shader) - { - fullbright_shader->bind(); - fullbright_shader->setMinimumAlpha(0.33f); - if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) - { - fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); - } else { - fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); - } - } - pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - //LLGLSLShader::bindNoShader(); - } - else - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); //OK - gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); - pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask(), TRUE, FALSE); - gPipeline.enableLightsDynamic(); - pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask(), TRUE, FALSE); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK - } - } - + LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy || (deferred_render && pass == 1) ? GL_TRUE : GL_FALSE); @@ -442,7 +350,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) LLMaterial* mat = NULL; - if (!params.mFullbright && deferred_render && !LLPipeline::sUnderWaterRender) + if (deferred_render && !LLPipeline::sUnderWaterRender) { mat = params.mMaterial; } @@ -479,7 +387,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) light_enabled = TRUE; } - if (!params.mFullbright && deferred_render && mat) + if (deferred_render && mat) { U32 mask = params.mShaderMask; @@ -512,32 +420,26 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) current_shader = NULL; } - if (use_shaders && mat && !params.mFullbright) + if (use_shaders && mat) { - // I apologize in advance for not giving this its own shader. // We have a material. Supply the appropriate data here. if (LLPipeline::sRenderDeferred) { current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, params.mSpecColor.mV[0], params.mSpecColor.mV[1], params.mSpecColor.mV[2], params.mSpecColor.mV[3]); current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, params.mEnvIntensity); - + current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, params.mFullbright ? 1.f : 0.f); + if (params.mNormalMap) { params.mNormalMap->addTextureStats(params.mVSize); current_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap); - } else { - LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); - } + } if (params.mSpecularMap) { params.mSpecularMap->addTextureStats(params.mVSize); current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap); - } else { - LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); - } + } } } else if (LLPipeline::sRenderDeferred && current_shader && (current_shader == simple_shader)) diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index 46c17f3b99..43122218ed 100755 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -50,11 +50,6 @@ public: LLDrawPoolAlpha(U32 type = LLDrawPool::POOL_ALPHA); /*virtual*/ ~LLDrawPoolAlpha(); - /*virtual*/ S32 getNumDeferredPasses(); - /*virtual*/ void beginDeferredPass(S32 pass); - /*virtual*/ void endDeferredPass(S32 pass); - /*virtual*/ void renderDeferred(S32 pass); - /*virtual*/ S32 getNumPostDeferredPasses(); /*virtual*/ void beginPostDeferredPass(S32 pass); /*virtual*/ void endPostDeferredPass(S32 pass); @@ -70,9 +65,7 @@ public: void renderGroupAlpha(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); void renderAlpha(U32 mask); void renderAlphaHighlight(U32 mask); - void pushMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures); - - + static BOOL sShowDebugAlpha; private: diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index a65240abff..2bdfe2b986 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -894,7 +894,14 @@ void LLDrawPoolAvatar::beginRiggedFullbright() } else { - sVertexProgram = &gSkinnedObjectFullbrightProgram; + if (LLPipeline::sRenderDeferred) + { + sVertexProgram = &gDeferredSkinnedFullbrightProgram; + } + else + { + sVertexProgram = &gSkinnedObjectFullbrightProgram; + } } } else @@ -913,6 +920,15 @@ void LLDrawPoolAvatar::beginRiggedFullbright() { sDiffuseChannel = 0; sVertexProgram->bind(); + + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + { + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } + else + { + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } } } @@ -1001,11 +1017,19 @@ void LLDrawPoolAvatar::beginRiggedFullbrightShiny() } } - if (sShaderLevel > 0 || gPipeline.canUseVertexShaders()) { sVertexProgram->bind(); LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); + + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + { + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } + else + { + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } } } @@ -1632,7 +1656,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) gGL.diffuseColor4f(0,0,0,face->getTextureEntry()->getGlow()); }*/ - LLMaterial* mat = face->getTextureEntry()->getMaterialParams().get(); + const LLTextureEntry* te = face->getTextureEntry(); + LLMaterial* mat = te->getMaterialParams().get(); if (mat) { @@ -1643,13 +1668,27 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) LLColor4U col = mat->getSpecularLightColor(); U8 spec = mat->getSpecularLightExponent(); - U8 env = mat->getEnvironmentIntensity(); + F32 env = mat->getEnvironmentIntensity()/255.f; + + if (mat->getSpecularID().isNull()) + { + env = te->getShiny()*0.25f; + } + + BOOL fullbright = te->getFullbright(); + sVertexProgram->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, fullbright ? 1.f : 0.f); sVertexProgram->uniform4f(LLShaderMgr::SPECULAR_COLOR, col.mV[0]/255.f, col.mV[1]/255.f, col.mV[2]/255.f, spec/255.f); + sVertexProgram->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, env); - sVertexProgram->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, env/255.f); - - sVertexProgram->setMinimumAlpha(mat->getAlphaMaskCutoff()/255.f); + if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + { + sVertexProgram->setMinimumAlpha(mat->getAlphaMaskCutoff()/255.f); + } + else + { + sVertexProgram->setMinimumAlpha(0.f); + } for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) { @@ -1663,6 +1702,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) else { gGL.getTexUnit(sDiffuseChannel)->bind(face->getTexture()); + sVertexProgram->setMinimumAlpha(0.f); if (normal_channel > -1) { LLDrawPoolBump::bindBumpMap(face, normal_channel); diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 1a6293c010..7ca87d3858 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -214,6 +214,167 @@ void LLDrawPoolSimple::render(S32 pass) } } + + + + + + + + + +static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_MASK("Alpha Mask"); + +LLDrawPoolAlphaMask::LLDrawPoolAlphaMask() : + LLRenderPass(POOL_ALPHA_MASK) +{ +} + +void LLDrawPoolAlphaMask::prerender() +{ + mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); +} + +void LLDrawPoolAlphaMask::beginRenderPass(S32 pass) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK); + + if (LLPipeline::sUnderWaterRender) + { + simple_shader = &gObjectSimpleWaterAlphaMaskProgram; + } + else + { + simple_shader = &gObjectSimpleAlphaMaskProgram; + } + + if (mVertexShaderLevel > 0) + { + simple_shader->bind(); + } + else + { + // don't use shaders! + if (gGLManager.mHasShaderObjects) + { + LLGLSLShader::bindNoShader(); + } + } +} + +void LLDrawPoolAlphaMask::endRenderPass(S32 pass) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK); + stop_glerror(); + LLRenderPass::endRenderPass(pass); + stop_glerror(); + if (mVertexShaderLevel > 0) + { + simple_shader->unbind(); + } +} + +void LLDrawPoolAlphaMask::render(S32 pass) +{ + LLGLDisable blend(GL_BLEND); + LLFastTimer t(FTM_RENDER_ALPHA_MASK); + + if (mVertexShaderLevel > 0) + { + simple_shader->bind(); + simple_shader->setMinimumAlpha(0.33f); + + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_SPECMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_NORMMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_NORMSPEC_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + } + else + { + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask(), TRUE, FALSE); + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK + } +} + +LLDrawPoolFullbrightAlphaMask::LLDrawPoolFullbrightAlphaMask() : + LLRenderPass(POOL_FULLBRIGHT_ALPHA_MASK) +{ +} + +void LLDrawPoolFullbrightAlphaMask::prerender() +{ + mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); +} + +void LLDrawPoolFullbrightAlphaMask::beginRenderPass(S32 pass) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK); + + if (LLPipeline::sUnderWaterRender) + { + simple_shader = &gObjectFullbrightWaterAlphaMaskProgram; + } + else + { + simple_shader = &gObjectFullbrightAlphaMaskProgram; + } + + if (mVertexShaderLevel > 0) + { + simple_shader->bind(); + } + else + { + // don't use shaders! + if (gGLManager.mHasShaderObjects) + { + LLGLSLShader::bindNoShader(); + } + } +} + +void LLDrawPoolFullbrightAlphaMask::endRenderPass(S32 pass) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK); + stop_glerror(); + LLRenderPass::endRenderPass(pass); + stop_glerror(); + if (mVertexShaderLevel > 0) + { + simple_shader->unbind(); + } +} + +void LLDrawPoolFullbrightAlphaMask::render(S32 pass) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK); + + if (mVertexShaderLevel > 0) + { + if (simple_shader) + { + simple_shader->bind(); + simple_shader->setMinimumAlpha(0.33f); + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + { + simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } else { + simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } + } + pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + //LLGLSLShader::bindNoShader(); + } + else + { + gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); + pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask(), TRUE, FALSE); + gPipeline.enableLightsDynamic(); + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK + } +} + //=============================== //DEFERRED IMPLEMENTATION //=============================== @@ -243,6 +404,28 @@ void LLDrawPoolSimple::renderDeferred(S32 pass) } } +static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_MASK_DEFERRED("Deferred Alpha Mask"); + +void LLDrawPoolAlphaMask::beginDeferredPass(S32 pass) +{ + +} + +void LLDrawPoolAlphaMask::endDeferredPass(S32 pass) +{ + +} + +void LLDrawPoolAlphaMask::renderDeferred(S32 pass) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK_DEFERRED); + gDeferredDiffuseAlphaMaskProgram.bind(); + gDeferredDiffuseAlphaMaskProgram.setMinimumAlpha(0.33f); + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + gDeferredDiffuseAlphaMaskProgram.unbind(); +} + + // grass drawpool LLDrawPoolGrass::LLDrawPoolGrass() : LLRenderPass(POOL_GRASS) @@ -407,6 +590,8 @@ void LLDrawPoolFullbright::render(S32 pass) { fullbright_shader->bind(); fullbright_shader->uniform1f(LLViewerShaderMgr::FULLBRIGHT, 1.f); + fullbright_shader->uniform1f(LLViewerShaderMgr::TEXTURE_GAMMA, 1.f); + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; pushBatches(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask, TRUE, TRUE); pushBatches(LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE, fullbright_mask, TRUE, TRUE); @@ -433,3 +618,32 @@ S32 LLDrawPoolFullbright::getNumPasses() return 1; } + +void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) +{ + gObjectFullbrightAlphaMaskProgram.bind(); + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + { + gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } + else + { + gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } +} + +void LLDrawPoolFullbrightAlphaMask::renderPostDeferred(S32 pass) +{ + LLFastTimer t(FTM_RENDER_FULLBRIGHT); + LLGLDisable blend(GL_BLEND); + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; + pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, fullbright_mask, TRUE, TRUE); +} + +void LLDrawPoolFullbrightAlphaMask::endPostDeferredPass(S32 pass) +{ + gObjectFullbrightAlphaMaskProgram.unbind(); + LLRenderPass::endRenderPass(pass); +} + + diff --git a/indra/newview/lldrawpoolsimple.h b/indra/newview/lldrawpoolsimple.h index bd62bc7502..608ad9e1eb 100755 --- a/indra/newview/lldrawpoolsimple.h +++ b/indra/newview/lldrawpoolsimple.h @@ -84,6 +84,59 @@ public: /*virtual*/ void prerender(); }; +class LLDrawPoolAlphaMask : public LLRenderPass +{ +public: + enum + { + VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_NORMAL | + LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_COLOR + }; + virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } + + LLDrawPoolAlphaMask(); + + /*virtual*/ S32 getNumDeferredPasses() { return 1; } + /*virtual*/ void beginDeferredPass(S32 pass); + /*virtual*/ void endDeferredPass(S32 pass); + /*virtual*/ void renderDeferred(S32 pass); + + /*virtual*/ S32 getNumPasses() { return 1; } + /*virtual*/ void beginRenderPass(S32 pass); + /*virtual*/ void endRenderPass(S32 pass); + /*virtual*/ void render(S32 pass = 0); + /*virtual*/ void prerender(); + +}; + +class LLDrawPoolFullbrightAlphaMask : public LLRenderPass +{ +public: + enum + { + VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_COLOR + }; + virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } + + LLDrawPoolFullbrightAlphaMask(); + + /*virtual*/ S32 getNumPostDeferredPasses() { return 1; } + /*virtual*/ void beginPostDeferredPass(S32 pass); + /*virtual*/ void endPostDeferredPass(S32 pass); + /*virtual*/ void renderPostDeferred(S32 pass); + + /*virtual*/ S32 getNumPasses() { return 1; } + /*virtual*/ void beginRenderPass(S32 pass); + /*virtual*/ void endRenderPass(S32 pass); + /*virtual*/ void render(S32 pass = 0); + /*virtual*/ void prerender(); +}; + + class LLDrawPoolFullbright : public LLRenderPass { public: diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index eb78d42c35..63919630fc 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1316,28 +1316,44 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLColor4U color = tep->getColor(); if (rebuild_color) - { - if (tep) + { //decide if shiny goes in alpha channel of color + if (tep && + getPoolType() != LLDrawPool::POOL_ALPHA) // <--- alpha channel MUST contain transparency, not shiny { LLMaterial* mat = tep->getMaterialParams().get(); + + bool shiny_in_alpha = false; + + if (LLPipeline::sRenderDeferred) + { //store shiny in alpha if we don't have a specular map + if (!mat || mat->getSpecularID().isNull()) + { + shiny_in_alpha = true; + } + } + else + { + if (!mat || mat->getDiffuseAlphaMode() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + { + shiny_in_alpha = true; + } + } - GLfloat alpha[4] = + if (shiny_in_alpha) { - 0.00f, - 0.25f, - 0.5f, - 0.75f - }; + + GLfloat alpha[4] = + { + 0.00f, + 0.25f, + 0.5f, + 0.75f + }; - if ((!LLPipeline::sRenderDeferred || !mat || mat->getSpecularID().isNull()) && - getPoolType() != LLDrawPool::POOL_ALPHA && - (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) - { llassert(tep->getShiny() <= 3); color.mV[3] = U8 (alpha[tep->getShiny()] * 255); } } - } // INDICES @@ -2117,11 +2133,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLVector4a src; - U32 glow32 = glow | - (glow << 8) | - (glow << 16) | - (glow << 24); + LLColor4U glow4u = LLColor4U(0,0,0,glow); + U32 glow32 = glow4u.mAll; + U32 vec[4]; vec[0] = vec[1] = vec[2] = vec[3] = glow32; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 87c5211952..a36d6c10da 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -211,6 +211,7 @@ LLGLSLShader gDeferredWLCloudProgram; LLGLSLShader gDeferredStarProgram; LLGLSLShader gDeferredFullbrightShinyProgram; LLGLSLShader gDeferredSkinnedFullbrightShinyProgram; +LLGLSLShader gDeferredSkinnedFullbrightProgram; LLGLSLShader gNormalMapGenProgram; // Deferred materials shaders @@ -293,6 +294,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredFullbrightProgram); mShaderList.push_back(&gDeferredFullbrightShinyProgram); mShaderList.push_back(&gDeferredSkinnedFullbrightShinyProgram); + mShaderList.push_back(&gDeferredSkinnedFullbrightProgram); mShaderList.push_back(&gDeferredEmissiveProgram); mShaderList.push_back(&gDeferredAvatarEyesProgram); mShaderList.push_back(&gDeferredWaterProgram); @@ -1138,6 +1140,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredStarProgram.unload(); gDeferredFullbrightShinyProgram.unload(); gDeferredSkinnedFullbrightShinyProgram.unload(); + gDeferredSkinnedFullbrightProgram.unload(); + gNormalMapGenProgram.unload(); for (U32 i = 0; i < LLMaterial::SHADER_COUNT*2; ++i) { @@ -1491,7 +1495,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightShinyProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightShinyProgram.mFeatures.hasGamma = true; gDeferredFullbrightShinyProgram.mFeatures.hasTransport = true; - gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); + gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = 0; gDeferredFullbrightShinyProgram.mShaderFiles.clear(); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1501,6 +1505,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { + gDeferredSkinnedFullbrightProgram.mName = "Skinned Fullbright Shader"; + gDeferredSkinnedFullbrightProgram.mFeatures.calculatesAtmospherics = true; + gDeferredSkinnedFullbrightProgram.mFeatures.hasGamma = true; + gDeferredSkinnedFullbrightProgram.mFeatures.hasTransport = true; + gDeferredSkinnedFullbrightProgram.mFeatures.hasObjectSkinning = true; + gDeferredSkinnedFullbrightProgram.mFeatures.disableTextureIndex = true; + gDeferredSkinnedFullbrightProgram.mShaderFiles.clear(); + gDeferredSkinnedFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredSkinnedFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredSkinnedFullbrightProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gDeferredSkinnedFullbrightProgram.createShader(NULL, NULL); + } + + if (success) + { gDeferredSkinnedFullbrightShinyProgram.mName = "Skinned Fullbright Shiny Shader"; gDeferredSkinnedFullbrightShinyProgram.mFeatures.calculatesAtmospherics = true; gDeferredSkinnedFullbrightShinyProgram.mFeatures.hasGamma = true; @@ -2455,6 +2474,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectSimpleProgram.mFeatures.hasAtmospherics = true; gSkinnedObjectSimpleProgram.mFeatures.hasLighting = true; gSkinnedObjectSimpleProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectSimpleProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectSimpleProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectSimpleProgram.mShaderFiles.clear(); gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -2471,6 +2491,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightProgram.mFeatures.hasTransport = true; gSkinnedObjectFullbrightProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectFullbrightProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectFullbrightProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -2487,6 +2508,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectEmissiveProgram.mFeatures.hasTransport = true; gSkinnedObjectEmissiveProgram.mFeatures.isFullbright = true; gSkinnedObjectEmissiveProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectEmissiveProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectEmissiveProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectEmissiveProgram.mShaderFiles.clear(); gSkinnedObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/emissiveSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -2503,6 +2525,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectEmissiveWaterProgram.mFeatures.hasTransport = true; gSkinnedObjectEmissiveWaterProgram.mFeatures.isFullbright = true; gSkinnedObjectEmissiveWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectEmissiveWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectEmissiveWaterProgram.mFeatures.hasWaterFog = true; gSkinnedObjectEmissiveWaterProgram.mShaderFiles.clear(); @@ -2521,6 +2544,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyProgram.mFeatures.isShiny = true; gSkinnedObjectFullbrightShinyProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightShinyProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectFullbrightShinyProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectFullbrightShinyProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightShinyProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -2537,6 +2561,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleProgram.mFeatures.hasGamma = true; gSkinnedObjectShinySimpleProgram.mFeatures.hasAtmospherics = true; gSkinnedObjectShinySimpleProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectShinySimpleProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectShinySimpleProgram.mFeatures.isShiny = true; gSkinnedObjectShinySimpleProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectShinySimpleProgram.mShaderFiles.clear(); @@ -2558,6 +2583,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectSimpleWaterProgram.mFeatures.hasWaterFog = true; gSkinnedObjectSimpleWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gSkinnedObjectSimpleWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectSimpleWaterProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectSimpleWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectSimpleWaterProgram.mShaderFiles.clear(); gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); @@ -2574,6 +2600,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightWaterProgram.mFeatures.hasTransport = true; gSkinnedObjectFullbrightWaterProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectFullbrightWaterProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectFullbrightWaterProgram.mFeatures.hasWaterFog = true; gSkinnedObjectFullbrightWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; @@ -2593,6 +2620,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isShiny = true; gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isFullbright = true; gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasWaterFog = true; gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.disableTextureIndex = true; gSkinnedObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; @@ -2611,6 +2639,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasGamma = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasAtmospherics = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.isShiny = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasWaterFog = true; gSkinnedObjectShinySimpleWaterProgram.mFeatures.disableTextureIndex = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index eb355ff16a..702a92c69c 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -366,6 +366,7 @@ extern LLGLSLShader gDeferredWLCloudProgram; extern LLGLSLShader gDeferredStarProgram; extern LLGLSLShader gDeferredFullbrightShinyProgram; extern LLGLSLShader gDeferredSkinnedFullbrightShinyProgram; +extern LLGLSLShader gDeferredSkinnedFullbrightProgram; extern LLGLSLShader gNormalMapGenProgram; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3aef88ed94..367edd21c6 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4534,34 +4534,46 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) LLMaterial* mat = te->getMaterialParams().get(); - if (mat) + if (mat && LLPipeline::sRenderDeferred) { - if (te->getFullbright()) + U8 alpha_mode = mat->getDiffuseAlphaMode(); + bool is_alpha = type == LLDrawPool::POOL_ALPHA && + (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND || + te->getColor().mV[3] < 0.999f); + + if (is_alpha) + { //this face needs alpha blending, override alpha mode + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + } + U32 mask = mat->getShaderMask(alpha_mode); + pool->addRiggedFace(facep, mask); + } + else if (mat) + { + bool fullbright = te->getFullbright(); + bool is_alpha = type == LLDrawPool::POOL_ALPHA; + U8 mode = mat->getDiffuseAlphaMode(); + bool can_be_shiny = mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE || + mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE; + + if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_MASK && te->getColor().mV[3] >= 0.999f) { - if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) - { - pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA); - } - else if (type == LLDrawPool::POOL_ALPHA) - { - pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_ALPHA); - } - else - { - pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT); - } + pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT : LLDrawPoolAvatar::RIGGED_SIMPLE); + } + else if (is_alpha || (te->getColor().mV[3] < 0.999f)) + { + pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA : LLDrawPoolAvatar::RIGGED_ALPHA); } - else if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + else if (gPipeline.canUseVertexShaders() + && LLPipeline::sRenderBump + && te->getShiny() + && can_be_shiny) { - // This feels unclean, but is the only way to get alpha masked rigged stuff to show up - // with masking correctly in both deferred and non-deferred paths. NORSPEC-191 - // - pool->addRiggedFace(facep, LLPipeline::sRenderDeferred ? LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_MASK : LLDrawPoolAvatar::RIGGED_ALPHA); + pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY : LLDrawPoolAvatar::RIGGED_SHINY); } else { - U32 mask = mat->getShaderMask(); - pool->addRiggedFace(facep, mask); + pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT : LLDrawPoolAvatar::RIGGED_SIMPLE); } } else @@ -5321,14 +5333,13 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) { - if (mat->getEnvironmentIntensity() > 0 || - te->getShiny() > 0) + if (te->getColor().mV[3] >= 0.999f) { material_pass = true; } else { - registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK); + registerFace(group, facep, LLRenderPass::PASS_ALPHA); } } else if (is_alpha) @@ -5394,7 +5405,13 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } else if (mat) { - if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + U8 mode = mat->getDiffuseAlphaMode(); + if (te->getColor().mV[3] < 0.999f) + { + mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + } + + if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) { registerFace(group, facep, fullbright ? LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK : LLRenderPass::PASS_ALPHA_MASK); } @@ -5533,7 +5550,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); - if (!force_simple && te->getBumpmap() && LLPipeline::sRenderBump) + if (!force_simple && te->getBumpmap() && !mat && LLPipeline::sRenderBump) { registerFace(group, facep, LLRenderPass::PASS_BUMP); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 984ea446fe..6dc89742ec 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -268,6 +268,8 @@ std::string gPoolNames[] = "POOL_SKY", "POOL_WL_SKY", "POOL_TREE", + "POOL_ALPHA_MASK", + "POOL_FULLBRIGHT_ALPHA_MASK", "POOL_GRASS", "POOL_INVISIBLE", "POOL_AVATAR", @@ -439,10 +441,14 @@ LLPipeline::LLPipeline() : mWaterPool(NULL), mGroundPool(NULL), mSimplePool(NULL), + mGrassPool(NULL), + mAlphaMaskPool(NULL), + mFullbrightAlphaMaskPool(NULL), mFullbrightPool(NULL), mInvisiblePool(NULL), mGlowPool(NULL), mBumpPool(NULL), + mMaterialsPool(NULL), mWLSkyPool(NULL), mLightMask(0), mLightMovingMask(0), @@ -489,6 +495,8 @@ void LLPipeline::init() //create render pass pools getPool(LLDrawPool::POOL_ALPHA); getPool(LLDrawPool::POOL_SIMPLE); + getPool(LLDrawPool::POOL_ALPHA_MASK); + getPool(LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK); getPool(LLDrawPool::POOL_GRASS); getPool(LLDrawPool::POOL_FULLBRIGHT); getPool(LLDrawPool::POOL_INVISIBLE); @@ -1591,6 +1599,14 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mGrassPool; break; + case LLDrawPool::POOL_ALPHA_MASK: + poolp = mAlphaMaskPool; + break; + + case LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK: + poolp = mFullbrightAlphaMaskPool; + break; + case LLDrawPool::POOL_FULLBRIGHT: poolp = mFullbrightPool; break; @@ -1699,14 +1715,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima alpha = color_alpha; break; default: //alpha mode set to "mask", go to alpha pool if fullbright - if (te->getFullbright()) - { - alpha = true; - } - else - { - alpha = color_alpha; // Material's alpha mode is set to none, mask, or emissive. Toss it into the opaque material draw pool. - } + alpha = color_alpha; // Material's alpha mode is set to none, mask, or emissive. Toss it into the opaque material draw pool. break; } } @@ -5487,6 +5496,32 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; + case LLDrawPool::POOL_ALPHA_MASK: + if (mAlphaMaskPool) + { + llassert(0); + llwarns << "Ignoring duplicate alpha mask pool." << llendl; + break; + } + else + { + mAlphaMaskPool = (LLRenderPass*) new_poolp; + } + break; + + case LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK: + if (mFullbrightAlphaMaskPool) + { + llassert(0); + llwarns << "Ignoring duplicate alpha mask pool." << llendl; + break; + } + else + { + mFullbrightAlphaMaskPool = (LLRenderPass*) new_poolp; + } + break; + case LLDrawPool::POOL_GRASS: if (mGrassPool) { @@ -5653,6 +5688,16 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mSimplePool = NULL; break; + case LLDrawPool::POOL_ALPHA_MASK: + llassert(mAlphaMaskPool == poolp); + mAlphaMaskPool = NULL; + break; + + case LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK: + llassert(mFullbrightAlphaMaskPool == poolp); + mFullbrightAlphaMaskPool = NULL; + break; + case LLDrawPool::POOL_GRASS: llassert(mGrassPool == poolp); mGrassPool = NULL; @@ -7145,7 +7190,7 @@ void LLPipeline::renderMaskedObjects(U32 type, U32 mask, BOOL texture, BOOL batc assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; - mAlphaPool->pushMaskBatches(type, mask, texture, batch_texture); + mAlphaMaskPool->pushMaskBatches(type, mask, texture, batch_texture); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; } @@ -8663,6 +8708,8 @@ void LLPipeline::renderDeferredLighting() LLPipeline::RENDER_TYPE_PASS_INVISIBLE, LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_ALPHA_MASK, + LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, END_RENDER_TYPES); renderGeomPostDeferred(*LLViewerCamera::getInstance()); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 4aee8f14d6..a8362953b4 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -434,6 +434,8 @@ public: RENDER_TYPE_TERRAIN = LLDrawPool::POOL_TERRAIN, RENDER_TYPE_SIMPLE = LLDrawPool::POOL_SIMPLE, RENDER_TYPE_GRASS = LLDrawPool::POOL_GRASS, + RENDER_TYPE_ALPHA_MASK = LLDrawPool::POOL_ALPHA_MASK, + RENDER_TYPE_FULLBRIGHT_ALPHA_MASK = LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK, RENDER_TYPE_FULLBRIGHT = LLDrawPool::POOL_FULLBRIGHT, RENDER_TYPE_BUMP = LLDrawPool::POOL_BUMP, RENDER_TYPE_MATERIALS = LLDrawPool::POOL_MATERIALS, @@ -807,6 +809,8 @@ protected: LLDrawPool* mGroundPool; LLRenderPass* mSimplePool; LLRenderPass* mGrassPool; + LLRenderPass* mAlphaMaskPool; + LLRenderPass* mFullbrightAlphaMaskPool; LLRenderPass* mFullbrightPool; LLDrawPool* mInvisiblePool; LLDrawPool* mGlowPool; |