diff options
Diffstat (limited to 'indra')
43 files changed, 471 insertions, 340 deletions
diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 3145891393..b294288c64 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -57,7 +57,7 @@ public: static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; - static const U8 DEFAULT_ENV_INTENSITY = ((U8)(0.05f * 255)); + static const U8 DEFAULT_ENV_INTENSITY = 0; LLMaterial(); LLMaterial(const LLSD& material_data); diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 5429489075..81a97c7661 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -216,6 +216,11 @@ PFNGLGETQUERYIVARBPROC glGetQueryivARB = NULL; PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB = NULL; PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB = NULL; +// GL_ARB_timer_query +PFNGLQUERYCOUNTERPROC glQueryCounter = NULL; +PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v = NULL; +PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v = NULL; + // GL_ARB_point_parameters PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB = NULL; PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB = NULL; @@ -421,6 +426,7 @@ LLGLManager::LLGLManager() : mHasFragmentShader(FALSE), mNumTextureImageUnits(0), mHasOcclusionQuery(FALSE), + mHasTimerQuery(FALSE), mHasOcclusionQuery2(FALSE), mHasPointParameters(FALSE), mHasDrawBuffers(FALSE), @@ -956,6 +962,7 @@ void LLGLManager::initExtensions() mHasARBEnvCombine = ExtensionExists("GL_ARB_texture_env_combine", gGLHExts.mSysExts); mHasCompressedTextures = glh_init_extensions("GL_ARB_texture_compression"); mHasOcclusionQuery = ExtensionExists("GL_ARB_occlusion_query", gGLHExts.mSysExts); + mHasTimerQuery = ExtensionExists("GL_ARB_timer_query", gGLHExts.mSysExts); mHasOcclusionQuery2 = ExtensionExists("GL_ARB_occlusion_query2", gGLHExts.mSysExts); mHasVertexBufferObject = ExtensionExists("GL_ARB_vertex_buffer_object", gGLHExts.mSysExts); mHasVertexArrayObject = ExtensionExists("GL_ARB_vertex_array_object", gGLHExts.mSysExts); @@ -1271,6 +1278,13 @@ void LLGLManager::initExtensions() glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectivARB"); glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectuivARB"); } + if (mHasTimerQuery) + { + llinfos << "initExtensions() TimerQuery-related procs..." << llendl; + glQueryCounter = (PFNGLQUERYCOUNTERPROC) GLH_EXT_GET_PROC_ADDRESS("glQueryCounter"); + glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjecti64v"); + glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectui64v"); + } if (mHasPointParameters) { llinfos << "initExtensions() PointParameters-related procs..." << llendl; diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 767d49cbf2..60597fd090 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -98,6 +98,7 @@ public: BOOL mHasFragmentShader; S32 mNumTextureImageUnits; BOOL mHasOcclusionQuery; + BOOL mHasTimerQuery; BOOL mHasOcclusionQuery2; BOOL mHasPointParameters; BOOL mHasDrawBuffers; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 509de51f4d..dace572953 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -116,6 +116,11 @@ extern PFNGLGETQUERYIVARBPROC glGetQueryivARB; extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; +// GL_ARB_timer_query +extern PFNGLQUERYCOUNTERPROC glQueryCounter; +extern PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v; +extern PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; + // GL_ARB_point_parameters extern PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB; extern PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB; @@ -378,6 +383,11 @@ extern PFNGLGETQUERYIVARBPROC glGetQueryivARB; extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; +// GL_ARB_timer_query +extern PFNGLQUERYCOUNTERPROC glQueryCounter; +extern PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v; +extern PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; + // GL_ARB_point_parameters extern PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB; extern PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB; @@ -619,6 +629,12 @@ extern PFNGLGETQUERYIVARBPROC glGetQueryivARB; extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; +// GL_ARB_timer_query +extern PFNGLQUERYCOUNTERPROC glQueryCounter; +extern PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v; +extern PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; + + // GL_ARB_point_parameters extern PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB; extern PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB; diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 39ad9b9e9b..191c9862f0 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -53,6 +53,12 @@ GLhandleARB LLGLSLShader::sCurBoundShader = 0; LLGLSLShader* LLGLSLShader::sCurBoundShaderPtr = NULL; S32 LLGLSLShader::sIndexedTextureChannels = 0; bool LLGLSLShader::sNoFixedFunction = false; +bool LLGLSLShader::sProfileEnabled = false; +std::set<LLGLSLShader*> LLGLSLShader::sInstances; +U64 LLGLSLShader::sTotalTimeElapsed = 0; +U32 LLGLSLShader::sTotalTrianglesDrawn = 0; +U64 LLGLSLShader::sTotalSamplesDrawn = 0; +U32 LLGLSLShader::sTotalDrawCalls = 0; //UI shader -- declared here so llui_libtest will link properly LLGLSLShader gUIProgram; @@ -87,19 +93,188 @@ LLShaderFeatures::LLShaderFeatures() //=============================== // LLGLSL Shader implementation //=============================== + +//static +void LLGLSLShader::initProfile() +{ + sProfileEnabled = true; + sTotalTimeElapsed = 0; + sTotalTrianglesDrawn = 0; + sTotalSamplesDrawn = 0; + sTotalDrawCalls = 0; + + for (std::set<LLGLSLShader*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter) + { + (*iter)->clearStats(); + } +} + + +struct LLGLSLShaderCompareTimeElapsed +{ + bool operator()(const LLGLSLShader* const& lhs, const LLGLSLShader* const& rhs) + { + return lhs->mTimeElapsed < rhs->mTimeElapsed; + } +}; + +//static +void LLGLSLShader::finishProfile() +{ + sProfileEnabled = false; + + std::vector<LLGLSLShader*> sorted; + + for (std::set<LLGLSLShader*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter) + { + sorted.push_back(*iter); + } + + std::sort(sorted.begin(), sorted.end(), LLGLSLShaderCompareTimeElapsed()); + + for (std::vector<LLGLSLShader*>::iterator iter = sorted.begin(); iter != sorted.end(); ++iter) + { + (*iter)->dumpStats(); + } + + llinfos << "-----------------------------------" << llendl; + llinfos << "Total rendering time: " << llformat("%.4f ms", sTotalTimeElapsed/1000000.f) << llendl; + llinfos << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn/1000000.f) << llendl; + llinfos << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn/1000000.f) << llendl; +} + +void LLGLSLShader::clearStats() +{ + mTrianglesDrawn = 0; + mTimeElapsed = 0; + mSamplesDrawn = 0; + mDrawCalls = 0; +} + +void LLGLSLShader::dumpStats() +{ + if (mDrawCalls > 0) + { + llinfos << "=============================================" << llendl; + llinfos << mName << llendl; + for (U32 i = 0; i < mShaderFiles.size(); ++i) + { + llinfos << mShaderFiles[i].first << llendl; + } + llinfos << "=============================================" << llendl; + + F32 ms = mTimeElapsed/1000000.f; + F32 seconds = ms/1000.f; + + F32 pct_tris = (F32) mTrianglesDrawn/(F32)sTotalTrianglesDrawn*100.f; + F32 tris_sec = (F32) (mTrianglesDrawn/1000000.0); + tris_sec /= seconds; + + F32 pct_samples = (F32) ((F64)mSamplesDrawn/(F64)sTotalSamplesDrawn)*100.f; + F32 samples_sec = (F32) mSamplesDrawn/1000000000.0; + samples_sec /= seconds; + + F32 pct_calls = (F32) mDrawCalls/(F32)sTotalDrawCalls*100.f; + U32 avg_batch = mTrianglesDrawn/mDrawCalls; + + llinfos << "Triangles Drawn: " << mTrianglesDrawn << " " << llformat("(%.2f pct of total, %.3f million/sec)", pct_tris, tris_sec ) << llendl; + llinfos << "Draw Calls: " << mDrawCalls << " " << llformat("(%.2f pct of total, avg %d tris/call)", pct_calls, avg_batch) << llendl; + llinfos << "SamplesDrawn: " << mSamplesDrawn << " " << llformat("(%.2f pct of total, %.3f billion/sec)", pct_samples, samples_sec) << llendl; + llinfos << "Time Elapsed: " << mTimeElapsed << " " << llformat("(%.2f pct of total, %.5f ms)\n", (F32) ((F64)mTimeElapsed/(F64)sTotalTimeElapsed)*100.f, ms) << llendl; + } +} + +//static +void LLGLSLShader::startProfile() +{ + if (sProfileEnabled && sCurBoundShaderPtr) + { + sCurBoundShaderPtr->placeProfileQuery(); + } + +} + +//static +void LLGLSLShader::stopProfile(U32 count, U32 mode) +{ + if (sProfileEnabled) + { + sCurBoundShaderPtr->readProfileQuery(count, mode); + } +} + +void LLGLSLShader::placeProfileQuery() +{ +#if !LL_DARWIN + if (mTimerQuery == 0) + { + glGenQueriesARB(1, &mTimerQuery); + } + + glBeginQueryARB(GL_SAMPLES_PASSED, 1); + glBeginQueryARB(GL_TIME_ELAPSED, mTimerQuery); +#endif +} + +void LLGLSLShader::readProfileQuery(U32 count, U32 mode) +{ +#if !LL_DARWIN + glEndQueryARB(GL_TIME_ELAPSED); + glEndQueryARB(GL_SAMPLES_PASSED); + + U64 time_elapsed = 0; + glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT, &time_elapsed); + + U64 samples_passed = 0; + glGetQueryObjectui64v(1, GL_QUERY_RESULT, &samples_passed); + + sTotalTimeElapsed += time_elapsed; + mTimeElapsed += time_elapsed; + + sTotalSamplesDrawn += samples_passed; + mSamplesDrawn += samples_passed; + + U32 tri_count = 0; + switch (mode) + { + case LLRender::TRIANGLES: tri_count = count/3; break; + case LLRender::TRIANGLE_FAN: tri_count = count-2; break; + case LLRender::TRIANGLE_STRIP: tri_count = count-2; break; + default: tri_count = count; break; //points lines etc just use primitive count + } + + mTrianglesDrawn += tri_count; + sTotalTrianglesDrawn += tri_count; + + sTotalDrawCalls++; + mDrawCalls++; +#endif +} + + + LLGLSLShader::LLGLSLShader() : mProgramObject(0), mAttributeMask(0), + mTotalUniformSize(0), mActiveTextureChannels(0), mShaderLevel(0), mShaderGroup(SG_DEFAULT), - mUniformsDirty(FALSE) + mUniformsDirty(FALSE), + mTimerQuery(0) { + +} +LLGLSLShader::~LLGLSLShader() +{ + } void LLGLSLShader::unload() { + sInstances.erase(this); + stop_glerror(); mAttribute.clear(); mTexture.clear(); @@ -138,6 +313,8 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes, U32 varying_count, const char** varyings) { + sInstances.insert(this); + //reloading, reset matrix hash values for (U32 i = 0; i < LLRender::NUM_MATRIX_MODES; ++i) { @@ -333,11 +510,56 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms) GLenum type; GLsizei length; - GLint size; + GLint size = -1; char name[1024]; /* Flawfinder: ignore */ name[0] = 0; + glGetActiveUniformARB(mProgramObject, index, 1024, &length, &size, &type, (GLcharARB *)name); +#if !LL_DARWIN + if (size > 0) + { + switch(type) + { + case GL_FLOAT_VEC2: size *= 2; break; + case GL_FLOAT_VEC3: size *= 3; break; + case GL_FLOAT_VEC4: size *= 4; break; + case GL_DOUBLE: size *= 2; break; + case GL_DOUBLE_VEC2: size *= 2; break; + case GL_DOUBLE_VEC3: size *= 6; break; + case GL_DOUBLE_VEC4: size *= 8; break; + case GL_INT_VEC2: size *= 2; break; + case GL_INT_VEC3: size *= 3; break; + case GL_INT_VEC4: size *= 4; break; + case GL_UNSIGNED_INT_VEC2: size *= 2; break; + case GL_UNSIGNED_INT_VEC3: size *= 3; break; + case GL_UNSIGNED_INT_VEC4: size *= 4; break; + case GL_BOOL_VEC2: size *= 2; break; + case GL_BOOL_VEC3: size *= 3; break; + case GL_BOOL_VEC4: size *= 4; break; + case GL_FLOAT_MAT2: size *= 4; break; + case GL_FLOAT_MAT3: size *= 9; break; + case GL_FLOAT_MAT4: size *= 16; break; + case GL_FLOAT_MAT2x3: size *= 6; break; + case GL_FLOAT_MAT2x4: size *= 8; break; + case GL_FLOAT_MAT3x2: size *= 6; break; + case GL_FLOAT_MAT3x4: size *= 12; break; + case GL_FLOAT_MAT4x2: size *= 8; break; + case GL_FLOAT_MAT4x3: size *= 12; break; + case GL_DOUBLE_MAT2: size *= 8; break; + case GL_DOUBLE_MAT3: size *= 18; break; + case GL_DOUBLE_MAT4: size *= 32; break; + case GL_DOUBLE_MAT2x3: size *= 12; break; + case GL_DOUBLE_MAT2x4: size *= 16; break; + case GL_DOUBLE_MAT3x2: size *= 12; break; + case GL_DOUBLE_MAT3x4: size *= 24; break; + case GL_DOUBLE_MAT4x2: size *= 16; break; + case GL_DOUBLE_MAT4x3: size *= 24; break; + } + mTotalUniformSize += size; + } +#endif + S32 location = glGetUniformLocationARB(mProgramObject, name); if (location != -1) { @@ -408,6 +630,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<string> * uniforms) { BOOL res = TRUE; + mTotalUniformSize = 0; mActiveTextureChannels = 0; mUniform.clear(); mUniformMap.clear(); @@ -431,6 +654,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<string> * uniforms) unbind(); + LL_DEBUGS("ShaderLoading") << "Total Uniform Size: " << mTotalUniformSize << llendl; return res; } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 725a7e2573..d67ece018f 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -67,14 +67,29 @@ public: SG_WATER }; + static std::set<LLGLSLShader*> sInstances; + static bool sProfileEnabled; + LLGLSLShader(); + ~LLGLSLShader(); static GLhandleARB sCurBoundShader; static LLGLSLShader* sCurBoundShaderPtr; static S32 sIndexedTextureChannels; static bool sNoFixedFunction; + static void initProfile(); + static void finishProfile(); + + static void startProfile(); + static void stopProfile(U32 count, U32 mode); + void unload(); + void clearStats(); + void dumpStats(); + void placeProfileQuery(); + void readProfileQuery(U32 count, U32 mode); + BOOL createShader(std::vector<std::string> * attributes, std::vector<std::string> * uniforms, U32 varying_count = 0, @@ -157,6 +172,7 @@ public: std::map<std::string, GLint> mUniformMap; //lookup map of uniform name to uniform location std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value std::vector<GLint> mTexture; + S32 mTotalUniformSize; S32 mActiveTextureChannels; S32 mShaderLevel; S32 mShaderGroup; @@ -165,6 +181,17 @@ public: std::vector< std::pair< std::string, GLenum > > mShaderFiles; std::string mName; boost::unordered_map<std::string, std::string> mDefines; + + //statistcis for profiling shader performance + U32 mTimerQuery; + U64 mTimeElapsed; + static U64 sTotalTimeElapsed; + U32 mTrianglesDrawn; + static U32 sTotalTrianglesDrawn; + U64 mSamplesDrawn; + static U64 sTotalSamplesDrawn; + U32 mDrawCalls; + static U32 sTotalDrawCalls; }; //UI shader (declared here so llui_libtest will link properly) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 29fe5400a3..dc6e158034 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -613,8 +613,9 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con glVertexPointer(3, GL_FLOAT, 0, pos[0].mV); glNormalPointer(GL_FLOAT, 0, norm[0].mV); } - + LLGLSLShader::startProfile(); glDrawArrays(sGLMode[mode], 0, count); + LLGLSLShader::stopProfile(count, mode); } //static @@ -651,7 +652,9 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto glVertexPointer(3, GL_FLOAT, 16, pos); } + LLGLSLShader::startProfile(); glDrawElements(sGLMode[mode], num_indices, GL_UNSIGNED_SHORT, indicesp); + LLGLSLShader::stopProfile(num_indices, mode); } void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const @@ -751,9 +754,14 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi U16* idx = ((U16*) getIndicesPointer())+indices_offset; stop_glerror(); + LLGLSLShader::startProfile(); glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, idx); + LLGLSLShader::stopProfile(count, mode); stop_glerror(); + + + placeFence(); } @@ -797,8 +805,10 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const } stop_glerror(); + LLGLSLShader::startProfile(); glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, ((U16*) getIndicesPointer()) + indices_offset); + LLGLSLShader::stopProfile(count, mode); stop_glerror(); placeFence(); } @@ -838,7 +848,9 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const } stop_glerror(); + LLGLSLShader::startProfile(); glDrawArrays(sGLMode[mode], first, count); + LLGLSLShader::stopProfile(count, mode); stop_glerror(); placeFence(); } @@ -2211,7 +2223,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if ((data_mask & required_mask) != required_mask) { - llerrs << "Shader consumption mismatches data provision." << llendl; + llwarns << "Shader consumption mismatches data provision." << llendl; } } } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index eb5c9cc5c0..84b2bde206 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8072,7 +8072,7 @@ <key>Type</key> <string>Boolean</string> <key>Value</key> - <integer>0</integer> + <integer>1</integer> </map> <key>RenderDebugNormalScale</key> <map> diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 00717cd6a9..e8cbf318a1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,11 +83,11 @@ uniform float shadow_offset; vec3 calcDirectionalLight(vec3 n, vec3 l) { - float a = pow(max(dot(n,l),0.0), 0.7); + float a = pow(max(dot(n,l),0.0), 0.7); return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -114,7 +114,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(pow(dot(n, lv), 0.7), 0.0); } - return da; + return vec3(da,da,da); } void main() @@ -125,7 +125,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); #if INDEX_MODE == INDEXED - vec4 diff = diffuseLookup(vary_texcoord0.xy); + vec4 diff= diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif @@ -136,15 +136,14 @@ void main() float vertex_color_alpha = vertex_color.a; #endif - vec3 normal = vary_norm; - normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; + vec3 normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; normal = vec3(dot(normal.xyz, vary_rotation[0]), dot(normal.xyz, vary_rotation[1]), dot(normal.xyz, vary_rotation[2])); - + vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; + dlight = dlight * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); vec4 color = diff * col; @@ -152,12 +151,11 @@ void main() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - vec3 light_col = vec3(0,0,0); + col = vec4(0,0,0,0); + + #define LIGHT_LOOP(i) \ + col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); -#ifdef MAC_GEFORCE_HACK - #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - LIGHT_LOOP(1) LIGHT_LOOP(2) LIGHT_LOOP(3) @@ -165,14 +163,8 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } -#endif - color.rgb += diff.rgb * vary_pointlight_col * light_col; + color.rgb += diff.rgb * vary_pointlight_col * col.rgb; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl index e872dadcc1..cccc7275ab 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl @@ -56,13 +56,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -float calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = pow(max(dot(n,l),0.0), 0.7); - return a; + return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -89,7 +89,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(pow(dot(n, lv), 0.7), 0.0); } - return da; + return vec3(da,da,da); } vec4 getPosition(vec2 pos_screen) @@ -126,7 +126,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#if MAC_GEFORCE_HACK + #define LIGHT_LOOP(i) \ light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -137,12 +137,7 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } -#endif + color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl index 81961d7746..3f90600ace 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl @@ -39,7 +39,12 @@ void main() mat = modelview_matrix * mat; vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz; + vec4 p = projection_matrix * vec4(pos, 1.0); +#if !DEPTH_CLAMP p.z = max(p.z, -p.w+0.01); gl_Position = p; +#else + gl_Position = p; +#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 3686f2f647..b809b73973 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl @@ -31,12 +31,16 @@ out vec4 frag_color; uniform sampler2D diffuseMap; +#if !DEPTH_CLAMP VARYING vec4 post_pos; +#endif void main() { frag_color = vec4(1,1,1,1); +#if !DEPTH_CLAMP gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl index 23feb09d72..bde1ad4e9f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl @@ -31,7 +31,9 @@ ATTRIBUTE vec3 position; ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; +#if !DEPTH_CLAMP VARYING vec4 post_pos; +#endif void main() { @@ -51,9 +53,13 @@ void main() norm = normalize(norm); pos = projection_matrix * pos; +#if !DEPTH_CLAMP post_pos = pos; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index 40b980bf51..a2c3ec3355 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -46,7 +46,7 @@ void main() frag_data[0] = vec4(col, 0.0); frag_data[1] = vertex_color.aaaa; // spec - //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested + frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl index 76d29b1df7..3c026796c8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl @@ -47,6 +47,6 @@ void main() passTextureIndex(); vary_normal = normalize(normal_matrix * normal); - + vertex_color = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 5329ae9dd7..3bd433c283 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -127,9 +127,9 @@ void main() dist_atten *= noise; - float lit = da * dist_atten; + float lit = pow(da, 0.7) * dist_atten; - lit = pow(lit,0.7); + vec3 col = light_col[i].rgb*lit*diff; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 9746218ea6..959a85330e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -201,9 +201,7 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); + lit = pow(da, 0.7) * dist_atten * noise; col = lcol*lit*diff_tex; amb_da += (da*0.5)*proj_ambiance; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 27863b0095..6976fc7bd9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -111,10 +111,8 @@ void main() vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - float lit = da * dist_atten * noise; + float lit = pow(da, 0.7) * dist_atten * noise; - lit = pow(lit, 0.7); - col = color.rgb*lit*col; vec4 spec = texture2DRect(specularRect, frag.xy); diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index bced4a5577..91a96977f0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -31,8 +31,12 @@ out vec4 frag_color; uniform sampler2D diffuseMap; +#if !DEPTH_CLAMP VARYING float pos_zd2; +#endif + VARYING float pos_w; + VARYING float target_pos_x; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -56,5 +60,7 @@ void main() frag_color = vec4(1,1,1,1); +#if !DEPTH_CLAMP gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); +#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl index c1f2d90712..11411a605c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl @@ -31,8 +31,12 @@ ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; +#if !DEPTH_CLAMP VARYING float pos_zd2; +#endif + VARYING float pos_w; + VARYING float target_pos_x; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -45,10 +49,16 @@ void main() vec4 pre_pos = vec4(position.xyz, 1.0); vec4 pos = modelview_projection_matrix * pre_pos; target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + pos_w = pos.w; + +#if !DEPTH_CLAMP pos_zd2 = pos.z * 0.5; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif passTextureIndex(); diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl index 6195e2f1ec..ef153dfc5b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl @@ -27,7 +27,9 @@ uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; +#if !DEPTH_CLAMP VARYING vec4 post_pos; +#endif uniform vec3 box_center; uniform vec3 box_size; @@ -37,8 +39,12 @@ void main() //transform vertex vec3 p = position*box_size+box_center; vec4 pos = modelview_projection_matrix*vec4(p.xyz, 1.0); - + +#if !DEPTH_CLAMP post_pos = pos; - + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl index 7e55fdc12a..3d1b182875 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl @@ -29,11 +29,16 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +#if !DEPTH_CLAMP VARYING vec4 post_pos; +#endif void main() { frag_color = vec4(1,1,1,1); +#if !DEPTH_CLAMP gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +#endif + } diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl index 8b46e81f90..cc77a4cea0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl @@ -27,14 +27,20 @@ uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; +#if !DEPTH_CLAMP VARYING vec4 post_pos; +#endif void main() { //transform vertex vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0); +#if !DEPTH_CLAMP post_pos = pos; - + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index d7f0ab6d8e..918cdce040 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -204,9 +204,7 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); + lit = pow(da, 0.7) * dist_atten * noise; col = lcol*lit*diff_tex; amb_da += (da*0.5)*proj_ambiance; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 111e88c6e9..5faa94fb03 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -45,6 +45,7 @@ uniform sampler2D diffuseMap; #endif uniform vec2 screen_res; +uniform vec2 shadow_res; vec3 atmosLighting(vec3 light); vec3 scaleSoftClip(vec3 light); @@ -66,7 +67,6 @@ VARYING vec4 vertex_color; uniform mat4 shadow_matrix[6]; uniform vec4 shadow_clip; -uniform vec2 shadow_res; uniform float shadow_bias; uniform mat4 inv_proj; @@ -84,7 +84,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -111,7 +111,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(pow(dot(n, lv), 0.7), 0.0); } - return da; + return vec3(da,da,da); } float pcfShadow(sampler2DShadow shadowMap, vec4 stc) @@ -204,10 +204,11 @@ void main() shadow = 1.0; } -#if INDEX_MODE == INDEXED - vec4 diff = diffuseLookup(vary_texcoord0.xy); + vec4 diff; +#if INDEX_MODE == INDEXED + diff = diffuseLookup(vary_texcoord0.xy); #else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif #if INDEX_MODE == NON_INDEXED_NO_COLOR @@ -216,7 +217,7 @@ void main() float vertex_color_alpha = vertex_color.a; #endif - vec3 normal = vary_norm; + vec3 normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); @@ -228,11 +229,10 @@ void main() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - vec3 light_col = vec3(0,0,0); + col = vec4(0,0,0,0); -#ifdef MAC_GEFORCE_HACK #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -241,14 +241,8 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } -#endif - color.rgb += diff.rgb * vary_pointlight_col * light_col; + color.rgb += diff.rgb * vary_pointlight_col * col.rgb; frag_color = vec4(1,0,1,1); //frag_color = color; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl index 39a5a9894d..9670d59399 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -70,7 +70,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -97,7 +97,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(pow(dot(n, lv), 0.7), 0.0); } - return da; + return vec3(da,da,da); } vec4 getPosition(vec2 pos_screen) @@ -217,7 +217,6 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#if MAC_GEFORCE_HACK #define LIGHT_LOOP(i) \ light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -228,12 +227,6 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } -#endif color.rgb += diff.rgb * vary_pointlight_col * light_col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl index 566aefea6a..fae279fba0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -72,7 +72,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a, a, a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -99,7 +99,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(pow(dot(n, lv), 0.7), 0.0); } - return da; + return vec3(da,da,da); } vec4 getPosition(vec2 pos_screen) @@ -224,8 +224,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#if MAC_GEFORCE_HACK - #define LIGHT_LOOP(i) + #define LIGHT_LOOP(i) \ light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) @@ -235,12 +234,7 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } -#endif + color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index b3ab8fd510..90b6856c5c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -213,9 +213,7 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); + lit = pow(da,0.7) * dist_atten * noise; col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 43fc5dbc5e..5fd6f0afb7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -214,9 +214,7 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); + lit = pow(da, 0.7) * dist_atten * noise; col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 3ce2d4fb1c..3f041a3a85 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -520,8 +520,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) // 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->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); if (params.mNormalMap) @@ -542,21 +541,15 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); } } - } else if (current_shader == simple_shader) + + } else if (LLPipeline::sRenderDeferred && current_shader && (current_shader == simple_shader)) { - // No material. Propegate with default parameters. - if (LLPipeline::sRenderDeferred) - { - current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, 0.0f, 0.0f, 0.0f, 0.0f); - - current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, 0.0f); - - LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); - - LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); - } + current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, 1.0f, 1.0f, 1.0f, 1.0f); + current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, 0.0f); + LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize); + current_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize); + current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); } if (params.mGroup) diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 0518c3ac79..612741e57c 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -276,11 +276,7 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha() void LLDrawPoolAvatar::beginDeferredRiggedAlpha() { -#if LL_DARWIN - sVertexProgram = gGLManager.mIsMobileGF ? &gDeferredSkinnedAlphaProgramMac : &gDeferredSkinnedAlphaProgram; -#else sVertexProgram = &gDeferredSkinnedAlphaProgram; -#endif gPipeline.bindDeferredShader(*sVertexProgram); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gPipeline.enableLightsDynamic(); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f91f1f7d3a..be88cb6ab6 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -291,55 +291,10 @@ void LLPanelFace::sendTexture() } LLSelectMgr::getInstance()->selectionSetImage(id); } - - mIsAlpha = FALSE; - LLGLenum image_format; - struct f2 : public LLSelectedTEGetFunctor<LLGLenum> - { - LLGLenum get(LLViewerObject* object, S32 te_index) - { - LLGLenum image_format = GL_RGB; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) image_format = image->getPrimaryFormat(); - return image_format; - } - } func2; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); - - mIsAlpha = FALSE; - switch (image_format) - { - case GL_RGBA: - case GL_ALPHA: - { - mIsAlpha = TRUE; - } - break; - - case GL_RGB: break; - default: - { - llwarns << "Unexpected tex format in LLPanelFace...resorting to no alpha" << llendl; - } - break; - } - - LLComboBox* comboAlphaMode = getChild<LLComboBox>("combobox alphamode"); - if (comboAlphaMode) - { - U32 alpha_mode = comboAlphaMode->getCurrentIndex(); - if (mIsAlpha && (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE)) - { - alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; - } - comboAlphaMode->selectNthItem(alpha_mode); - } - } void LLPanelFace::sendBump() -{ +{ LLComboBox* mComboBumpiness = getChild<LLComboBox>("combobox bumpiness"); if(!mComboBumpiness)return; U32 bumpiness = mComboBumpiness->getCurrentIndex(); @@ -834,7 +789,7 @@ void LLPanelFace::getState() } } alpha_get_func; - U8 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + U8 alpha_mode = 1; LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &alpha_get_func, alpha_mode); { @@ -843,13 +798,10 @@ void LLPanelFace::getState() if (combobox_alphamode) { - // Should never want to reflect something other than the correct state - // if it's supposed to be set to NONE, that should be enforced elsewhere - // - //if (!mIsAlpha) - //{ - // alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; - //} + if (!mIsAlpha) + { + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + } combobox_alphamode->selectNthItem(alpha_mode); } @@ -1823,18 +1775,9 @@ void LLPanelFace::updateMaterial() bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - LLUUID norm_map_id = getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID(); - LLUUID spec_map_id = getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID(); - - bool doing_diffuse_alpha = (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - bool doing_bumps = (bumpiness == BUMPY_TEXTURE) || !norm_map_id.isNull(); - bool doing_shiny = (shininess == SHINY_TEXTURE) || !spec_map_id.isNull(); - - doing_diffuse_alpha = doing_diffuse_alpha && mIsAlpha; - - if (doing_diffuse_alpha - || doing_bumps - || doing_shiny) + if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) + || (bumpiness == BUMPY_TEXTURE) + || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. bool new_material = false; @@ -1843,10 +1786,11 @@ void LLPanelFace::updateMaterial() new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); } - - mMaterial->setDiffuseAlphaMode(alpha_mode); + + mMaterial->setDiffuseAlphaMode(getChild<LLComboBox>("combobox alphamode")->getCurrentIndex()); mMaterial->setAlphaMaskCutoff((U8)(getChild<LLUICtrl>("maskcutoff")->getValue().asInteger())); - + + LLUUID norm_map_id = getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID(); if (!norm_map_id.isNull()) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; @@ -1874,6 +1818,8 @@ void LLPanelFace::updateMaterial() mMaterial->setNormalRepeat(1.0f,1.0f); mMaterial->setNormalRotation(0.0f); } + + LLUUID spec_map_id = getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID(); if (!spec_map_id.isNull()) { diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f42586c715..f6e282ad87 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -89,7 +89,7 @@ class LLOcclusionQueryPool : public LLGLNamePool public: LLOcclusionQueryPool() { - mCurQuery = 1; + mCurQuery = 2; //1 is reserved for LLGLSLShader } protected: diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 426eaa1ce4..7c0be549df 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -750,7 +750,7 @@ class LLVolumeGeometryManager: public LLGeometryManager virtual void rebuildGeom(LLSpatialGroup* group); virtual void rebuildMesh(LLSpatialGroup* group); virtual void getGeometry(LLSpatialGroup* group); - void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE); + void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE, BOOL no_materials = FALSE); void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type); }; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index abeef7097a..1e5c5097ea 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -98,6 +98,7 @@ BOOL gDepthDirty = FALSE; BOOL gResizeScreenTexture = FALSE; BOOL gWindowResized = FALSE; BOOL gSnapshot = FALSE; +BOOL gShaderProfileFrame = FALSE; U32 gRecentFrameCount = 0; // number of 'recent' frames LLFrameTimer gRecentFPSTime; @@ -340,6 +341,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) return; } + + if (gShaderProfileFrame) + { + LLGLSLShader::initProfile(); + } + //LLGLState::verify(FALSE); ///////////////////////////////////////////////// @@ -1018,6 +1025,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); gShiftFrame = false; + + if (gShaderProfileFrame) + { + gShaderProfileFrame = FALSE; + LLGLSLShader::finishProfile(); + } } void render_hud_attachments() diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 84f6248a81..2735e908cd 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -147,6 +147,8 @@ void handle_test_load_url(void*); //extern BOOL gDebugAvatarRotation; extern BOOL gDebugClicks; extern BOOL gDebugWindowProc; +extern BOOL gShaderProfileFrame; + //extern BOOL gDebugTextEditorTips; //extern BOOL gDebugSelectMgr; @@ -7038,6 +7040,15 @@ class LLAdvancedClickRenderShadowOption: public view_listener_t } }; +class LLAdvancedClickRenderProfile: public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + gShaderProfileFrame = TRUE; + return true; + } +}; + void menu_toggle_attached_lights(void* user_data) { LLPipeline::sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); @@ -8473,7 +8484,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedHandleAttachedLightParticles(), "Advanced.HandleAttachedLightParticles"); view_listener_t::addMenu(new LLAdvancedCheckRenderShadowOption(), "Advanced.CheckRenderShadowOption"); view_listener_t::addMenu(new LLAdvancedClickRenderShadowOption(), "Advanced.ClickRenderShadowOption"); - + view_listener_t::addMenu(new LLAdvancedClickRenderProfile(), "Advanced.ClickRenderProfile"); #ifdef TOGGLE_HACKED_GODLIKE_VIEWER view_listener_t::addMenu(new LLAdvancedHandleToggleHackedGodmode(), "Advanced.HandleToggleHackedGodmode"); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 40027672cc..d30fe50ac8 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1413,9 +1413,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredAlphaProgram.addPermutation("INDEX_MODE", "1"); - gDeferredAlphaProgram.addPermutation("HAS_SKIN", "0"); - gDeferredAlphaProgram.addPermutation("IS_AVATAR_SKIN", "0"); + success = gDeferredAlphaProgram.createShader(NULL, NULL); // Hack @@ -1503,6 +1501,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); success = gDeferredShadowProgram.createShader(NULL, NULL); } @@ -1512,6 +1511,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowCubeProgram.mShaderFiles.clear(); gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowCubeV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredShadowCubeProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredShadowCubeProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredShadowCubeProgram.createShader(NULL, NULL); } @@ -1523,6 +1523,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowAlphaMaskProgram.mShaderFiles.clear(); gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredShadowAlphaMaskProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredShadowAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredShadowAlphaMaskProgram.createShader(NULL, NULL); } @@ -1534,6 +1535,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarShadowProgram.mShaderFiles.clear(); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAvatarShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredAvatarShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarShadowProgram.createShader(NULL, &mAvatarUniforms); } @@ -1545,6 +1547,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAttachmentShadowProgram.mShaderFiles.clear(); gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAttachmentShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredAttachmentShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredAttachmentShadowProgram.createShader(NULL, NULL); } @@ -1583,13 +1586,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true; gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true; gDeferredAvatarAlphaProgram.mShaderFiles.clear(); - 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.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.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredAvatarAlphaProgram.addPermutation("INDEX_MODE", "3"); - gDeferredAvatarAlphaProgram.addPermutation("HAS_SKIN", "0"); - gDeferredAvatarAlphaProgram.addPermutation("IS_AVATAR_SKIN", "1"); - + success = gDeferredAvatarAlphaProgram.createShader(NULL, &mAvatarUniforms); gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 38310ed7cf..e9283d8bad 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -331,9 +331,6 @@ extern LLGLSLShader gDeferredNonIndexedDiffuseProgram; extern LLGLSLShader gDeferredSkinnedDiffuseProgram; extern LLGLSLShader gDeferredSkinnedBumpProgram; extern LLGLSLShader gDeferredSkinnedAlphaProgram; -#if LL_DARWIN -extern LLGLSLShader gDeferredSkinnedAlphaProgramMac; -#endif extern LLGLSLShader gDeferredBumpProgram; extern LLGLSLShader gDeferredTerrainProgram; extern LLGLSLShader gDeferredTreeProgram; diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 6687ce432f..3d9c4c59b3 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -1085,132 +1085,6 @@ void LLVOTree::calcNumVerts(U32& vert_count, U32& index_count, S32 trunk_LOD, S3 } } -U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha) -{ - U32 ret = 0; - // - // Draws a tree by recursing, drawing branches and then a 'leaf' texture. - // If stop_level = -1, simply draws the whole tree as a billboarded texture - // - - static F32 constant_twist; - static F32 width = 0; - - //F32 length = ((scale == 1.f)? mTrunkLength:mBranchLength); - //F32 aspect = ((scale == 1.f)? mTrunkAspect:mBranchAspect); - F32 length = ((trunk_depth || (scale == 1.f))? mTrunkLength:mBranchLength); - F32 aspect = ((trunk_depth || (scale == 1.f))? mTrunkAspect:mBranchAspect); - - constant_twist = 360.f/branches; - - if (!LLPipeline::sReflectionRender && stop_level >= 0) - { - // - // Draw the tree using recursion - // - if (depth > stop_level) - { - { - llassert(sLODIndexCount[trunk_LOD] > 0); - width = scale * length * aspect; - LLMatrix4 scale_mat; - scale_mat.mMatrix[0][0] = width; - scale_mat.mMatrix[1][1] = width; - scale_mat.mMatrix[2][2] = scale*length; - scale_mat *= matrix; - - gGL.loadMatrix((F32*) scale_mat.mMatrix); - gGL.syncMatrices(); - glDrawElements(GL_TRIANGLES, sLODIndexCount[trunk_LOD], GL_UNSIGNED_SHORT, indicesp + sLODIndexOffset[trunk_LOD]); - gPipeline.addTrianglesDrawn(LEAF_INDICES); - stop_glerror(); - ret += sLODIndexCount[trunk_LOD]; - } - - // Recurse to create more branches - for (S32 i=0; i < (S32)branches; i++) - { - LLMatrix4 trans_mat; - trans_mat.setTranslation(0,0,scale*length); - trans_mat *= matrix; - - LLQuaternion rot = - LLQuaternion(20.f*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f)) * - LLQuaternion(droop*DEG_TO_RAD, LLVector4(0.f, 1.f, 0.f)) * - LLQuaternion(((constant_twist + ((i%2==0)?twist:-twist))*i)*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f)); - - LLMatrix4 rot_mat(rot); - rot_mat *= trans_mat; - - ret += drawBranchPipeline(rot_mat, indicesp, trunk_LOD, stop_level, depth - 1, 0, scale*mScaleStep, twist, droop, branches, alpha); - } - // Recurse to continue trunk - if (trunk_depth) - { - LLMatrix4 trans_mat; - trans_mat.setTranslation(0,0,scale*length); - trans_mat *= matrix; - - LLMatrix4 rot_mat(70.5f*DEG_TO_RAD, LLVector4(0,0,1)); - rot_mat *= trans_mat; // rotate a bit around Z when ascending - ret += drawBranchPipeline(rot_mat, indicesp, trunk_LOD, stop_level, depth, trunk_depth-1, scale*mScaleStep, twist, droop, branches, alpha); - } - } - else - { - // - // Draw leaves as two 90 deg crossed quads with leaf textures - // - { - LLMatrix4 scale_mat; - scale_mat.mMatrix[0][0] = - scale_mat.mMatrix[1][1] = - scale_mat.mMatrix[2][2] = scale*mLeafScale; - - scale_mat *= matrix; - - - gGL.loadMatrix((F32*) scale_mat.mMatrix); - gGL.syncMatrices(); - glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp); - gPipeline.addTrianglesDrawn(LEAF_INDICES); - stop_glerror(); - ret += LEAF_INDICES; - } - } - } - else - { - // - // Draw the tree as a single billboard texture - // - - LLMatrix4 scale_mat; - scale_mat.mMatrix[0][0] = - scale_mat.mMatrix[1][1] = - scale_mat.mMatrix[2][2] = mBillboardScale*mBillboardRatio; - - scale_mat *= matrix; - - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.translatef(0.0, -0.5, 0.0); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - gGL.loadMatrix((F32*) scale_mat.mMatrix); - gGL.syncMatrices(); - glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp); - gPipeline.addTrianglesDrawn(LEAF_INDICES); - stop_glerror(); - ret += LEAF_INDICES; - - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - } - - return ret; -} - void LLVOTree::updateRadius() { if (mDrawable.isNull()) diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h index 52debc85ab..2a7eb21238 100644 --- a/indra/newview/llvotree.h +++ b/indra/newview/llvotree.h @@ -104,10 +104,7 @@ public: F32 twist, F32 droop, F32 branches, - F32 alpha); - - U32 drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha); - + F32 alpha); /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face = -1, // which face to check, -1 = ALL_SIDES diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 56aa69b25c..27565a8d17 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4104,15 +4104,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } } - //DEBUG - LLVertexBuffer* buff = facep->getVertexBuffer(); - - if (type == LLRenderPass::PASS_ALPHA && !buff->hasDataType(LLVertexBuffer::TYPE_BINORMAL)) - { - llerrs << "WTF?" << llendl; - } - - if (idx >= 0 && draw_vec[idx]->mVertexBuffer == facep->getVertexBuffer() && draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && @@ -4784,7 +4775,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX; } - genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, batch_textures); + genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, batch_textures, TRUE); genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, batch_textures); genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, batch_textures); genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, FALSE); @@ -4963,7 +4954,7 @@ static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB"); -void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort, BOOL batch_textures) +void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort, BOOL batch_textures, BOOL no_materials) { LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); @@ -5268,6 +5259,10 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); } } + else if (no_materials) + { + registerFace(group, facep, LLRenderPass::PASS_SIMPLE); + } else { U32 pass[] = diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 89df61919e..c074a0e16e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9023,6 +9023,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLEnable cull(GL_CULL_FACE); + //enable depth clamping if available + LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); + if (use_shader) { gDeferredShadowCubeProgram.bind(); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 5af02a238f..364c1df999 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2359,6 +2359,12 @@ <menu_item_check.on_click function="Advanced.ToggleFrameTest" /> </menu_item_check> + <menu_item_call + label="Frame Profile" + name="Frame Profile"> + <menu_item_call.on_click + function="Advanced.ClickRenderProfile" /> + </menu_item_call> </menu> <menu create_jump_keys="true" |