diff options
author | Dave Parks <davep@lindenlab.com> | 2011-08-10 13:01:14 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-08-10 13:01:14 -0500 |
commit | 2ee815478043c4d5845f094f744a055707dba0e0 (patch) | |
tree | 7a34bf2b60eaf609af9f3e8dab20268ed720d75c | |
parent | f076bdf609ec1fe114a7d0222a318483c97c7a26 (diff) |
SH-2238, SH-2223, SH-SH-2242 glVertexAttrib throughout main render pipeline complete, preview renders and debug displays still pending. Also fixed a render glitch and a crash (JIRAs listed).
68 files changed, 1095 insertions, 677 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index b6cb84d10c..02bcc9e338 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -934,7 +934,9 @@ void LLGLSLShader::uniform4fv(const string& uniform, U32 count, const GLfloat* v std::map<GLint, LLVector4>::iterator iter = mValue.find(location); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { + stop_glerror(); glUniform4fvARB(location, count, v); + stop_glerror(); mValue[location] = vec; } } diff --git a/indra/llrender/llrendersphere.cpp b/indra/llrender/llrendersphere.cpp index a5cd70445f..e7e07a1ab2 100644 --- a/indra/llrender/llrendersphere.cpp +++ b/indra/llrender/llrendersphere.cpp @@ -35,106 +35,11 @@ #include "llglheaders.h" -GLUquadricObj *gQuadObj2 = NULL; LLRenderSphere gSphere; -void drawSolidSphere(GLdouble radius, GLint slices, GLint stacks); - -void drawSolidSphere(GLdouble radius, GLint slices, GLint stacks) -{ - if (!gQuadObj2) - { - gQuadObj2 = gluNewQuadric(); - if (!gQuadObj2) - { - llwarns << "drawSolidSphere couldn't allocate quadric" << llendl; - return; - } - } - - gluQuadricDrawStyle(gQuadObj2, GLU_FILL); - gluQuadricNormals(gQuadObj2, GLU_SMOOTH); - // If we ever changed/used the texture or orientation state - // of quadObj, we'd need to change it to the defaults here - // with gluQuadricTexture and/or gluQuadricOrientation. - gluQuadricTexture(gQuadObj2, GL_TRUE); - gluSphere(gQuadObj2, radius, slices, stacks); -} - - -// A couple thoughts on sphere drawing: -// 1) You need more slices than stacks, but little less than 2:1 -// 2) At low LOD, setting stacks to an odd number avoids a "band" around the equator, making things look smoother -void LLRenderSphere::prerender() -{ - // Create a series of display lists for different LODs - mDList[0] = glGenLists(1); - glNewList(mDList[0], GL_COMPILE); - drawSolidSphere(1.0, 30, 20); - glEndList(); - - mDList[1] = glGenLists(1); - glNewList(mDList[1], GL_COMPILE); - drawSolidSphere(1.0, 20, 15); - glEndList(); - - mDList[2] = glGenLists(1); - glNewList(mDList[2], GL_COMPILE); - drawSolidSphere(1.0, 12, 8); - glEndList(); - - mDList[3] = glGenLists(1); - glNewList(mDList[3], GL_COMPILE); - drawSolidSphere(1.0, 8, 5); - glEndList(); -} - -void LLRenderSphere::cleanupGL() -{ - for (S32 detail = 0; detail < 4; detail++) - { - glDeleteLists(mDList[detail], 1); - mDList[detail] = 0; - } - - if (gQuadObj2) - { - gluDeleteQuadric(gQuadObj2); - gQuadObj2 = NULL; - } -} - -// Constants here are empirically derived from my eyeballs, JNC -// -// The toughest adjustment is the cutoff for the lowest LOD -// Maybe we should have more LODs at the low end? -void LLRenderSphere::render(F32 pixel_area) -{ - S32 level_of_detail; - - if (pixel_area > 10000.f) - { - level_of_detail = 0; - } - else if (pixel_area > 800.f) - { - level_of_detail = 1; - } - else if (pixel_area > 100.f) - { - level_of_detail = 2; - } - else - { - level_of_detail = 3; - } - glCallList(mDList[level_of_detail]); -} - - void LLRenderSphere::render() { - glCallList(mDList[0]); + renderGGL(); } inline LLVector3 polar_to_cart(F32 latitude, F32 longitude) diff --git a/indra/llrender/llrendersphere.h b/indra/llrender/llrendersphere.h index 96a6bec80c..f8e9e86e7f 100644 --- a/indra/llrender/llrendersphere.h +++ b/indra/llrender/llrendersphere.h @@ -40,11 +40,6 @@ void lat2xyz(LLVector3 * result, F32 lat, F32 lon); // utility routine class LLRenderSphere { public: - LLGLuint mDList[5]; - - void prerender(); - void cleanupGL(); - void render(F32 pixel_area); // of a box of size 1.0 at that position void render(); // render at highest LOD void renderGGL(); // render using LLRender diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index a5977d658d..5d19168842 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -62,7 +62,6 @@ U32 LLVertexBuffer::sAllocatedBytes = 0; BOOL LLVertexBuffer::sMapped = FALSE; BOOL LLVertexBuffer::sUseStreamDraw = TRUE; BOOL LLVertexBuffer::sPreferStreamDraw = FALSE; -S32 LLVertexBuffer::sWeight4Loc = -1; std::vector<U32> LLVertexBuffer::sDeleteList; @@ -355,6 +354,8 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) //static void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm) { + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); + U32 count = pos.size(); llassert_always(norm.size() >= pos.size()); llassert_always(count > 0) ; @@ -369,6 +370,49 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con glDrawArrays(sGLMode[mode], 0, count); } +//static +void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp) +{ + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); + + U32 mask = LLVertexBuffer::MAP_VERTEX; + if (tc) + { + mask = mask | LLVertexBuffer::MAP_TEXCOORD0; + } + + unbind(); + + setupClientArrays(mask); + + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + + if (shader) + { + S32 loc = shader->getAttribLocation(LLVertexBuffer::TYPE_VERTEX); + if (loc > -1) + { + glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, 16, pos); + + if (tc) + { + loc = shader->getAttribLocation(LLVertexBuffer::TYPE_TEXCOORD0); + if (loc > -1) + { + glVertexAttribPointerARB(loc, 2, GL_FLOAT, GL_FALSE, 0, tc); + } + } + } + } + else + { + glTexCoordPointer(2, GL_FLOAT, 0, tc); + glVertexPointer(3, GL_FLOAT, 16, pos); + } + + glDrawElements(sGLMode[mode], num_indices, GL_UNSIGNED_SHORT, indicesp); +} + void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const { if (start >= (U32) mRequestedNumVerts || @@ -403,6 +447,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi validateRange(start, end, count, indices_offset); llassert(mRequestedNumVerts >= 0); + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); if (mGLIndices != sGLRenderIndices) { @@ -431,6 +476,8 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const { + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); + llassert(mRequestedNumIndices >= 0); if (indices_offset >= (U32) mRequestedNumIndices || indices_offset + count > (U32) mRequestedNumIndices) @@ -463,6 +510,8 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const { + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); + llassert(mRequestedNumVerts >= 0); if (first >= (U32) mRequestedNumVerts || first + count > (U32) mRequestedNumVerts) @@ -2037,9 +2086,16 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const } - if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1) + if (data_mask & MAP_WEIGHT4) { - glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4])); + if (shader) + { + S32 loc = shader->getAttribLocation(TYPE_WEIGHT4); + if (loc > -1) + { + glVertexAttribPointerARB(loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4])); + } + } } if (data_mask & MAP_CLOTHWEIGHT) diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 3cccdf62ec..9497bc9357 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -111,8 +111,6 @@ public: static LLVBOPool sStreamIBOPool; static LLVBOPool sDynamicIBOPool; - static S32 sWeight4Loc; - static BOOL sUseStreamDraw; static BOOL sPreferStreamDraw; @@ -120,6 +118,7 @@ public: static void cleanupClass(); static void setupClientArrays(U32 data_mask); static void drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm); + static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp); static void clientCopy(F64 max_time = 0.005); //copy data from client to GL static void unbind(); //unbind any bound vertex buffer diff --git a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl index 7613e50dca..35c5a38081 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl @@ -7,7 +7,7 @@ -attribute vec4 object_weight; +attribute vec4 weight4; uniform mat4 matrixPalette[32]; @@ -15,8 +15,8 @@ mat4 getObjectSkinnedTransform() { int i; - vec4 w = fract(object_weight); - vec4 index = floor(object_weight); + vec4 w = fract(weight4); + vec4 index = floor(weight4); float scale = 1.0/(w.x+w.y+w.z+w.w); w *= scale; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl new file mode 100644 index 0000000000..5d1306bfc9 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl @@ -0,0 +1,63 @@ +/** + * @file alphaNonIndexedNoColorF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2DRect depthMap; +uniform sampler2D diffuseMap; + +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform vec2 screen_res; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +varying vec3 vary_ambient; +varying vec3 vary_directional; +varying vec3 vary_fragcoord; +varying vec3 vary_position; +varying vec3 vary_pointlight_col; + +uniform mat4 inv_proj; + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).a; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +void main() +{ + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + + vec4 pos = vec4(vary_position, 1.0); + + vec4 diff= texture2D(diffuseMap,gl_TexCoord[0].xy); + + vec4 col = vec4(vary_ambient + vary_directional.rgb, 1.0); + vec4 color = diff * col; + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + color.rgb += diff.rgb * vary_pointlight_col.rgb; + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl index 842931ec17..468d7332a6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl @@ -7,7 +7,6 @@ attribute vec3 position; attribute vec3 normal; -attribute vec4 diffuse_color; attribute vec2 texcoord0; vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); @@ -86,9 +85,7 @@ void main() calcAtmospherics(pos.xyz); - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); + vec4 col = vec4(0.0, 0.0, 0.0, 1.0); // Collect normal lights col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a); @@ -98,17 +95,17 @@ void main() col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a); col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a); - vary_pointlight_col = col.rgb*diffuse_color.rgb; + vary_pointlight_col = col.rgb; col.rgb = vec3(0,0,0); // Add windlight lights col.rgb = atmosAmbient(vec3(0.)); - vary_ambient = col.rgb*diffuse_color.rgb; - vary_directional = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a))); + vary_ambient = col.rgb; + vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), 0.0)); - col.rgb = min(col.rgb*diffuse_color.rgb, 1.0); + col.rgb = min(col.rgb, 1.0); gl_FrontColor = col; diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index 3268618093..d8e8f6088d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -13,7 +13,7 @@ varying vec3 vary_normal; void main() { - vec4 diff = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); + vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy); if (diff.a < 0.2) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 78986ab12e..c693725074 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl @@ -13,7 +13,6 @@ varying vec4 post_pos; void main() { - //gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a); gl_FragColor = vec4(1,1,1,1); gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl index cf6fc1c0ed..35d0bb5603 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl @@ -11,10 +11,8 @@ mat4 getSkinnedTransform(); attribute vec3 position; attribute vec3 normal; -attribute vec4 diffuse_color; attribute vec2 texcoord0; - varying vec4 post_pos; void main() @@ -40,8 +38,6 @@ void main() post_pos = pos; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); - - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl index e66f8c8483..9ef11109ed 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl @@ -6,7 +6,6 @@ */ attribute vec3 position; -attribute vec4 diffuse_color; attribute vec3 normal; attribute vec2 texcoord0; @@ -38,8 +37,6 @@ void main() vary_normal = norm; gl_Position = gl_ProjectionMatrix * pos; - - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl index 338d0ebb2b..26355731ae 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl @@ -1,5 +1,5 @@ /** - * @file diffuseF.glsl + * @file diffuseAlphaMaskF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * $/LicenseInfo$ @@ -15,7 +15,7 @@ varying vec3 vary_normal; void main() { - vec4 col = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; if (col.a < minimum_alpha || col.a > maximum_alpha) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl new file mode 100644 index 0000000000..dfc1b52c2e --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl @@ -0,0 +1,30 @@ +/** + * @file diffuseAlphaMaskNoColorF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +uniform float minimum_alpha; +uniform float maximum_alpha; + +uniform sampler2D diffuseMap; + +varying vec3 vary_normal; + +void main() +{ + vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); + + if (col.a < minimum_alpha || col.a > maximum_alpha) + { + discard; + } + + gl_FragData[0] = vec4(col.rgb, 0.0); + gl_FragData[1] = vec4(0,0,0,0); // spec + vec3 nvn = normalize(vary_normal); + gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl new file mode 100644 index 0000000000..ff9578e253 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl @@ -0,0 +1,23 @@ +/** + * @file diffuseNoColorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +attribute vec3 position; +attribute vec3 normal; +attribute vec2 texcoord0; + +varying vec3 vary_normal; +varying float vary_texture_index; + +void main() +{ + //transform vertex + gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); + + vary_normal = normalize(gl_NormalMatrix * normal); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl new file mode 100644 index 0000000000..5a9a6196f3 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -0,0 +1,28 @@ +/** + * @file emissiveF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +#extension GL_ARB_texture_rectangle : enable + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + + +void main() +{ + float shadow = 1.0; + + vec4 color = diffuseLookup(gl_TexCoord[0].xy)*gl_Color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl new file mode 100644 index 0000000000..9841943fe6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl @@ -0,0 +1,38 @@ +/** + * @file emissiveV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +attribute vec4 position; +attribute float emissive; +attribute vec2 texcoord0; + +void calcAtmospherics(vec3 inPositionEye); + +vec3 atmosAmbient(vec3 light); +vec3 atmosAffectDirectionalLight(float lightIntensity); +vec3 scaleDownLight(vec3 light); +vec3 scaleUpLight(vec3 light); + +varying float vary_texture_index; + +void main() +{ + //transform vertex + vec4 vert = vec4(position.xyz, 1.0); + vec4 pos = (gl_ModelViewMatrix * vert); + vary_texture_index = position.w; + + gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0); + + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = vec4(0,0,0,emissive); + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl index 7db577c07a..bb0497b309 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl @@ -7,7 +7,6 @@ attribute vec3 position; -attribute vec4 diffuse_color; varying vec4 vary_fragcoord; @@ -18,5 +17,4 @@ void main() vary_fragcoord = pos; gl_Position = pos; - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 0d25d7792d..6c08f7b51f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -37,7 +37,10 @@ uniform float sun_wash; uniform int proj_shadow_idx; uniform float shadow_fade; -varying vec4 vary_light; +uniform vec3 center; +uniform vec3 color; +uniform float falloff; +uniform float size; varying vec4 vary_fragcoord; uniform vec2 screen_res; @@ -92,7 +95,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) vec4 getPosition(vec2 pos_screen) { - float depth = texture2DRect(depthMap, pos_screen.xy).a; + float depth = texture2DRect(depthMap, pos_screen.xy).r; vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); @@ -111,9 +114,9 @@ void main() frag.xy *= screen_res; vec3 pos = getPosition(frag.xy).xyz; - vec3 lv = vary_light.xyz-pos.xyz; + vec3 lv = center.xyz-pos.xyz; float dist2 = dot(lv,lv); - dist2 /= vary_light.w; + dist2 /= size; if (dist2 > 1.0) { discard; @@ -127,16 +130,16 @@ void main() vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); if (proj_tc.z < 0.0) { - discard; + //discard; } proj_tc.xyz /= proj_tc.w; - float fa = gl_Color.a+1.0; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); if (dist_atten <= 0.0) { - discard; + //discard; } lv = proj_origin-pos.xyz; @@ -164,7 +167,7 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); - vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; + vec3 lcol = color.rgb * plcol.rgb * plcol.a; lit = da * dist_atten * noise; @@ -181,7 +184,7 @@ void main() amb_da = min(amb_da, 1.0-lit); - col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; + col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; } @@ -214,7 +217,7 @@ void main() stc.y > 0.0) { vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb; + col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb; } } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 5efa3200d4..601bb17bc7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -20,7 +20,10 @@ uniform sampler2DRect depthMap; uniform vec3 env_mat[3]; uniform float sun_wash; -varying vec4 vary_light; +uniform vec3 center; +uniform vec3 color; +uniform float falloff; +uniform float size; varying vec4 vary_fragcoord; uniform vec2 screen_res; @@ -49,9 +52,9 @@ void main() frag.xy *= screen_res; vec3 pos = getPosition(frag.xy).xyz; - vec3 lv = vary_light.xyz-pos; + vec3 lv = center.xyz-pos; float dist2 = dot(lv,lv); - dist2 /= vary_light.w; + dist2 /= size; if (dist2 > 1.0) { discard; @@ -72,11 +75,11 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = gl_Color.a+1.0; + 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; - col = gl_Color.rgb*lit*col; + col = color.rgb*lit*col; vec4 spec = texture2DRect(specularRect, frag.xy); if (spec.a > 0.0) @@ -86,7 +89,7 @@ void main() { sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); sa *= noise; - col += da*sa*gl_Color.rgb*spec.rgb; + col += da*sa*color.rgb*spec.rgb; } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl index ac3170d16d..a09cfa2661 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl @@ -6,10 +6,7 @@ */ attribute vec3 position; -attribute vec4 diffuse_color; -attribute vec2 texcoord0; -varying vec4 vary_light; varying vec4 vary_fragcoord; void main() @@ -18,12 +15,5 @@ void main() vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); vary_fragcoord = pos; - vec4 tex = vec4(texcoord0,0,1); - tex.w = 1.0; - - vary_light = vec4(texcoord0,0,1); - gl_Position = pos; - - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 3ba5ee5bd2..35ab77d3cc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -306,5 +306,6 @@ void main() } gl_FragColor.rgb = col; + gl_FragColor.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 9aaffc15bf..ed67dc32d5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -13,7 +13,6 @@ uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect depthMap; uniform sampler2DRect normalMap; -uniform samplerCube environmentMap; uniform sampler2D noiseMap; uniform sampler2D lightFunc; uniform sampler2D projectionMap; @@ -32,7 +31,10 @@ uniform float far_clip; uniform vec3 proj_origin; //origin of projection to be used for angular attenuation uniform float sun_wash; -varying vec4 vary_light; +uniform vec3 center; +uniform vec3 color; +uniform float falloff; +uniform float size; varying vec4 vary_fragcoord; uniform vec2 screen_res; @@ -60,9 +62,9 @@ void main() frag.xy *= screen_res; vec3 pos = getPosition(frag.xy).xyz; - vec3 lv = vary_light.xyz-pos.xyz; + vec3 lv = center.xyz-pos.xyz; float dist2 = dot(lv,lv); - dist2 /= vary_light.w; + dist2 /= size; if (dist2 > 1.0) { discard; @@ -82,7 +84,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = gl_Color.a+1.0; + float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); lv = proj_origin-pos.xyz; @@ -108,7 +110,7 @@ void main() vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); - vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; + vec3 lcol = color.rgb * plcol.rgb * plcol.a; lit = da * dist_atten * noise; @@ -127,7 +129,7 @@ void main() amb_da = min(amb_da, 1.0-lit); - col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; + col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; } @@ -156,7 +158,7 @@ void main() stc.y > 0.0) { vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb; + col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb; } } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl index 665d8126a0..6bbf86177a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl @@ -25,7 +25,6 @@ uniform float ssao_factor; uniform float ssao_factor_inv; varying vec2 vary_fragcoord; -varying vec4 vary_light; uniform mat4 inv_proj; uniform vec2 screen_res; diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl index 65fa288e88..d39bfef4ae 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl @@ -6,11 +6,7 @@ */ attribute vec3 position; -attribute vec3 normal; -attribute vec4 diffuse_color; -attribute vec2 texcoord0; -varying vec4 vary_light; varying vec2 vary_fragcoord; uniform vec2 screen_res; @@ -22,10 +18,4 @@ void main() gl_Position = pos; vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; - vec4 tex = vec4(texcoord0,0,1); - tex.w = 1.0; - - vary_light = vec4(texcoord0,0,1); - - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index de7e038402..08a3bc251a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl @@ -11,10 +11,18 @@ uniform sampler2D diffuseMap; varying vec3 vary_normal; +uniform float minimum_alpha; +uniform float maximum_alpha; + void main() { vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); - gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005); + if (col.a < minimum_alpha || col.a > maximum_alpha) + { + discard; + } + + gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, 0.0); gl_FragData[1] = vec4(0,0,0,0); vec3 nvn = normalize(vary_normal); gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl new file mode 100644 index 0000000000..9f0b902c96 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl @@ -0,0 +1,27 @@ +/** + * @file treeShadowF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform float minimum_alpha; +uniform float maximum_alpha; + +uniform sampler2D diffuseMap; + +varying vec4 post_pos; + +void main() +{ + float alpha = texture2D(diffuseMap, gl_TexCoord[0].xy).a; + + if (alpha < minimum_alpha || alpha > maximum_alpha) + { + discard; + } + + gl_FragColor = vec4(1,1,1,1); + + gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl new file mode 100644 index 0000000000..42ce2f5226 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl @@ -0,0 +1,23 @@ +/** + * @file treeShadowV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +attribute vec3 position; +attribute vec2 texcoord0; + +varying vec4 post_pos; + +void main() +{ + //transform vertex + vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0); + + post_pos = pos; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); + + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl index 07e56e84db..f56f389348 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl @@ -10,7 +10,6 @@ attribute vec3 position; attribute vec3 normal; attribute vec2 texcoord0; - varying vec3 vary_normal; void main() diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl new file mode 100644 index 0000000000..a5442c9bf4 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl @@ -0,0 +1,13 @@ +/** + * @file onetexturenocolorF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D tex0; + +void main() +{ + gl_FragColor = texture2D(tex0, gl_TexCoord[0].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl new file mode 100644 index 0000000000..7df45e90e6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl @@ -0,0 +1,18 @@ +/** + * @file onetexturenocolorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +attribute vec3 position; +attribute vec2 texcoord0; + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1); + gl_TexCoord[0] = vec4(texcoord0,0,1); +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl index ebf2361da4..9d129caf21 100644 --- a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl @@ -14,7 +14,7 @@ attribute vec2 texcoord0; void main() { gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1); - gl_TexCoord[0] = vec4(texcoord0,0,1); + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/objects.zip b/indra/newview/app_settings/shaders/class1/objects.zip Binary files differnew file mode 100644 index 0000000000..7e43660731 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects.zip diff --git a/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl new file mode 100644 index 0000000000..78668711ac --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl @@ -0,0 +1,33 @@ +/** + * @file emissiveSkinnedV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +attribute vec3 position; +attribute float emissive; +attribute vec2 texcoord0; + +void calcAtmospherics(vec3 inPositionEye); +mat4 getObjectSkinnedTransform(); + +void main() +{ + //transform vertex + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); + + mat4 mat = getObjectSkinnedTransform(); + + mat = gl_ModelViewMatrix * mat; + vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz; + + calcAtmospherics(pos.xyz); + + gl_FrontColor = vec4(0,0,0,emissive); + + gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0); + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl b/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl new file mode 100644 index 0000000000..05d7cc397f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl @@ -0,0 +1,29 @@ +/** + * @file emissiveV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +attribute vec4 position; +attribute float emissive; +attribute vec2 texcoord0; + +void calcAtmospherics(vec3 inPositionEye); + +varying float vary_texture_index; + +void main() +{ + //transform vertex + vary_texture_index = position.w; + gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); + + vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0)); + calcAtmospherics(pos.xyz); + + gl_FrontColor = vec4(0,0,0,emissive); + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl new file mode 100644 index 0000000000..57d98038e0 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl @@ -0,0 +1,27 @@ +/** + * @file fullbrightNoColorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +attribute vec3 position; +attribute vec2 texcoord0; +attribute vec3 normal; + +void calcAtmospherics(vec3 inPositionEye); + +void main() +{ + //transform vertex + vec4 vert = vec4(position.xyz,1.0); + vec4 pos = (gl_ModelViewMatrix * vert); + gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0); + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = vec4(1,1,1,1); + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl new file mode 100644 index 0000000000..54c262885e --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl @@ -0,0 +1,30 @@ +/** + * @file simpleNoColorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +attribute vec3 position; +attribute vec3 normal; +attribute vec2 texcoord0; + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); + +void main() +{ + //transform vertex + vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0)); + gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); + + vec3 norm = normalize(gl_NormalMatrix * normal); + + calcAtmospherics(pos.xyz); + + vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0.)); + gl_FrontColor = color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/treeV.glsl b/indra/newview/app_settings/shaders/class1/objects/treeV.glsl new file mode 100644 index 0000000000..1e9e7f4b0b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/treeV.glsl @@ -0,0 +1,35 @@ +/** + * @file treeV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +attribute vec3 position; +attribute vec2 texcoord0; +attribute vec3 normal; + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); + +void main() +{ + //transform vertex + vec4 vert = vec4(position.xyz,1.0); + + gl_Position = gl_ModelViewProjectionMatrix*vert; + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1); + + vec4 pos = (gl_ModelViewMatrix * vert); + + vec3 norm = normalize(gl_NormalMatrix * normal); + + calcAtmospherics(pos.xyz); + + vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0.)); + gl_FrontColor = color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl new file mode 100644 index 0000000000..294a000ab5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -0,0 +1,121 @@ +/** + * @file alphaNonIndexedNoColorF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2DRectShadow shadowMap0; +uniform sampler2DRectShadow shadowMap1; +uniform sampler2DRectShadow shadowMap2; +uniform sampler2DRectShadow shadowMap3; +uniform sampler2DRect depthMap; +uniform sampler2D diffuseMap; + +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform vec2 screen_res; +uniform vec2 shadow_res; + +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + +varying vec3 vary_ambient; +varying vec3 vary_directional; +varying vec3 vary_fragcoord; +varying vec3 vary_position; +varying vec3 vary_pointlight_col; + +uniform float shadow_bias; + +uniform mat4 inv_proj; + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).a; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos.xyz /= pos.w; + pos.w = 1.0; + return pos; +} + +float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl) +{ + stc.xyz /= stc.w; + stc.z += shadow_bias; + + float cs = shadow2DRect(shadowMap, stc.xyz).x; + float shadow = cs; + + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(scl, scl, 0.0)).x, cs); + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(scl, -scl, 0.0)).x, cs); + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-scl, scl, 0.0)).x, cs); + shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-scl, -scl, 0.0)).x, cs); + + return shadow/5.0; +} + + +void main() +{ + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + + float shadow = 1.0; + vec4 pos = vec4(vary_position, 1.0); + + vec4 spos = pos; + + if (spos.z > -shadow_clip.w) + { + vec4 lpos; + + if (spos.z < -shadow_clip.z) + { + lpos = shadow_matrix[3]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap3, lpos, 1.5); + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + else if (spos.z < -shadow_clip.y) + { + lpos = shadow_matrix[2]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap2, lpos, 1.5); + } + else if (spos.z < -shadow_clip.x) + { + lpos = shadow_matrix[1]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap1, lpos, 1.5); + } + else + { + lpos = shadow_matrix[0]*spos; + lpos.xy *= shadow_res; + shadow = pcfShadow(shadowMap0, lpos, 1.5); + } + } + + vec4 diff = texture2D(diffuseMap,gl_TexCoord[0].xy); + + vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, 1.0); + vec4 color = diff * col; + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + + color.rgb += diff.rgb * vary_pointlight_col.rgb; + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl index 97fe7029e1..a446239a22 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl @@ -68,11 +68,11 @@ void main() mat = gl_ModelViewMatrix * mat; - vec3 pos = (mat*position).xyz; + vec3 pos = (mat*vec4(position, 1.0)).xyz; gl_Position = gl_ProjectionMatrix * vec4(pos, 1.0); - vec4 n = position; + vec4 n = vec4(position, 1.0); n.xyz += normal.xyz; n.xyz = (mat*n).xyz; n.xyz = normalize(n.xyz-pos.xyz); diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 65c3e5da10..8102578bb2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -8,7 +8,6 @@ attribute vec3 position; attribute vec3 normal; -attribute vec4 diffuse_color; attribute vec2 texcoord0; vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); @@ -89,9 +88,7 @@ void main() calcAtmospherics(pos.xyz); - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); + vec4 col = vec4(0.0, 0.0, 0.0, 1.0); // Collect normal lights col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a); @@ -101,17 +98,17 @@ void main() col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a); col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a); - vary_pointlight_col = col.rgb*diffuse_color.rgb; + vary_pointlight_col = col.rgb; col.rgb = vec3(0,0,0); // Add windlight lights col.rgb = atmosAmbient(vec3(0.)); - vary_ambient = col.rgb*diffuse_color.rgb; - vary_directional = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a))); + vary_ambient = col.rgb; + vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), 0.0)); - col.rgb = min(col.rgb*diffuse_color.rgb, 1.0); + col.rgb = min(col.rgb, 1.0); gl_FrontColor = col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index f54186ffca..a16be0c8b4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -36,7 +36,10 @@ uniform float sun_wash; uniform int proj_shadow_idx; uniform float shadow_fade; -varying vec4 vary_light; +uniform vec3 center; +uniform float size; +uniform vec3 color; +uniform float falloff; varying vec4 vary_fragcoord; uniform vec2 screen_res; @@ -110,9 +113,9 @@ void main() frag.xy *= screen_res; vec3 pos = getPosition(frag.xy).xyz; - vec3 lv = vary_light.xyz-pos.xyz; + vec3 lv = center.xyz-pos.xyz; float dist2 = dot(lv,lv); - dist2 /= vary_light.w; + dist2 /= size; if (dist2 > 1.0) { discard; @@ -143,7 +146,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = gl_Color.a+1.0; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); if (dist_atten <= 0.0) { @@ -175,7 +178,7 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); - vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; + vec3 lcol = color.rgb * plcol.rgb * plcol.a; lit = da * dist_atten * noise; @@ -192,7 +195,7 @@ void main() amb_da = min(amb_da, 1.0-lit); - col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; + col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; } @@ -225,7 +228,7 @@ void main() stc.y > 0.0) { vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; + col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index f0c9b01671..cbac299e44 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -47,7 +47,8 @@ uniform mat3 ssao_effect_mat; uniform mat4 inv_proj; uniform vec2 screen_res; -varying vec4 vary_light; +uniform vec3 sun_dir; + varying vec2 vary_fragcoord; vec3 vary_PositionEye; @@ -264,7 +265,7 @@ void main() norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm //vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz; - float da = max(dot(norm.xyz, vary_light.xyz), 0.0); + float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -291,7 +292,7 @@ void main() // the old infinite-sky shiny reflection // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(refnormpersp, vary_light.xyz); + float sa = dot(refnormpersp, sun_dir.xyz); vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; // add the two types of shiny together diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl index d2e3415d91..9534f1d79c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl @@ -7,12 +7,11 @@ attribute vec3 position; -attribute vec2 texcoord0; uniform vec2 screen_res; -varying vec4 vary_light; varying vec2 vary_fragcoord; + void main() { //transform vertex @@ -21,6 +20,4 @@ void main() vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; - - vary_light = vec4(texcoord0,0,1); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index d53850b489..699fcdb0f3 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -30,7 +30,7 @@ uniform float ssao_factor; uniform float ssao_factor_inv; varying vec2 vary_fragcoord; -varying vec4 vary_light; +uniform vec3 sun_dir; uniform mat4 inv_proj; uniform vec2 screen_res; @@ -167,10 +167,10 @@ void main() }*/ float shadow = 1.0; - float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); + float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); vec3 shadow_pos = pos.xyz + displace*norm; - vec3 offset = vary_light.xyz * (1.0-dp_directional_light); + vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl index 6795b55dc6..39cca9589e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl @@ -6,9 +6,6 @@ */ attribute vec3 position; -attribute vec3 normal; -attribute vec4 diffuse_color; -attribute vec2 texcoord0; varying vec4 vary_light; @@ -23,10 +20,4 @@ void main() gl_Position = pos; vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; - vec4 tex = vec4(texcoord0,0,1); - tex.w = 1.0; - - vary_light = vec4(texcoord0,0,1); - - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl b/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl new file mode 100644 index 0000000000..d2a83c9724 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl @@ -0,0 +1,36 @@ +/** + * @file simpleNonIndexedV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +attribute vec3 position; +attribute vec2 texcoord0; +attribute vec3 normal; +attribute vec4 diffuse_color; + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); + +void main() +{ + //transform vertex + vec4 vert = vec4(position.xyz,1.0); + + gl_Position = gl_ModelViewProjectionMatrix*vert; + gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1); + + vec4 pos = (gl_ModelViewMatrix * vert); + + vec3 norm = normalize(gl_NormalMatrix * normal); + + calcAtmospherics(pos.xyz); + + vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); + gl_FrontColor = color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 406417a36b..64a5884e14 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -3925,7 +3925,7 @@ void LLAgent::renderAutoPilotTarget() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // lovely green - gGL.diffuseColor4f(0.f, 1.f, 1.f, 1.f); + gGL.color4f(0.f, 1.f, 1.f, 1.f); target_global = mAutoPilotTargetGlobal; @@ -3935,7 +3935,7 @@ void LLAgent::renderAutoPilotTarget() glScalef(height_meters, height_meters, height_meters); - gSphere.render(1500.f); + gSphere.render(); gGL.popMatrix(); } diff --git a/indra/newview/llcylinder.cpp b/indra/newview/llcylinder.cpp index 4901e29691..2adc071d7a 100644 --- a/indra/newview/llcylinder.cpp +++ b/indra/newview/llcylinder.cpp @@ -37,261 +37,39 @@ #include "llgl.h" #include "llglheaders.h" -LLCylinder gCylinder; LLCone gCone; -GLUquadricObj* gQuadObj = NULL; - -static const GLint SLICES[] = { 30, 20, 12, 6 }; // same as sphere slices -static const GLint STACKS = 2; -static const GLfloat RADIUS = 0.5f; - -// draws a cylinder or cone -// returns approximate number of triangles required -U32 draw_cylinder_side(GLint slices, GLint stacks, GLfloat base_radius, GLfloat top_radius) -{ - U32 triangles = 0; - GLfloat height = 1.0f; - - if (!gQuadObj) - { - gQuadObj = gluNewQuadric(); - if (!gQuadObj) llerror("draw_cylindrical_body couldn't allocated quadric", 0); - } - - gluQuadricDrawStyle(gQuadObj, GLU_FILL); - gluQuadricNormals(gQuadObj, GLU_SMOOTH); - gluQuadricOrientation(gQuadObj, GLU_OUTSIDE); - gluQuadricTexture(gQuadObj, GL_TRUE); - gluCylinder(gQuadObj, base_radius, top_radius, height, slices, stacks); - triangles += stacks * (slices * 2); - - - return triangles; -} - - -// Returns number of triangles required to draw -// Need to know if top or not to set lighting normals -const BOOL TOP = TRUE; -const BOOL BOTTOM = FALSE; -U32 draw_cylinder_cap(GLint slices, GLfloat base_radius, BOOL is_top) -{ - U32 triangles = 0; - - if (!gQuadObj) - { - gQuadObj = gluNewQuadric(); - if (!gQuadObj) llerror("draw_cylinder_base couldn't allocated quadric", 0); - } - - gluQuadricDrawStyle(gQuadObj, GLU_FILL); - gluQuadricNormals(gQuadObj, GLU_SMOOTH); - gluQuadricOrientation(gQuadObj, GLU_OUTSIDE); - gluQuadricTexture(gQuadObj, GL_TRUE); - - // no hole in the middle of the disk, and just one ring - GLdouble inner_radius = 0.0; - GLint rings = 1; - - // normals point in +z for top, -z for base - if (is_top) - { - gluQuadricOrientation(gQuadObj, GLU_OUTSIDE); - } - else - { - gluQuadricOrientation(gQuadObj, GLU_INSIDE); - } - gluDisk(gQuadObj, inner_radius, base_radius, slices, rings); - triangles += slices; - - return triangles; -} - -void LLCylinder::drawSide(S32 detail) -{ - draw_cylinder_side(SLICES[detail], STACKS, RADIUS, RADIUS); -} - -void LLCylinder::drawTop(S32 detail) -{ - draw_cylinder_cap(SLICES[detail], RADIUS, TOP); -} - -void LLCylinder::drawBottom(S32 detail) -{ - draw_cylinder_cap(SLICES[detail], RADIUS, BOTTOM); -} - -void LLCylinder::prerender() -{ -} - -void LLCylinder::cleanupGL() -{ - if (gQuadObj) - { - gluDeleteQuadric(gQuadObj); - gQuadObj = NULL; - } -} - -void LLCylinder::render(F32 pixel_area) -{ - renderface(pixel_area, 0); - renderface(pixel_area, 1); - renderface(pixel_area, 2); -} - - -void LLCylinder::renderface(F32 pixel_area, S32 face) -{ - if (face < 0 || face > 2) - { - llerror("LLCylinder::renderface() invalid face number", face); - return; - } - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - S32 level_of_detail; - - if (pixel_area > 20000.f) - { - level_of_detail = 0; - } - else if (pixel_area > 1600.f) - { - level_of_detail = 1; - } - else if (pixel_area > 200.f) - { - level_of_detail = 2; - } - else - { - level_of_detail = 3; - } - - if (level_of_detail < 0 || CYLINDER_LEVELS_OF_DETAIL <= level_of_detail) - { - llerror("LLCylinder::renderface() invalid level of detail", level_of_detail); - return; - } - - LLVertexBuffer::unbind(); - - switch(face) - { - case 0: - glTranslatef(0.f, 0.f, -0.5f); - drawSide(level_of_detail); - break; - case 1: - glTranslatef(0.0f, 0.f, 0.5f); - drawTop(level_of_detail); - break; - case 2: - glTranslatef(0.0f, 0.f, -0.5f); - drawBottom(level_of_detail); - break; - default: - llerror("LLCylinder::renderface() fell out of switch", 0); - break; - } - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); -} - - // // Cones // -void LLCone::prerender() +void LLCone::render(S32 sides) { -} + gGL.begin(LLRender::TRIANGLE_FAN); + gGL.vertex3f(0,0,0); -void LLCone::cleanupGL() -{ - if (gQuadObj) + for (U32 i = 0; i < sides; i++) { - gluDeleteQuadric(gQuadObj); - gQuadObj = NULL; + F32 a = (F32) i/sides * F_PI*2.f; + F32 x = cosf(a)*0.5f; + F32 y = sinf(a)*0.5f; + gGL.vertex3f(x,y,0.f); } -} + gGL.vertex3f(cosf(0.f)*0.5f, sinf(0.f)*0.5f, 0.f); -void LLCone::drawSide(S32 detail) -{ - draw_cylinder_side( SLICES[detail], STACKS, RADIUS, 0.f ); -} - -void LLCone::drawBottom(S32 detail) -{ - draw_cylinder_cap( SLICES[detail], RADIUS, BOTTOM ); -} - -void LLCone::render(S32 level_of_detail) -{ - GLfloat height = 1.0f; + gGL.end(); - if (level_of_detail < 0 || CONE_LEVELS_OF_DETAIL <= level_of_detail) + gGL.begin(LLRender::TRIANGLE_FAN); + gGL.vertex3f(0.f, 0.f, 1.f); + for (U32 i = 0; i < sides; i++) { - llerror("LLCone::render() invalid level of detail", level_of_detail); - return; + F32 a = (F32) i/sides * F_PI*2.f; + F32 x = cosf(a)*0.5f; + F32 y = sinf(a)*0.5f; + gGL.vertex3f(x,y,0.f); } + gGL.vertex3f(cosf(0.f)*0.5f, sinf(0.f)*0.5f, 0.f); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - // center object at 0 - glTranslatef(0.f, 0.f, - height / 2.0f); - - drawSide(level_of_detail); - drawBottom(level_of_detail); - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); + gGL.end(); } - -void LLCone::renderface(S32 level_of_detail, S32 face) -{ - if (face < 0 || face > 1) - { - llerror("LLCone::renderface() invalid face number", face); - return; - } - - if (level_of_detail < 0 || CONE_LEVELS_OF_DETAIL <= level_of_detail) - { - llerror("LLCone::renderface() invalid level of detail", level_of_detail); - return; - } - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - LLVertexBuffer::unbind(); - - switch(face) - { - case 0: - glTranslatef(0.f, 0.f, -0.5f); - drawSide(level_of_detail); - break; - case 1: - glTranslatef(0.f, 0.f, -0.5f); - drawBottom(level_of_detail); - break; - default: - llerror("LLCylinder::renderface() fell out of switch", 0); - break; - } - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); -} diff --git a/indra/newview/llcylinder.h b/indra/newview/llcylinder.h index 40a669ceb6..4369f06659 100644 --- a/indra/newview/llcylinder.h +++ b/indra/newview/llcylinder.h @@ -30,45 +30,18 @@ //#include "stdtypes.h" //#include "llgl.h" -// -// Cylinders -// -const S32 CYLINDER_LEVELS_OF_DETAIL = 4; -const S32 CYLINDER_FACES = 3; - -class LLCylinder -{ -public: - void prerender(); - void drawTop(S32 detail); - void drawSide(S32 detail); - void drawBottom(S32 detail); - void cleanupGL(); - - void render(F32 pixel_area); - void renderface(F32 pixel_area, S32 face); -}; - +#include "llvertexbuffer.h" // // Cones // -const S32 CONE_LOD_HIGHEST = 0; -const S32 CONE_LEVELS_OF_DETAIL = 4; -const S32 CONE_FACES = 2; - class LLCone { public: - void prerender(); - void cleanupGL(); - void drawSide(S32 detail); - void drawBottom(S32 detail); - void render(S32 level_of_detail); - void renderface(S32 level_of_detail, S32 face); + void render(S32 sides = 12); }; -extern LLCylinder gCylinder; + extern LLCone gCone; #endif diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index ef8819d9b5..a3f8eb377a 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -492,7 +492,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. - if (draw_glow_for_this_partition && + if (current_shader && + draw_glow_for_this_partition && params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) { // install glow-accumulating blend mode diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index dae995e1f5..a99f0200ce 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -270,7 +270,6 @@ void LLDrawPoolAvatar::beginDeferredRiggedAlpha() sVertexProgram = &gDeferredSkinnedAlphaProgram; gPipeline.bindDeferredShader(*sVertexProgram); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); gPipeline.enableLightsDynamic(); } @@ -279,7 +278,6 @@ void LLDrawPoolAvatar::endDeferredRiggedAlpha() LLVertexBuffer::unbind(); gPipeline.unbindDeferredShader(*sVertexProgram); sDiffuseChannel = 0; - LLVertexBuffer::sWeight4Loc = -1; sVertexProgram = NULL; } @@ -354,10 +352,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass) if (pass == 0) { sVertexProgram = &gDeferredAvatarShadowProgram; - if (sShaderLevel > 0) - { - gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; - } + //gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f); gGL.diffuseColor4f(1,1,1,1); @@ -373,7 +368,6 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass) sVertexProgram = &gDeferredAttachmentShadowProgram; sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->bind(); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } } @@ -392,7 +386,6 @@ void LLDrawPoolAvatar::endShadowPass(S32 pass) { LLVertexBuffer::unbind(); sVertexProgram->unbind(); - LLVertexBuffer::sWeight4Loc = -1; sVertexProgram = NULL; } } @@ -426,11 +419,6 @@ void LLDrawPoolAvatar::renderShadow(S32 pass) if (pass == 0) { - if (sShaderLevel > 0) - { - gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; - } - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } else @@ -587,11 +575,20 @@ void LLDrawPoolAvatar::beginImpostor() gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); sDiffuseChannel = 0; + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } } void LLDrawPoolAvatar::endImpostor() { gPipeline.enableLightsDynamic(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } } void LLDrawPoolAvatar::beginRigid() @@ -657,9 +654,10 @@ void LLDrawPoolAvatar::endDeferredImpostor() void LLDrawPoolAvatar::beginDeferredRigid() { - sVertexProgram = &gDeferredNonIndexedDiffuseProgram; + sVertexProgram = &gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; sVertexProgram->bind(); + sVertexProgram->setAlphaRange(0.2f, 1.f); } void LLDrawPoolAvatar::endDeferredRigid() @@ -773,7 +771,6 @@ void LLDrawPoolAvatar::beginRiggedSimple() { sDiffuseChannel = 0; sVertexProgram->bind(); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } } @@ -784,7 +781,6 @@ void LLDrawPoolAvatar::endRiggedSimple() { sVertexProgram->unbind(); sVertexProgram = NULL; - LLVertexBuffer::sWeight4Loc = -1; } } @@ -811,7 +807,34 @@ void LLDrawPoolAvatar::endRiggedFullbrightAlpha() void LLDrawPoolAvatar::beginRiggedGlow() { - beginRiggedFullbright(); + if (sShaderLevel > 0) + { + if (LLPipeline::sUnderWaterRender) + { + sVertexProgram = &gSkinnedObjectEmissiveWaterProgram; + } + else + { + sVertexProgram = &gSkinnedObjectEmissiveProgram; + } + } + else + { + if (LLPipeline::sUnderWaterRender) + { + sVertexProgram = &gObjectEmissiveNonIndexedWaterProgram; + } + else + { + sVertexProgram = &gObjectEmissiveNonIndexedProgram; + } + } + + if (sShaderLevel > 0 || gPipeline.canUseVertexShaders()) + { + sDiffuseChannel = 0; + sVertexProgram->bind(); + } } void LLDrawPoolAvatar::endRiggedGlow() @@ -848,7 +871,6 @@ void LLDrawPoolAvatar::beginRiggedFullbright() { sDiffuseChannel = 0; sVertexProgram->bind(); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } } @@ -859,7 +881,6 @@ void LLDrawPoolAvatar::endRiggedFullbright() { sVertexProgram->unbind(); sVertexProgram = NULL; - LLVertexBuffer::sWeight4Loc = -1; } } @@ -892,7 +913,6 @@ void LLDrawPoolAvatar::beginRiggedShinySimple() { sVertexProgram->bind(); LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } } @@ -904,7 +924,6 @@ void LLDrawPoolAvatar::endRiggedShinySimple() LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); sVertexProgram->unbind(); sVertexProgram = NULL; - LLVertexBuffer::sWeight4Loc = -1; } } @@ -938,7 +957,6 @@ void LLDrawPoolAvatar::beginRiggedFullbrightShiny() { sVertexProgram->bind(); LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } } @@ -950,7 +968,6 @@ void LLDrawPoolAvatar::endRiggedFullbrightShiny() LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); sVertexProgram->unbind(); sVertexProgram = NULL; - LLVertexBuffer::sWeight4Loc = -1; } } @@ -960,14 +977,12 @@ void LLDrawPoolAvatar::beginDeferredRiggedSimple() sVertexProgram = &gDeferredSkinnedDiffuseProgram; sDiffuseChannel = 0; sVertexProgram->bind(); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } void LLDrawPoolAvatar::endDeferredRiggedSimple() { LLVertexBuffer::unbind(); sVertexProgram->unbind(); - LLVertexBuffer::sWeight4Loc = -1; sVertexProgram = NULL; } @@ -977,7 +992,6 @@ void LLDrawPoolAvatar::beginDeferredRiggedBump() sVertexProgram->bind(); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT); } void LLDrawPoolAvatar::endDeferredRiggedBump() @@ -986,7 +1000,6 @@ void LLDrawPoolAvatar::endDeferredRiggedBump() sVertexProgram->disableTexture(LLViewerShaderMgr::BUMP_MAP); sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->unbind(); - LLVertexBuffer::sWeight4Loc = -1; normal_channel = -1; sDiffuseChannel = 0; sVertexProgram = NULL; @@ -996,10 +1009,10 @@ void LLDrawPoolAvatar::beginDeferredSkinned() { sShaderLevel = mVertexShaderLevel; sVertexProgram = &gDeferredAvatarProgram; - sRenderingSkinned = TRUE; sVertexProgram->bind(); + sVertexProgram->setAlphaRange(0.2f, 1.f); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gGL.getTexUnit(0)->activate(); @@ -1216,11 +1229,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) return; } - if (sShaderLevel > 0) - { - gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; - } - if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) { LLMatrix4 rot_mat; @@ -1632,34 +1640,3 @@ LLVertexBufferAvatar::LLVertexBufferAvatar() } -void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const -{ - /*if (sRenderingSkinned) - { - U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData; - - glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_VERTEX], (void*)(base + 0)); - glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL])); - glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0])); - - set_vertex_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], - LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_WEIGHT], (F32*)(base + mOffsets[TYPE_WEIGHT])); - - if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP) - { - set_binormals(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL], - LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_BINORMAL], (LLVector3*)(base + mOffsets[TYPE_BINORMAL])); - } - - if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH) - { - set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], - LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_CLOTHWEIGHT], (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT])); - } - } - else - {*/ - LLVertexBuffer::setupVertexBuffer(data_mask); - //} -} - diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index fcd8294af5..e0326bcfaf 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -176,6 +176,7 @@ public: RIGGED_FULLBRIGHT_SHINY_MASK = RIGGED_SIMPLE_MASK, RIGGED_GLOW_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_EMISSIVE | LLVertexBuffer::MAP_WEIGHT4, RIGGED_ALPHA_MASK = RIGGED_SIMPLE_MASK, RIGGED_FULLBRIGHT_ALPHA_MASK = RIGGED_FULLBRIGHT_MASK, @@ -214,7 +215,6 @@ class LLVertexBufferAvatar : public LLVertexBuffer { public: LLVertexBufferAvatar(); - virtual void setupVertexBuffer(U32 data_mask) const; }; extern S32 AVATAR_OFFSET_POS; diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 582e462871..80c202d4e2 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -46,7 +46,7 @@ static LLFastTimer::DeclareTimer FTM_RENDER_GRASS_DEFERRED("Deferred Grass"); void LLDrawPoolGlow::beginPostDeferredPass(S32 pass) { - gDeferredFullbrightProgram.bind(); + gDeferredEmissiveProgram.bind(); } static LLFastTimer::DeclareTimer FTM_RENDER_GLOW_PUSH("Glow Push"); @@ -76,7 +76,7 @@ void LLDrawPoolGlow::renderPostDeferred(S32 pass) void LLDrawPoolGlow::endPostDeferredPass(S32 pass) { - gDeferredFullbrightProgram.unbind(); + gDeferredEmissiveProgram.unbind(); LLRenderPass::endRenderPass(pass); } @@ -255,6 +255,7 @@ void LLDrawPoolGrass::prerender() void LLDrawPoolGrass::beginRenderPass(S32 pass) { LLFastTimer t(FTM_RENDER_GRASS); + stop_glerror(); if (LLPipeline::sUnderWaterRender) { diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 50a52ac4cf..da8e3e8b3a 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -142,7 +142,7 @@ void LLDrawPoolTree::beginDeferredPass(S32 pass) { LLFastTimer t(FTM_RENDER_TREES); - shader = &gDeferredNonIndexedDiffuseAlphaMaskProgram; + shader = &gDeferredTreeProgram; shader->bind(); shader->setAlphaRange(0.5f, 1.f); } @@ -169,8 +169,8 @@ void LLDrawPoolTree::beginShadowPass(S32 pass) glPolygonOffset(gSavedSettings.getF32("RenderDeferredTreeShadowOffset"), gSavedSettings.getF32("RenderDeferredTreeShadowBias")); - gDeferredShadowAlphaMaskProgram.bind(); - gDeferredShadowAlphaMaskProgram.setAlphaRange(0.5f, 1.f); + gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.setAlphaRange(0.5f, 1.f); } void LLDrawPoolTree::renderShadow(S32 pass) @@ -184,6 +184,7 @@ void LLDrawPoolTree::endShadowPass(S32 pass) glPolygonOffset(gSavedSettings.getF32("RenderDeferredSpotShadowOffset"), gSavedSettings.getF32("RenderDeferredSpotShadowBias")); + gDeferredTreeShadowProgram.unbind(); } diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 3286408f21..b9838f7da2 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3623,6 +3623,15 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim LLVertexBuffer::unbind(); + bool no_ff = LLGLSLShader::sNoFixedFunction; + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + LLGLSLShader::sNoFixedFunction = false; + + if (shader) + { + shader->unbind(); + } + stop_gloderror(); static U32 cur_name = 1; @@ -4003,6 +4012,13 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim mResourceCost = calcResourceCost(); + LLVertexBuffer::unbind(); + LLGLSLShader::sNoFixedFunction = no_ff; + if (shader) + { + shader->bind(); + } + /*if (which_lod == -1 && mScene[LLModel::LOD_PHYSICS].empty()) { //build physics scene mScene[LLModel::LOD_PHYSICS] = mScene[LLModel::LOD_LOW]; @@ -4950,7 +4966,7 @@ BOOL LLModelPreview::render() llassert(binding == model->mMaterialList[i]); - gGL.diffuseColor4fv(instance.mMaterial[i].mDiffuseColor.mV); + gGL.diffuseColor4fv(material.mDiffuseColor.mV); if (material.mDiffuseMap.notNull()) { @@ -5261,7 +5277,7 @@ BOOL LLModelPreview::render() const LLImportMaterial& material = instance.mMaterial[binding]; buffer->setBuffer(type_mask & buffer->getTypeMask()); - gGL.diffuseColor4fv(instance.mMaterial[i].mDiffuseColor.mV); + gGL.diffuseColor4fv(material.mDiffuseColor.mV); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); diff --git a/indra/newview/llhudeffectbeam.cpp b/indra/newview/llhudeffectbeam.cpp index 37b7b2e75d..ec5a0926c4 100644 --- a/indra/newview/llhudeffectbeam.cpp +++ b/indra/newview/llhudeffectbeam.cpp @@ -295,12 +295,12 @@ void LLHUDEffectBeam::render() F32 alpha = mFadeInterp.getCurVal()*mColor.mV[3]; alpha *= mInterpFade[i].getCurVal(); coloru.mV[3] = (U8)alpha; - glColor4ubv(coloru.mV); + gGL.color4ubv(coloru.mV); glPushMatrix(); glTranslatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]); glScalef(scale, scale, scale); - gSphere.render(0); + gSphere.render(); glPopMatrix(); } } diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index c4f8369cd0..a9b14829b2 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1519,6 +1519,7 @@ void LLManipTranslate::renderSnapGuides() F32 sz = mGridSizeMeters; F32 tiles = sz; + glMatrixMode(GL_TEXTURE); gGL.pushMatrix(); usc = 1.0f/usc; @@ -2243,7 +2244,7 @@ void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_ glRotatef(rot, axis.mV[0], axis.mV[1], axis.mV[2]); glScalef(mArrowScales.mV[index], mArrowScales.mV[index], mArrowScales.mV[index] * 1.5f); - gCone.render(CONE_LOD_HIGHEST); + gCone.render(); gGL.popMatrix(); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 8aa24e9261..568c967a9a 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -89,6 +89,7 @@ #include "llvoavatarself.h" #include "llvovolume.h" #include "pipeline.h" +#include "llviewershadermgr.h" #include "llglheaders.h" @@ -5570,8 +5571,7 @@ void pushWireframe(LLDrawable* drawable) for (S32 i = 0; i < rigged_volume->getNumVolumeFaces(); ++i) { const LLVolumeFace& face = rigged_volume->getVolumeFace(i); - glVertexPointer(3, GL_FLOAT, 16, face.mPositions); - glDrawElements(GL_TRIANGLES, face.mNumIndices, GL_UNSIGNED_SHORT, face.mIndices); + LLVertexBuffer::drawElements(LLRender::TRIANGLES, face.mPositions, face.mTexCoords, face.mNumIndices, face.mIndices); } gGL.popMatrix(); } @@ -5584,7 +5584,7 @@ void pushWireframe(LLDrawable* drawable) LLFace* face = drawable->getFace(i); if (face->verify()) { - pushVerts(face, LLVertexBuffer::MAP_VERTEX); + pushVerts(face, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); } } } @@ -5604,6 +5604,13 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color) return; } + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + + if (shader) + { + gHighlightProgram.bind(); + } + glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); @@ -5627,26 +5634,41 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color) if (LLSelectMgr::sRenderHiddenSelections) // && gFloaterTools && gFloaterTools->getVisible()) { gGL.blendFunc(LLRender::BF_SOURCE_COLOR, LLRender::BF_ONE); - LLGLEnable fog(GL_FOG); - glFogi(GL_FOG_MODE, GL_LINEAR); - float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec(); - LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0); - glFogf(GL_FOG_START, d); - glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV()))); - glFogfv(GL_FOG_COLOR, fogCol.mV); - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + if (shader) { - gGL.diffuseColor4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f); + gHighlightProgram.uniform4f("highlight_color", color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f); pushWireframe(drawable); } + else + { + LLGLEnable fog(GL_FOG); + glFogi(GL_FOG_MODE, GL_LINEAR); + float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec(); + LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0); + glFogf(GL_FOG_START, d); + glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV()))); + glFogfv(GL_FOG_COLOR, fogCol.mV); + + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + { + gGL.diffuseColor4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f); + pushWireframe(drawable); + } + } } gGL.flush(); gGL.setSceneBlendType(LLRender::BT_ALPHA); - gGL.diffuseColor4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2); + if (shader) + { + gHighlightProgram.uniform4f("highlight_color", color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2); + } + else + { + gGL.diffuseColor4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2); + } LLGLEnable offset(GL_POLYGON_OFFSET_LINE); glPolygonOffset(3.f, 3.f); glLineWidth(3.f); @@ -5654,6 +5676,11 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color) glLineWidth(1.f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); gGL.popMatrix(); + + if (shader) + { + shader->bind(); + } } //----------------------------------------------------------------------------- diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 064eaa49dd..3d371f7a44 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -4248,7 +4248,7 @@ public: LLVector3 local_start = mStart; LLVector3 local_end = mEnd; - if (!gPipeline.hasRenderType(drawable->getRenderType()) || !drawable->isVisible()) + if (!drawable || !gPipeline.hasRenderType(drawable->getRenderType()) || !drawable->isVisible()) { return false; } diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index 983108391f..2ec7534025 100644 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -506,7 +506,8 @@ void LLTracker::renderBeacon(LLVector3d pos_global, glMatrixMode(GL_MODELVIEW); - glPushMatrix(); + gGL.pushMatrix(); + { glTranslatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]); draw_shockwave(1024.f, gRenderStartTime.getElapsedTimeF32(), 32, fogged_color); @@ -559,9 +560,8 @@ void LLTracker::renderBeacon(LLVector3d pos_global, gGL.end(); } - - //gCylinder.render(1000); - glPopMatrix(); + } + gGL.popMatrix(); std::string text; text = llformat( "%.0f m", to_vec.magVec()); diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 5e4c124c45..2d08a27923 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -459,7 +459,10 @@ void LLViewerJointMesh::uploadJointMatrices() } } stop_glerror(); - glUniform4fvARB(gAvatarMatrixParam, 45, mat); + if (LLGLSLShader::sCurBoundShaderPtr) + { + LLGLSLShader::sCurBoundShaderPtr->uniform4fv(LLViewerShaderMgr::AVATAR_MATRIX, 45, mat); + } stop_glerror(); } else @@ -512,7 +515,8 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) { if (!mValid || !mMesh || !mFace || !mVisible || !mFace->getVertexBuffer() || - mMesh->getNumFaces() == 0) + mMesh->getNumFaces() == 0 || + (LLGLSLShader::sNoFixedFunction && LLGLSLShader::sCurBoundShaderPtr == NULL)) { return 0; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8684322eef..f07b21e3c3 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -97,6 +97,8 @@ LLGLSLShader gObjectAlphaMaskNoColorProgram; LLGLSLShader gObjectAlphaMaskNoColorWaterProgram; LLGLSLShader gObjectFullbrightNonIndexedProgram; LLGLSLShader gObjectFullbrightNonIndexedWaterProgram; +LLGLSLShader gObjectEmissiveNonIndexedProgram; +LLGLSLShader gObjectEmissiveNonIndexedWaterProgram; LLGLSLShader gObjectFullbrightShinyNonIndexedProgram; LLGLSLShader gObjectFullbrightShinyNonIndexedWaterProgram; LLGLSLShader gObjectShinyNonIndexedProgram; @@ -105,11 +107,13 @@ LLGLSLShader gObjectShinyNonIndexedWaterProgram; //object hardware skinning shaders LLGLSLShader gSkinnedObjectSimpleProgram; LLGLSLShader gSkinnedObjectFullbrightProgram; +LLGLSLShader gSkinnedObjectEmissiveProgram; LLGLSLShader gSkinnedObjectFullbrightShinyProgram; LLGLSLShader gSkinnedObjectShinySimpleProgram; LLGLSLShader gSkinnedObjectSimpleWaterProgram; LLGLSLShader gSkinnedObjectFullbrightWaterProgram; +LLGLSLShader gSkinnedObjectEmissiveWaterProgram; LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; @@ -147,12 +151,14 @@ LLGLSLShader gDeferredDiffuseProgram; LLGLSLShader gDeferredDiffuseAlphaMaskProgram; LLGLSLShader gDeferredNonIndexedDiffuseProgram; LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; +LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; LLGLSLShader gDeferredSkinnedDiffuseProgram; LLGLSLShader gDeferredSkinnedBumpProgram; LLGLSLShader gDeferredSkinnedAlphaProgram; LLGLSLShader gDeferredBumpProgram; LLGLSLShader gDeferredTerrainProgram; LLGLSLShader gDeferredTreeProgram; +LLGLSLShader gDeferredTreeShadowProgram; LLGLSLShader gDeferredAvatarProgram; LLGLSLShader gDeferredAvatarAlphaProgram; LLGLSLShader gDeferredLightProgram; @@ -169,6 +175,7 @@ LLGLSLShader gDeferredAttachmentShadowProgram; LLGLSLShader gDeferredAlphaProgram; LLGLSLShader gDeferredAvatarEyesProgram; LLGLSLShader gDeferredFullbrightProgram; +LLGLSLShader gDeferredEmissiveProgram; LLGLSLShader gDeferredGIProgram; LLGLSLShader gDeferredGIFinalProgram; LLGLSLShader gDeferredPostGIProgram; @@ -179,10 +186,6 @@ LLGLSLShader gDeferredWLCloudProgram; LLGLSLShader gDeferredStarProgram; LLGLSLShader gLuminanceGatherProgram; - -//current avatar shader parameter pointer -GLint gAvatarMatrixParam; - LLViewerShaderMgr::LLViewerShaderMgr() : mVertexShaderLevel(SHADER_COUNT, 0), mMaxAvatarShaderLevel(0) @@ -223,14 +226,18 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gTreeWaterProgram); mShaderList.push_back(&gObjectFullbrightNonIndexedProgram); mShaderList.push_back(&gObjectFullbrightNonIndexedWaterProgram); + mShaderList.push_back(&gObjectEmissiveNonIndexedProgram); + mShaderList.push_back(&gObjectEmissiveNonIndexedWaterProgram); mShaderList.push_back(&gObjectFullbrightShinyNonIndexedProgram); mShaderList.push_back(&gObjectFullbrightShinyNonIndexedWaterProgram); mShaderList.push_back(&gSkinnedObjectSimpleProgram); mShaderList.push_back(&gSkinnedObjectFullbrightProgram); + mShaderList.push_back(&gSkinnedObjectEmissiveProgram); mShaderList.push_back(&gSkinnedObjectFullbrightShinyProgram); mShaderList.push_back(&gSkinnedObjectShinySimpleProgram); mShaderList.push_back(&gSkinnedObjectSimpleWaterProgram); mShaderList.push_back(&gSkinnedObjectFullbrightWaterProgram); + mShaderList.push_back(&gSkinnedObjectEmissiveWaterProgram); mShaderList.push_back(&gSkinnedObjectFullbrightShinyWaterProgram); mShaderList.push_back(&gSkinnedObjectShinySimpleWaterProgram); mShaderList.push_back(&gTerrainProgram); @@ -251,6 +258,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredAlphaProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); + mShaderList.push_back(&gDeferredEmissiveProgram); mShaderList.push_back(&gDeferredAvatarEyesProgram); mShaderList.push_back(&gDeferredPostGIProgram); mShaderList.push_back(&gDeferredEdgeProgram); @@ -690,6 +698,8 @@ void LLViewerShaderMgr::unloadShaders() gObjectAlphaMaskNoColorWaterProgram.unload(); gObjectFullbrightNonIndexedProgram.unload(); gObjectFullbrightNonIndexedWaterProgram.unload(); + gObjectEmissiveNonIndexedProgram.unload(); + gObjectEmissiveNonIndexedWaterProgram.unload(); gTreeProgram.unload(); gTreeWaterProgram.unload(); @@ -700,11 +710,13 @@ void LLViewerShaderMgr::unloadShaders() gSkinnedObjectSimpleProgram.unload(); gSkinnedObjectFullbrightProgram.unload(); + gSkinnedObjectEmissiveProgram.unload(); gSkinnedObjectFullbrightShinyProgram.unload(); gSkinnedObjectShinySimpleProgram.unload(); gSkinnedObjectSimpleWaterProgram.unload(); gSkinnedObjectFullbrightWaterProgram.unload(); + gSkinnedObjectEmissiveWaterProgram.unload(); gSkinnedObjectFullbrightShinyWaterProgram.unload(); gSkinnedObjectShinySimpleWaterProgram.unload(); @@ -730,6 +742,7 @@ void LLViewerShaderMgr::unloadShaders() gDeferredDiffuseProgram.unload(); gDeferredDiffuseAlphaMaskProgram.unload(); gDeferredNonIndexedDiffuseAlphaMaskProgram.unload(); + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.unload(); gDeferredNonIndexedDiffuseProgram.unload(); gDeferredSkinnedDiffuseProgram.unload(); gDeferredSkinnedBumpProgram.unload(); @@ -1086,9 +1099,11 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (mVertexShaderLevel[SHADER_DEFERRED] == 0) { gDeferredTreeProgram.unload(); + gDeferredTreeShadowProgram.unload(); gDeferredDiffuseProgram.unload(); gDeferredDiffuseAlphaMaskProgram.unload(); gDeferredNonIndexedDiffuseAlphaMaskProgram.unload(); + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.unload(); gDeferredNonIndexedDiffuseProgram.unload(); gDeferredSkinnedDiffuseProgram.unload(); gDeferredSkinnedBumpProgram.unload(); @@ -1111,6 +1126,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.unload(); gDeferredAlphaProgram.unload(); gDeferredFullbrightProgram.unload(); + gDeferredEmissiveProgram.unload(); gDeferredAvatarEyesProgram.unload(); gDeferredPostGIProgram.unload(); gDeferredEdgeProgram.unload(); @@ -1163,6 +1179,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredNonIndexedDiffuseAlphaMaskProgram.createShader(NULL, NULL); } + + if (success) + { + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mName = "Deferred Diffuse Non-Indexed Alpha Mask Shader"; + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.clear(); + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("deferred/diffuseNoColorV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskNoColorF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.createShader(NULL, NULL); + } if (success) { @@ -1236,6 +1262,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { + gDeferredTreeShadowProgram.mName = "Deferred Tree Shadow Shader"; + gDeferredTreeShadowProgram.mShaderFiles.clear(); + gDeferredTreeShadowProgram.mShaderFiles.push_back(make_pair("deferred/treeShadowV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredTreeShadowProgram.mShaderFiles.push_back(make_pair("deferred/treeShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredTreeShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredTreeShadowProgram.createShader(NULL, NULL); + } + + if (success) + { gDeferredImpostorProgram.mName = "Deferred Impostor Shader"; gDeferredImpostorProgram.mShaderFiles.clear(); gDeferredImpostorProgram.mShaderFiles.push_back(make_pair("deferred/impostorV.glsl", GL_VERTEX_SHADER_ARB)); @@ -1438,6 +1474,20 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { + gDeferredEmissiveProgram.mName = "Deferred Emissive Shader"; + gDeferredEmissiveProgram.mFeatures.calculatesAtmospherics = true; + gDeferredEmissiveProgram.mFeatures.hasGamma = true; + gDeferredEmissiveProgram.mFeatures.hasTransport = true; + gDeferredEmissiveProgram.mFeatures.mIndexedTextureChannels = gGLManager.mNumTextureImageUnits; + gDeferredEmissiveProgram.mShaderFiles.clear(); + gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredEmissiveProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredEmissiveProgram.createShader(NULL, NULL); + } + + if (success) + { // load water shader gDeferredWaterProgram.mName = "Deferred Water Shader"; gDeferredWaterProgram.mFeatures.calculatesAtmospherics = true; @@ -1553,7 +1603,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true; gDeferredAvatarAlphaProgram.mShaderFiles.clear(); gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarAlphaProgram.createShader(NULL, &mAvatarUniforms); } @@ -1736,12 +1786,16 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectAlphaMaskNoColorWaterProgram.unload(); gObjectFullbrightNonIndexedProgram.unload(); gObjectFullbrightNonIndexedWaterProgram.unload(); + gObjectEmissiveNonIndexedProgram.unload(); + gObjectEmissiveNonIndexedWaterProgram.unload(); gSkinnedObjectSimpleProgram.unload(); gSkinnedObjectFullbrightProgram.unload(); + gSkinnedObjectEmissiveProgram.unload(); gSkinnedObjectFullbrightShinyProgram.unload(); gSkinnedObjectShinySimpleProgram.unload(); gSkinnedObjectSimpleWaterProgram.unload(); gSkinnedObjectFullbrightWaterProgram.unload(); + gSkinnedObjectEmissiveWaterProgram.unload(); gSkinnedObjectFullbrightShinyWaterProgram.unload(); gSkinnedObjectShinySimpleWaterProgram.unload(); gTreeProgram.unload(); @@ -1921,6 +1975,37 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (success) { + gObjectEmissiveNonIndexedProgram.mName = "Non Indexed Emissive Shader"; + gObjectEmissiveNonIndexedProgram.mFeatures.calculatesAtmospherics = true; + gObjectEmissiveNonIndexedProgram.mFeatures.hasGamma = true; + gObjectEmissiveNonIndexedProgram.mFeatures.hasTransport = true; + gObjectEmissiveNonIndexedProgram.mFeatures.isFullbright = true; + gObjectEmissiveNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectEmissiveNonIndexedProgram.mShaderFiles.clear(); + gObjectEmissiveNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectEmissiveNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectEmissiveNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectEmissiveNonIndexedProgram.createShader(NULL, NULL); + } + + if (success) + { + gObjectEmissiveNonIndexedWaterProgram.mName = "Non Indexed Emissive Water Shader"; + gObjectEmissiveNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectEmissiveNonIndexedWaterProgram.mFeatures.isFullbright = true; + gObjectEmissiveNonIndexedWaterProgram.mFeatures.hasWaterFog = true; + gObjectEmissiveNonIndexedWaterProgram.mFeatures.hasTransport = true; + gObjectEmissiveNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectEmissiveNonIndexedWaterProgram.mShaderFiles.clear(); + gObjectEmissiveNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectEmissiveNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectEmissiveNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectEmissiveNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectEmissiveNonIndexedWaterProgram.createShader(NULL, NULL); + } + + if (success) + { gObjectFullbrightNoColorProgram.mName = "Non Indexed no color Fullbright Shader"; gObjectFullbrightNoColorProgram.mFeatures.calculatesAtmospherics = true; gObjectFullbrightNoColorProgram.mFeatures.hasGamma = true; @@ -2301,6 +2386,39 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (success) { + gSkinnedObjectEmissiveProgram.mName = "Skinned Emissive Shader"; + gSkinnedObjectEmissiveProgram.mFeatures.calculatesAtmospherics = true; + gSkinnedObjectEmissiveProgram.mFeatures.hasGamma = true; + gSkinnedObjectEmissiveProgram.mFeatures.hasTransport = true; + gSkinnedObjectEmissiveProgram.mFeatures.isFullbright = true; + gSkinnedObjectEmissiveProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectEmissiveProgram.mFeatures.disableTextureIndex = true; + gSkinnedObjectEmissiveProgram.mShaderFiles.clear(); + gSkinnedObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/emissiveSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); + gSkinnedObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSkinnedObjectEmissiveProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gSkinnedObjectEmissiveProgram.createShader(NULL, NULL); + } + + if (success) + { + gSkinnedObjectEmissiveWaterProgram.mName = "Skinned Emissive Water Shader"; + gSkinnedObjectEmissiveWaterProgram.mFeatures.calculatesAtmospherics = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.hasGamma = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.hasTransport = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.isFullbright = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.hasObjectSkinning = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.disableTextureIndex = true; + gSkinnedObjectEmissiveWaterProgram.mFeatures.hasWaterFog = true; + gSkinnedObjectEmissiveWaterProgram.mShaderFiles.clear(); + gSkinnedObjectEmissiveWaterProgram.mShaderFiles.push_back(make_pair("objects/emissiveSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); + gSkinnedObjectEmissiveWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSkinnedObjectEmissiveWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gSkinnedObjectEmissiveWaterProgram.createShader(NULL, NULL); + } + + if (success) + { gSkinnedObjectFullbrightShinyProgram.mName = "Skinned Fullbright Shiny Shader"; gSkinnedObjectFullbrightShinyProgram.mFeatures.calculatesAtmospherics = true; gSkinnedObjectFullbrightShinyProgram.mFeatures.hasGamma = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index ced7ed06d9..1b658c45ba 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -71,15 +71,6 @@ public: SHADER_COUNT }; - typedef enum - { - MATERIAL_COLOR = 0, - SPECULAR_COLOR, - BINORMAL, - OBJECT_WEIGHT, - END_RESERVED_ATTRIBS - } eGLSLReservedAttribs; - typedef enum { DIFFUSE_MAP = 0, @@ -309,6 +300,8 @@ extern LLGLSLShader gObjectFullbrightAlphaMaskProgram; extern LLGLSLShader gObjectFullbrightWaterAlphaMaskProgram; extern LLGLSLShader gObjectFullbrightNonIndexedProgram; extern LLGLSLShader gObjectFullbrightNonIndexedWaterProgram; +extern LLGLSLShader gObjectEmissiveNonIndexedProgram; +extern LLGLSLShader gObjectEmissiveNonIndexedWaterProgram; extern LLGLSLShader gObjectBumpProgram; extern LLGLSLShader gTreeProgram; extern LLGLSLShader gTreeWaterProgram; @@ -328,11 +321,13 @@ extern LLGLSLShader gObjectShinyNonIndexedWaterProgram; extern LLGLSLShader gSkinnedObjectSimpleProgram; extern LLGLSLShader gSkinnedObjectFullbrightProgram; +extern LLGLSLShader gSkinnedObjectEmissiveProgram; extern LLGLSLShader gSkinnedObjectFullbrightShinyProgram; extern LLGLSLShader gSkinnedObjectShinySimpleProgram; extern LLGLSLShader gSkinnedObjectSimpleWaterProgram; extern LLGLSLShader gSkinnedObjectFullbrightWaterProgram; +extern LLGLSLShader gSkinnedObjectEmissiveWaterProgram; extern LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; @@ -368,6 +363,7 @@ extern LLGLSLShader gDeferredWaterProgram; extern LLGLSLShader gDeferredDiffuseProgram; extern LLGLSLShader gDeferredDiffuseAlphaMaskProgram; extern LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; +extern LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; extern LLGLSLShader gDeferredNonIndexedDiffuseProgram; extern LLGLSLShader gDeferredSkinnedDiffuseProgram; extern LLGLSLShader gDeferredSkinnedBumpProgram; @@ -375,6 +371,7 @@ extern LLGLSLShader gDeferredSkinnedAlphaProgram; extern LLGLSLShader gDeferredBumpProgram; extern LLGLSLShader gDeferredTerrainProgram; extern LLGLSLShader gDeferredTreeProgram; +extern LLGLSLShader gDeferredTreeShadowProgram; extern LLGLSLShader gDeferredLightProgram; extern LLGLSLShader gDeferredMultiLightProgram; extern LLGLSLShader gDeferredSpotLightProgram; @@ -394,6 +391,7 @@ extern LLGLSLShader gDeferredAvatarShadowProgram; extern LLGLSLShader gDeferredAttachmentShadowProgram; extern LLGLSLShader gDeferredAlphaProgram; extern LLGLSLShader gDeferredFullbrightProgram; +extern LLGLSLShader gDeferredEmissiveProgram; extern LLGLSLShader gDeferredAvatarEyesProgram; extern LLGLSLShader gDeferredAvatarAlphaProgram; extern LLGLSLShader gDeferredWLSkyProgram; @@ -401,8 +399,5 @@ extern LLGLSLShader gDeferredWLCloudProgram; extern LLGLSLShader gDeferredStarProgram; extern LLGLSLShader gLuminanceGatherProgram; -//current avatar shader parameter pointer -extern GLint gAvatarMatrixParam; - #endif diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 36d8d6a39b..9f66c074fd 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1720,10 +1720,7 @@ void LLViewerWindow::initGLDefaults() glCullFace(GL_BACK); // RN: Need this for translation and stretch manip. - gCone.prerender(); gBox.prerender(); - gSphere.prerender(); - gCylinder.prerender(); } struct MainPanel : public LLPanel @@ -2233,6 +2230,10 @@ void LLViewerWindow::drawDebugText() gGL.color4f(1,1,1,1); gGL.pushMatrix(); gGL.pushUIMatrix(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } { // scale view by UI global scale factor and aspect ratio correction factor gGL.scaleUI(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f); @@ -2242,6 +2243,10 @@ void LLViewerWindow::drawDebugText() gGL.popMatrix(); gGL.flush(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } } void LLViewerWindow::draw() @@ -3441,26 +3446,26 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, if (drawable && drawable->isLight()) { LLVOVolume* vovolume = drawable->getVOVolume(); - glPushMatrix(); + gGL.pushMatrix(); LLVector3 center = drawable->getPositionAgent(); - glTranslatef(center[0], center[1], center[2]); + gGL.translatef(center[0], center[1], center[2]); F32 scale = vovolume->getLightRadius(); - glScalef(scale, scale, scale); + gGL.scalef(scale, scale, scale); LLColor4 color(vovolume->getLightColor(), .5f); - gGL.diffuseColor4fv(color.mV); + gGL.color4fv(color.mV); F32 pixel_area = 100000.f; // Render Outside - gSphere.render(pixel_area); + gSphere.render(); // Render Inside glCullFace(GL_FRONT); - gSphere.render(pixel_area); + gSphere.render(); glCullFace(GL_BACK); - glPopMatrix(); + gGL.popMatrix(); } return true; } @@ -4635,10 +4640,7 @@ void LLViewerWindow::stopGL(BOOL save_state) gPipeline.destroyGL(); } - gCone.cleanupGL(); gBox.cleanupGL(); - gSphere.cleanupGL(); - gCylinder.cleanupGL(); if(gPostProcess) { diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 0b746c841c..7e00350926 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -112,20 +112,6 @@ public: glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR])); } - if (data_mask & MAP_WEIGHT) - { - glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT])); - } - - if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1) - { - glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4])); - } - - if (data_mask & MAP_CLOTHWEIGHT) - { - glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT])); - } if (data_mask & MAP_VERTEX) { glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0)); diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index 02d914a812..22fba90f65 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -91,8 +91,9 @@ void LLWLParamSet::update(LLGLSLShader * shader) const val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; val.mV[2] = (F32) i->second[2].asReal(); val.mV[3] = (F32) i->second[3].asReal(); - - shader->uniform4fv(param, 1, val.mV); + stop_glerror(); + shader->uniform4fv(param, 1, val.mV); + stop_glerror(); } else // param is the uniform name { @@ -118,8 +119,9 @@ void LLWLParamSet::update(LLGLSLShader * shader) const { val.mV[0] = i->second.asBoolean(); } - + stop_glerror(); shader->uniform4fv(param, 1, val.mV); + stop_glerror(); } } } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d296081612..f6d021fda8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -458,7 +458,7 @@ void LLPipeline::init() } mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); - mDeferredVB->allocateBuffer(3, 0, true); + mDeferredVB->allocateBuffer(8, 0, true); setLightingDetail(-1); } @@ -3494,7 +3494,7 @@ void LLPipeline::renderHighlights() if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightProgram.bind(); - gHighlightProgram.vertexAttrib4f(LLViewerShaderMgr::MATERIAL_COLOR,1,1,1,0.5f); + gHighlightProgram.uniform4f("highlight_color",1,1,1,0.5f); } if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) @@ -3526,7 +3526,7 @@ void LLPipeline::renderHighlights() color.setVec(1.f, 0.f, 0.f, 0.5f); if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { - gHighlightProgram.vertexAttrib4f(LLViewerShaderMgr::MATERIAL_COLOR,1,0,0,0.5f); + gHighlightProgram.uniform4f("highlight_color",1,0,0,0.5f); } int count = mHighlightFaces.size(); for (S32 i = 0; i < count; i++) @@ -7021,7 +7021,7 @@ void LLPipeline::renderDeferredLighting() LLVector4 dir(mSunDir, 0.f); glh::vec4f tc(dir.mV); mat.mult_matrix_vec(tc); - mTransformedSunDir.set(dir.mV); + mTransformedSunDir.set(tc.v); } glPushMatrix(); @@ -7036,7 +7036,7 @@ void LLPipeline::renderDeferredLighting() { //paint shadow/SSAO light map (direct lighting lightmap) LLFastTimer ftm(FTM_SUN_SHADOW); bindDeferredShader(gDeferredSunProgram, 0); - + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); glClearColor(1,1,1,1); mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT); glClearColor(0,0,0,0); @@ -7067,7 +7067,7 @@ void LLPipeline::renderDeferredLighting() LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); stop_glerror(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); } @@ -7091,7 +7091,8 @@ void LLPipeline::renderDeferredLighting() gDeferredEdgeProgram.bind(); mEdgeMap.bindTarget(); bindDeferredShader(gDeferredEdgeProgram); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(gDeferredEdgeProgram); mEdgeMap.flush(); } @@ -7113,7 +7114,8 @@ void LLPipeline::renderDeferredLighting() gLuminanceGatherProgram.uniform2f("screen_res", mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight()); mLuminanceMap.bindTarget(); bindDeferredShader(gLuminanceGatherProgram); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(gLuminanceGatherProgram); mLuminanceMap.flush(); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLuminanceMap.getTexture(), true); @@ -7131,7 +7133,8 @@ void LLPipeline::renderDeferredLighting() mGIMapPost[0].bindTarget(); bindDeferredShader(gDeferredGIProgram, 0, &mGIMap, 0, mTrueNoiseMap); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(gDeferredGIProgram); mGIMapPost[0].flush(); } @@ -7156,7 +7159,8 @@ void LLPipeline::renderDeferredLighting() LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_FALSE); stop_glerror(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); } @@ -7171,7 +7175,8 @@ void LLPipeline::renderDeferredLighting() LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_FALSE); stop_glerror(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); } mGIMapPost[0].flush(); @@ -7185,13 +7190,12 @@ void LLPipeline::renderDeferredLighting() LLFastTimer ftm(FTM_SOFTEN_SHADOW); //blur lightmap mDeferredLight[1].bindTarget(); - glClearColor(1,1,1,1); mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT); glClearColor(0,0,0,0); bindDeferredShader(gDeferredBlurLightProgram); - + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian"); const U32 kern_length = 4; F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize"); @@ -7219,7 +7223,7 @@ void LLPipeline::renderDeferredLighting() LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); stop_glerror(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); } @@ -7227,6 +7231,7 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(gDeferredBlurLightProgram); bindDeferredShader(gDeferredBlurLightProgram, 1); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredLight[0].bindTarget(); gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f); @@ -7235,7 +7240,7 @@ void LLPipeline::renderDeferredLighting() LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); stop_glerror(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); stop_glerror(); } mDeferredLight[0].flush(); @@ -7338,12 +7343,12 @@ void LLPipeline::renderDeferredLighting() std::list<LLVector4> light_colors; LLVertexBuffer::unbind(); + LLVector4a* v = (LLVector4a*) vert.get(); - F32 v[24]; - glVertexPointer(3, GL_FLOAT, 0, v); - { bindDeferredShader(gDeferredLightProgram); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + LLGLDepthTest depth(GL_TRUE, GL_FALSE); for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) { @@ -7398,15 +7403,15 @@ void LLPipeline::renderDeferredLighting() //correspond to their axis facing, with bit position 3,2,1 matching //axis facing x,y,z, bit set meaning positive facing, bit clear //meaning negative facing - v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000 - v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001 - v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010 - v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011 + v[0].set(c[0]-s,c[1]-s,c[2]-s); // 0 - 0000 + v[1].set(c[0]-s,c[1]-s,c[2]+s); // 1 - 0001 + v[2].set(c[0]-s,c[1]+s,c[2]-s); // 2 - 0010 + v[3].set(c[0]-s,c[1]+s,c[2]+s); // 3 - 0011 - v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100 - v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101 - v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110 - v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111 + v[4].set(c[0]+s,c[1]-s,c[2]-s); // 4 - 0100 + v[5].set(c[0]+s,c[1]-s,c[2]+s); // 5 - 0101 + v[6].set(c[0]+s,c[1]+s,c[2]-s); // 6 - 0110 + v[7].set(c[0]+s,c[1]+s,c[2]+s); // 7 - 0111 if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || camera->getOrigin().mV[0] < c[0] - s - 0.2f || @@ -7425,8 +7430,12 @@ void LLPipeline::renderDeferredLighting() } LLFastTimer ftm(FTM_LOCAL_LIGHTS); - glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); - gGL.diffuseColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); + //glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); + gDeferredLightProgram.uniform3fv("center", 1, tc.v); + gDeferredLightProgram.uniform1f("size", s*s); + gDeferredLightProgram.uniform3fv("color", 1, col.mV); + gDeferredLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f); + //gGL.diffuseColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center)); stop_glerror(); @@ -7453,6 +7462,8 @@ void LLPipeline::renderDeferredLighting() LLGLDepthTest depth(GL_TRUE, GL_FALSE); bindDeferredShader(gDeferredSpotLightProgram); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + gDeferredSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) @@ -7481,18 +7492,20 @@ void LLPipeline::renderDeferredLighting() //correspond to their axis facing, with bit position 3,2,1 matching //axis facing x,y,z, bit set meaning positive facing, bit clear //meaning negative facing - v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000 - v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001 - v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010 - v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011 + v[0].set(c[0]-s,c[1]-s,c[2]-s); // 0 - 0000 + v[1].set(c[0]-s,c[1]-s,c[2]+s); // 1 - 0001 + v[2].set(c[0]-s,c[1]+s,c[2]-s); // 2 - 0010 + v[3].set(c[0]-s,c[1]+s,c[2]+s); // 3 - 0011 - v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100 - v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101 - v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110 - v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111 - - glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); - gGL.diffuseColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); + v[4].set(c[0]+s,c[1]-s,c[2]-s); // 4 - 0100 + v[5].set(c[0]+s,c[1]-s,c[2]+s); // 5 - 0101 + v[6].set(c[0]+s,c[1]+s,c[2]-s); // 6 - 0110 + v[7].set(c[0]+s,c[1]+s,c[2]+s); // 7 - 0111 + + gDeferredSpotLightProgram.uniform3fv("center", 1, tc.v); + gDeferredSpotLightProgram.uniform1f("size", s*s); + gDeferredSpotLightProgram.uniform3fv("color", 1, col.mV); + gDeferredSpotLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f); glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center)); } @@ -7500,6 +7513,11 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(gDeferredSpotLightProgram); } + //reset mDeferredVB to fullscreen triangle + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); + { bindDeferredShader(gDeferredMultiLightProgram); @@ -7554,6 +7572,8 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) { LLFastTimer ftm(FTM_PROJECTORS); @@ -7575,9 +7595,11 @@ void LLPipeline::renderDeferredLighting() LLColor3 col = volume->getLightColor(); col *= volume->getLightIntensity(); - glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); - gGL.diffuseColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + gDeferredMultiSpotLightProgram.uniform3fv("center", 1, tc.v); + gDeferredMultiSpotLightProgram.uniform1f("size", s*s); + gDeferredMultiSpotLightProgram.uniform3fv("color", 1, col.mV); + gDeferredMultiSpotLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); } gDeferredMultiSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); @@ -7610,7 +7632,7 @@ void LLPipeline::renderDeferredLighting() bindDeferredShader(gDeferredPostProgram, 0, &mGIMapPost[0]); gDeferredPostProgram.bind(); - + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); LLVertexBuffer::unbind(); // glVertexPointer(2, GL_FLOAT, 0, vert); @@ -7622,8 +7644,8 @@ void LLPipeline::renderDeferredLighting() glPushMatrix(); glLoadIdentity(); - glDrawArrays(GL_TRIANGLES, 0, 3); - + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); @@ -8294,12 +8316,14 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowAlphaMaskProgram.bind(); gDeferredShadowAlphaMaskProgram.setAlphaRange(0.6f, 1.f); renderObjects(LLRenderPass::PASS_ALPHA_SHADOW, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR, TRUE); - gGL.diffuseColor4f(1,1,1,1); + gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.setAlphaRange(0.6f, 1.f); renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); } //glCullFace(GL_BACK); + gDeferredShadowProgram.bind(); gGLLastMatrix = NULL; glLoadMatrixd(gGLModelView); doOcclusion(shadow_cam); @@ -9676,6 +9700,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) static const F32 clip_plane = 0.99999f; + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + gGL.color4ub(64,64,64,255); gGL.begin(LLRender::QUADS); gGL.vertex3f(-1, -1, clip_plane); @@ -9685,6 +9714,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) gGL.end(); gGL.flush(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } + glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); |