diff options
author | Oz Linden <oz@lindenlab.com> | 2013-04-25 16:54:49 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2013-04-25 16:54:49 -0400 |
commit | 6f953cc97b90eff43d69c2bda28fc9863fc57214 (patch) | |
tree | 326124bad515a7831631863d91348549568bb9ee /indra/newview | |
parent | d7136bac52dc36cca1f5b89fdc26fd323be468c5 (diff) | |
parent | 3a2576cefa97f50640adb596a5d01fa287f7033f (diff) |
merge changes for latest rendering fixes
Diffstat (limited to 'indra/newview')
19 files changed, 231 insertions, 192 deletions
diff --git a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl index ff30560adc..2745d5fd95 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl @@ -30,24 +30,18 @@ uniform mat4 matrixPalette[64]; mat4 getObjectSkinnedTransform() { + int i; - float w0 = fract(weight4.x); - float w1 = fract(weight4.y); - float w2 = fract(weight4.z); - float w3 = fract(weight4.w); - - int i0 = int(floor(weight4.x)); - int i1 = int(floor(weight4.y)); - int i2 = int(floor(weight4.z)); - int i3 = int(floor(weight4.w)); - - //float scale = 1.0/(w.x+w.y+w.z+w.w); - //w *= scale; + vec4 w = fract(weight4); + vec4 index = floor(weight4); + + float scale = 1.0/(w.x+w.y+w.z+w.w); + w *= scale; - mat4 mat = matrixPalette[i0]*w0; - mat += matrixPalette[i1]*w1; - mat += matrixPalette[i2]*w2; - mat += matrixPalette[i3]*w3; + mat4 mat = matrixPalette[int(index.x)]*w.x; + mat += matrixPalette[int(index.y)]*w.y; + mat += matrixPalette[int(index.z)]*w.z; + mat += matrixPalette[int(index.w)]*w.w; return mat; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d175d2b518..9f1fdb4385 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,7 +35,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if INDEX_MODE != INDEXED +#ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif @@ -52,7 +52,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -104,16 +104,18 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if INDEX_MODE == INDEXED +#ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - diff.rgb = pow(diff.rgb, vec3(2.2)); -#if INDEX_MODE == NON_INDEXED_NO_COLOR - float vertex_color_alpha = 1.0; + + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + +#ifdef USE_VERTEX_COLOR + float vertex_color_alpha = vertex_color.a; #else - float vertex_color_alpha = vertex_color.a; + float vertex_color_alpha = 1.0; #endif vec3 normal = vary_norm; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index 4c26621a88..77d02b36ff 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -34,25 +34,31 @@ uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; -#if INDEX_MODE == INDEXED + +#ifdef USE_INDEXED_TEX void passTextureIndex(); #endif + ATTRIBUTE vec3 normal; -#if INDEX_MODE != NON_INDEXED_NO_COLOR + +#ifdef USE_VERTEX_COLOR ATTRIBUTE vec4 diffuse_color; #endif + ATTRIBUTE vec2 texcoord0; -#if HAS_SKIN +#ifdef HAS_SKIN mat4 getObjectSkinnedTransform(); -#elif IS_AVATAR_SKIN +#else +#ifdef IS_AVATAR_SKIN mat4 getSkinnedTransform(); #endif +#endif vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); -float calcDirectionalLight(vec3 n, vec3 l); +vec3 calcDirectionalLight(vec3 n, vec3 l); vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); @@ -65,7 +71,7 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -80,13 +86,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -float calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - return a; + return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -113,7 +119,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(dot(n, lv), 0.0); } - return da; + return vec3(da,da,da); } void main() @@ -122,7 +128,7 @@ void main() vec3 norm; //transform vertex -#if HAS_SKIN +#ifdef HAS_SKIN mat4 trans = getObjectSkinnedTransform(); trans = modelview_matrix * trans; @@ -132,7 +138,9 @@ void main() norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); vec4 frag_pos = projection_matrix * pos; gl_Position = frag_pos; -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN mat4 trans = getSkinnedTransform(); vec4 pos_in = vec4(position.xyz, 1.0); pos.x = dot(trans[0], pos_in); @@ -154,7 +162,9 @@ void main() gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); #endif -#if INDEX_MODE == INDEXED +#endif + +#ifdef USE_INDEXED_TEX passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; #else @@ -166,34 +176,46 @@ void main() calcAtmospherics(pos.xyz); -#if INDEX_MODE == NON_INDEXED_NO_COLOR +#ifndef USE_VERTEX_COLOR vec4 diffuse_color = vec4(1,1,1,1); #endif //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - vary_pointlight_col = diffuse_color.rgb; + vec3 diff = pow(diffuse_color.rgb, vec3(2.2)); + + + + vary_pointlight_col = diff; + col.rgb = vec3(0,0,0); // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); + col.rgb = atmosAmbient(col.rgb); + + vary_ambient = col.rgb*diff.rgb; + + vary_directional.rgb = atmosAffectDirectionalLight(1.0f); - vary_ambient = col.rgb*diffuse_color.rgb; - vary_directional.rgb = atmosAffectDirectionalLight(1); + col.rgb = col.rgb*diff.rgb; - col.rgb = col.rgb*diffuse_color.rgb; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR vertex_color = col; #endif -#if HAS_SKIN +#ifdef HAS_SKIN vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); #else pos = modelview_projection_matrix * vert; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); #endif +#endif + } + diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 5e75cc3ce6..b3c1a067ee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -29,7 +29,8 @@ #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -349,29 +350,32 @@ vec3 atmosGetDiffuseSunlightColor() vec3 scaleDownLight(vec3 light) { - return (light / scene_light_strength ); + return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength)); } vec3 scaleUpLight(vec3 light) { - return (light * scene_light_strength); + return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength)); } vec3 atmosAmbient(vec3 light) { - return getAmblitColor() + light / 2.0; + return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f)); } vec3 atmosAffectDirectionalLight(float lightIntensity) { - return getSunlitColor() * lightIntensity; + return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity); } vec3 scaleSoftClip(vec3 light) { //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); + vec3 zeroes = vec3(0.0f, 0.0f, 0.0f); + vec3 ones = vec3(1.0f, 1.0f, 1.0f); + + light = ones - clamp(light, zeroes, ones); + light = ones - pow(light, gamma.xxx); return light; } @@ -399,7 +403,7 @@ VARYING vec2 vary_texcoord2; uniform float env_intensity; uniform vec4 specular_color; -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) uniform float minimum_alpha; #endif @@ -426,14 +430,14 @@ void main() vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy); diffcol.rgb *= vertex_color.rgb; -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) if (diffcol.a < minimum_alpha) { discard; } #endif -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) diffcol.rgb = pow(diffcol.rgb, vec3(2.2)); #endif @@ -456,9 +460,12 @@ void main() vec3 tnorm = vary_normal; #endif + norm.xyz = tnorm; + norm.xyz = normalize(norm.xyz); + vec4 final_color = diffcol; -#if DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE +#if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE) final_color.a = 0; #endif @@ -475,8 +482,7 @@ void main() #endif -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND - { +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) //forward rendering, output just lit RGBA vec3 pos = vary_position; @@ -549,26 +555,27 @@ void main() float shadow = 1.0; #endif + spec = final_specular; vec4 diffuse = final_color; - vec3 norm = normalize(tnorm); - vec4 spec = final_specular; float envIntensity = final_normal.z; - vec3 col; + vec3 col = vec3(0.0f,0.0f,0.0f); + float bloom = 0.0; - { calcAtmospherics(pos.xyz, 1.0); - float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - da = pow(da, 0.7); + float da =dot(norm.xyz, sun_dir.xyz); + float final_da = pow(da, 0.7f); + final_da = min(final_da, shadow); + final_da = max(final_da, diffuse.a); + final_da = max(final_da, 0.0f); - col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, shadow), diffuse.a)); - - col *= diffuse.rgb; + col.rgb = atmosAmbient(col); + col.rgb = col.rgb + atmosAffectDirectionalLight(final_da); + col.rgb *= diffuse.rgb; - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection { @@ -595,33 +602,10 @@ void main() col = atmosLighting(col); col = scaleSoftClip(col); - //col = mix(col.rgb, diffuse.rgb, diffuse.a); - } - - vec3 light_col = vec3(0,0,0); - vec3 npos = normalize(-pos.xyz); - - /*vec3 calcPointLightOrSpotLight( - vec3 light_col, - vec3 npos, - vec3 diffuse, - vec4 spec, - vec3 v, - vec3 n, - vec4 lp, - vec3 ln, - float la, - float fa, - float is_pointlight) - - */ - - /* -#ifdef MAC_GEFORCE_HACK #define LIGHT_LOOP(i) \ - light_col += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -630,34 +614,19 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else*/ - for (int i = 2; i < 8; i++) - { - light_col += calcPointLightOrSpotLight( - light_diffuse[i].rgb, - npos, - diffuse.rgb, - final_specular, - pos.xyz, - norm, - light_position[i], - light_direction[i], - light_attenuation[i].x, - light_attenuation[i].y, - light_attenuation[i].z); - } -//#endif - - col += light_col; - frag_color.rgb = col; - - } - + frag_color.rgb = col.rgb; frag_color.a = diffcol.a*vertex_color.a; #else frag_data[0] = final_color; + +#ifdef UGLY_MAC_HACK + // magic spec exp clamp fixes rendering artifacts on older mac GF drivers + // + final_specular = min(final_specular, vec4(1.0f, 1.0f, 1.0f, 0.125f)); +#endif + frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index f578795abe..0638dcfa55 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -37,7 +37,8 @@ uniform mat3 normal_matrix; uniform mat4 modelview_projection_matrix; #endif -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + #if !HAS_SKIN uniform mat4 modelview_matrix; #endif @@ -84,7 +85,7 @@ void main() vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vary_position = pos; #endif @@ -134,7 +135,7 @@ vary_normal = n; vertex_color = diffuse_color; -#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) #if !HAS_SKIN vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; #endif diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl index 777c8b45bb..c8282e9a51 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl @@ -50,7 +50,7 @@ void fullbright_shiny_lighting() color.rgb = fullbrightScaleSoftClip(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl index 4fa3b1d939..e7dbd4bbd2 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl @@ -51,7 +51,7 @@ void fullbright_shiny_lighting() color.rgb = fullbrightScaleSoftClip(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl index 58984a4263..5886fc65be 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl @@ -48,7 +48,7 @@ void fullbright_shiny_lighting_water() color.rgb = fullbrightShinyAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = applyWaterFog(color); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl index a39b7205d7..cddc7d8df8 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl @@ -49,7 +49,7 @@ void fullbright_shiny_lighting_water() color.rgb = fullbrightShinyAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = applyWaterFog(color); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl index 52e3b2ad02..9208c148ef 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl @@ -50,7 +50,7 @@ void shiny_lighting() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl index 474d5ea496..92628faa68 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl @@ -51,7 +51,7 @@ void shiny_lighting() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl index d2a4c47aac..61841674e2 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl @@ -47,7 +47,7 @@ void shiny_lighting_water() color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); color.rgb = atmosLighting(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = applyWaterFog(color); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl index f3bd662364..0b6e835fd0 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl @@ -48,7 +48,7 @@ void shiny_lighting_water() color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); color.rgb = atmosLighting(color.rgb); - color.a = max(color.a, vertex_color.a); + color.a = 1.0; frag_color = applyWaterFog(color); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index db58c19057..73c85c0419 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -25,10 +25,6 @@ #extension GL_ARB_texture_rectangle : enable -#define INDEXED 1 -#define NON_INDEXED 2 -#define NON_INDEXED_NO_COLOR 3 - #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -40,7 +36,7 @@ uniform sampler2DShadow shadowMap1; uniform sampler2DShadow shadowMap2; uniform sampler2DShadow shadowMap3; -#if INDEX_MODE != INDEXED +#ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif @@ -58,7 +54,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -198,20 +194,23 @@ void main() } vec4 diff; -#if INDEX_MODE == INDEXED + +#ifdef USE_INDEXED_TEX diff = diffuseLookup(vary_texcoord0.xy); -#else +#endif + +#ifdef USE_DIFFUSE_TEX diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - diff.rgb = pow(diff.rgb, vec3(2.2)); -#if INDEX_MODE == NON_INDEXED_NO_COLOR + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + float vertex_color_alpha = 1.0; -#else - float vertex_color_alpha = vertex_color.a; + +#ifdef USE_VERTEX_COLOR + vertex_color_alpha = vertex_color.a; #endif vec3 normal = vary_norm; - vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); dlight = dlight * vary_directional.rgb * vary_pointlight_col; @@ -220,9 +219,9 @@ void main() vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - col = vec4(0,0,0,0); + + col = vec4(0.0f,0.0f,0.0f,0.0f); #define LIGHT_LOOP(i) \ col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 46fd8da4f8..127c1709b8 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -23,10 +23,6 @@ * $/LicenseInfo$ */ -#define INDEXED 1 -#define NON_INDEXED 2 -#define NON_INDEXED_NO_COLOR 3 - uniform mat3 normal_matrix; uniform mat4 texture_matrix0; uniform mat4 projection_matrix; @@ -34,25 +30,31 @@ uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; -#if INDEX_MODE == INDEXED + +#ifdef USE_INDEXED_TEX void passTextureIndex(); #endif + ATTRIBUTE vec3 normal; -#if INDEX_MODE != NON_INDEXED_NO_COLOR + +#ifdef USE_VERTEX_COLOR ATTRIBUTE vec4 diffuse_color; #endif + ATTRIBUTE vec2 texcoord0; -#if HAS_SKIN +#ifdef HAS_SKIN mat4 getObjectSkinnedTransform(); -#elif IS_AVATAR_SKIN +#else +#ifdef IS_AVATAR_SKIN mat4 getSkinnedTransform(); #endif +#endif vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); -float calcDirectionalLight(vec3 n, vec3 l); +vec3 calcDirectionalLight(vec3 n, vec3 l); vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); @@ -65,12 +67,11 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif VARYING vec2 vary_texcoord0; - VARYING vec3 vary_norm; uniform float near_clip; @@ -82,13 +83,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -float calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - return a; + return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -115,7 +116,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(dot(n, lv), 0.0); } - return da; + return vec3(da,da,da); } void main() @@ -124,7 +125,7 @@ void main() vec3 norm; //transform vertex -#if HAS_SKIN +#ifdef HAS_SKIN mat4 trans = getObjectSkinnedTransform(); trans = modelview_matrix * trans; @@ -134,7 +135,9 @@ void main() norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); vec4 frag_pos = projection_matrix * pos; gl_Position = frag_pos; -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN mat4 trans = getSkinnedTransform(); vec4 pos_in = vec4(position.xyz, 1.0); pos.x = dot(trans[0], pos_in); @@ -156,7 +159,9 @@ void main() gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); #endif -#if INDEX_MODE == INDEXED +#endif + +#ifdef USE_INDEXED_TEX passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; #else @@ -169,37 +174,42 @@ void main() calcAtmospherics(pos.xyz); -#if INDEX_MODE == NON_INDEXED_NO_COLOR +#ifndef USE_VERTEX_COLOR vec4 diffuse_color = vec4(1,1,1,1); #endif //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - vec3 dff = pow(diffuse_color.rgb, vec3(2.2)); + vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f)); vary_pointlight_col = dff; col.rgb = vec3(0,0,0); // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); + col.rgb = atmosAmbient(col.rgb); - vary_directional.rgb = atmosAffectDirectionalLight(1); + vary_directional.rgb = atmosAffectDirectionalLight(1.0f); vary_ambient = col.rgb*dff; col.rgb = col.rgb*dff; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR vertex_color = col; #endif -#if HAS_SKIN +#ifdef HAS_SKIN vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); #else pos = modelview_projection_matrix * vert; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); #endif + +#endif + } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index edd1546263..850bf9677c 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -792,9 +792,6 @@ BOOL LLViewerShaderMgr::loadBasicShaders() // Load basic dependency shaders first // All of these have to load for any shaders to function -#if LL_DARWIN // Mac can't currently handle all 8 lights, - S32 sum_lights_class = 2; -#else S32 sum_lights_class = 3; // class one cards will get the lower sum lights @@ -805,7 +802,6 @@ BOOL LLViewerShaderMgr::loadBasicShaders() { sum_lights_class = 2; } -#endif // If we have sun and moon only checked, then only sum those lights. if (gPipeline.getLightingDetail() == 0) @@ -813,6 +809,14 @@ BOOL LLViewerShaderMgr::loadBasicShaders() sum_lights_class = 1; } +#if LL_DARWIN + // Work around driver crashes on older Macs when using deferred rendering + // NORSPEC-59 + // + if (gGLManager.mIsMobileGF) + sum_lights_class = 3; +#endif + // Use the feature table to mask out the max light level to use. Also make sure it's at least 1. S32 max_light_class = gSavedSettings.getS32("RenderShaderLightingMaxLevel"); sum_lights_class = llclamp(sum_lights_class, 1, max_light_class); @@ -1218,9 +1222,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredSkinnedAlphaProgram.addPermutation("INDEX_MODE", "2"); + gDeferredSkinnedAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1"); + gDeferredSkinnedAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredSkinnedAlphaProgram.addPermutation("HAS_SKIN", "1"); - gDeferredSkinnedAlphaProgram.addPermutation("IS_AVATAR_SKIN", "0"); success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL); // Hack to include uniforms for lighting without linking in lighting file @@ -1265,6 +1269,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); bool has_skin = i & 0x10; gDeferredMaterialProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0"); + + #if LL_DARWIN + // include spec exp clamp to fix older mac rendering artifacts + // + if (gGLManager.mIsMobileGF) + { + gDeferredMaterialProgram[i].addPermutation("UGLY_MAC_HACK","1"); + } + #endif + if (has_skin) { gDeferredMaterialProgram[i].mFeatures.hasObjectSkinning = true; @@ -1414,9 +1428,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.clear(); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAlphaProgram.addPermutation("INDEX_MODE", "1"); - gDeferredAlphaProgram.addPermutation("HAS_SKIN", "0"); - gDeferredAlphaProgram.addPermutation("IS_AVATAR_SKIN", "0"); + gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); + gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredAlphaProgram.createShader(NULL, NULL); @@ -1592,8 +1605,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mShaderFiles.clear(); gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAvatarAlphaProgram.addPermutation("INDEX_MODE", "3"); - gDeferredAvatarAlphaProgram.addPermutation("HAS_SKIN", "0"); + gDeferredAvatarAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1"); gDeferredAvatarAlphaProgram.addPermutation("IS_AVATAR_SKIN", "1"); gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index f861f49296..f5b8244509 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4336,6 +4336,15 @@ U32 LLVOAvatar::renderTransparent(BOOL first_pass) gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } +#if LL_DARWIN + // blatant hack to avoid driver crash on rendering mMeshLODs for eyelashes and baked hair below + // NORSPEC-59 + if (gGLManager.mIsMobileGF) + { + return num_indices; + } +#endif + if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender) { if (LLPipeline::sImpostorRender) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 1e32e7628f..edd47b68c3 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4043,6 +4043,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, BOOL fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) || (type == LLRenderPass::PASS_INVISIBLE) || + (type == LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK) || (type == LLRenderPass::PASS_ALPHA && facep->isState(LLFace::FULLBRIGHT)); if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->getVertexBuffer()->hasDataType(LLVertexBuffer::TYPE_NORMAL)) @@ -4082,7 +4083,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U8 index = facep->getTextureIndex(); - LLMaterial* mat = LLPipeline::sRenderDeferred ? facep->getTextureEntry()->getMaterialParams().get() : NULL; + LLMaterial* mat = facep->getTextureEntry()->getMaterialParams().get(); bool batchable = false; @@ -4781,7 +4782,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX; } - genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, batch_textures, TRUE); + genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, batch_textures, FALSE); genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, batch_textures); genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, batch_textures); genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, FALSE); @@ -5248,6 +5249,14 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: LLMaterial* mat = te->getMaterialParams().get(); + bool can_be_shiny = true; + if (mat) + { + U8 mode = mat->getDiffuseAlphaMode(); + can_be_shiny = mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE || + mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE; + } + if (mat && LLPipeline::sRenderDeferred && !hud_group) { if (fullbright) @@ -5325,7 +5334,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } else if (gPipeline.canUseVertexShaders() && LLPipeline::sRenderBump - && te->getShiny()) + && te->getShiny() + && can_be_shiny) { //shiny if (tex->getPrimaryFormat() == GL_ALPHA) { //invisiprim+shiny @@ -5369,7 +5379,14 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } else if (fullbright || bake_sunlight) { //fullbright - registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); + if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + { + registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK); + } + else + { + registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); + } if (LLPipeline::sRenderDeferred && !hud_group && LLPipeline::sRenderBump && te->getBumpmap()) { //if this is the deferred render and a bump map is present, register in post deferred bump registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); @@ -5384,7 +5401,14 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: else { //all around simple llassert(mask & LLVertexBuffer::MAP_NORMAL); - registerFace(group, facep, LLRenderPass::PASS_SIMPLE); + if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + { //material alpha mask can be respected in non-deferred + registerFace(group, facep, LLRenderPass::PASS_ALPHA_MASK); + } + else + { + registerFace(group, facep, LLRenderPass::PASS_SIMPLE); + } } } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ca5adc6180..1957345b6d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -917,6 +917,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { screenFormat = GL_RGBA12; } + + if (gGLManager.mGLVersion < 4.f && gGLManager.mIsNVIDIA) + { + screenFormat = GL_RGBA16F_ARB; + } if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) @@ -1672,14 +1677,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima alpha = false; break; default: //alpha mode set to "mask", go to alpha pool if fullbright - if (te->getFullbright()) - { - alpha = true; - } - else - { - alpha = false; // Material's alpha mode is set to none, mask, or emissive. Toss it into the opaque material draw pool. - } + alpha = false; // Material's alpha mode is set to none, mask, or emissive. Toss it into the opaque material draw pool. break; } } @@ -10040,7 +10038,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { static LLCullResult result[4]; - //LLGLEnable enable(GL_DEPTH_CLAMP_NV); renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, TRUE, target_width); } |