From 14f6bbadef2c39e58a3b54c0c6212949acf50e45 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 8 Aug 2011 15:29:23 -0500 Subject: SH-2242 Work in progress migrating to glVertexAttrib everywhere --- .../shaders/class2/deferred/avatarAlphaV.glsl | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 01e40afc4f..65c3e5da10 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -6,6 +6,10 @@ */ +attribute vec3 position; +attribute vec3 normal; +attribute vec4 diffuse_color; +attribute vec2 texcoord0; vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); @@ -61,20 +65,21 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa void main() { - gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[0] = vec4(texcoord0,0,1); vec4 pos; vec3 norm; mat4 trans = getSkinnedTransform(); - pos.x = dot(trans[0], gl_Vertex); - pos.y = dot(trans[1], gl_Vertex); - pos.z = dot(trans[2], gl_Vertex); + vec4 pos_in = vec4(position.xyz, 1.0); + pos.x = dot(trans[0], pos_in); + pos.y = dot(trans[1], pos_in); + pos.z = dot(trans[2], pos_in); pos.w = 1.0; - norm.x = dot(trans[0].xyz, gl_Normal); - norm.y = dot(trans[1].xyz, gl_Normal); - norm.z = dot(trans[2].xyz, gl_Normal); + norm.x = dot(trans[0].xyz, normal); + norm.y = dot(trans[1].xyz, normal); + norm.z = dot(trans[2].xyz, normal); norm = normalize(norm); gl_Position = gl_ProjectionMatrix * pos; @@ -84,9 +89,9 @@ void main() calcAtmospherics(pos.xyz); - //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); + //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a); + vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); // 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); @@ -96,17 +101,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*gl_Color.rgb; + vary_pointlight_col = col.rgb*diffuse_color.rgb; col.rgb = vec3(0,0,0); // Add windlight lights col.rgb = atmosAmbient(vec3(0.)); - vary_ambient = col.rgb*gl_Color.rgb; - vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); + 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))); - col.rgb = min(col.rgb*gl_Color.rgb, 1.0); + col.rgb = min(col.rgb*diffuse_color.rgb, 1.0); gl_FrontColor = col; -- cgit v1.2.3 From 2ee815478043c4d5845f094f744a055707dba0e0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 10 Aug 2011 13:01:14 -0500 Subject: 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). --- .../app_settings/shaders/class2/deferred/avatarAlphaV.glsl | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') 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; -- cgit v1.2.3 From 530981a2149a74e1dc003cea1bbc9dc392fcae60 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 15 Sep 2011 00:54:25 -0500 Subject: SH-2243 work in progress -- no more deprecated built-in matrix state when using shaders. --- indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index f35af53f95..3e35675784 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -23,6 +23,7 @@ * $/LicenseInfo$ */ +uniform mat4 projection_matrix; attribute vec3 position; attribute vec3 normal; @@ -99,7 +100,7 @@ void main() norm.z = dot(trans[2].xyz, normal); norm = normalize(norm); - gl_Position = gl_ProjectionMatrix * pos; + gl_Position = projection_matrix * pos; float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz)); vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset; -- cgit v1.2.3 From 24ae2fb5af52d7128e79a0f63afce9a8db1123eb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 15 Sep 2011 16:38:31 -0500 Subject: SH-2243 work in progress -- don't use built-in GL light state when shaders are available. --- .../shaders/class2/deferred/avatarAlphaV.glsl | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 3e35675784..0273f3c121 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -51,6 +51,11 @@ uniform float near_clip; uniform float shadow_offset; uniform float shadow_bias; +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; +uniform vec3 light_attenuation[8]; +uniform vec3 light_diffuse[8]; + float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector @@ -102,20 +107,20 @@ void main() gl_Position = projection_matrix * pos; - float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz)); - vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset; + float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); + vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; calcAtmospherics(pos.xyz); 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); - col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation ,gl_LightSource[3].specular.a); - col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation, gl_LightSource[4].specular.a); - col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].quadraticAttenuation, gl_LightSource[5].specular.a); - 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); + col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); + col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); + col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); + col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); + col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); + col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); vary_pointlight_col = col.rgb; @@ -125,7 +130,7 @@ void main() col.rgb = atmosAmbient(vec3(0.)); vary_ambient = col.rgb; - vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), 0.0)); + vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0)); col.rgb = min(col.rgb, 1.0); -- cgit v1.2.3 From da84f5552731e1ece3a463c4c385bb327f1048a1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Sep 2011 12:40:53 -0500 Subject: SH-2243 work in progress -- don't use deprecated shader state --- .../shaders/class2/deferred/avatarAlphaV.glsl | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 0273f3c121..091a865160 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -25,9 +25,9 @@ uniform mat4 projection_matrix; -attribute vec3 position; -attribute vec3 normal; -attribute vec2 texcoord0; +ATTRIBUTE vec3 position; +ATTRIBUTE vec3 normal; +ATTRIBUTE vec2 texcoord0; vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); @@ -41,11 +41,14 @@ vec3 atmosAffectDirectionalLight(float lightIntensity); vec3 scaleDownLight(vec3 light); vec3 scaleUpLight(vec3 light); -varying vec3 vary_position; -varying vec3 vary_ambient; -varying vec3 vary_directional; -varying vec3 vary_fragcoord; -varying vec3 vary_pointlight_col; +VARYING vec3 vary_position; +VARYING vec3 vary_ambient; +VARYING vec3 vary_directional; +VARYING vec3 vary_fragcoord; +VARYING vec3 vary_pointlight_col; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; +VARYING float fog_depth; uniform float near_clip; uniform float shadow_offset; @@ -88,7 +91,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa void main() { - gl_TexCoord[0] = vec4(texcoord0,0,1); + vary_texcoord0 = texcoord0; vec4 pos; vec3 norm; @@ -134,9 +137,9 @@ void main() col.rgb = min(col.rgb, 1.0); - gl_FrontColor = col; + vertex_color = col; - gl_FogFragCoord = pos.z; + fog_depth = pos.z; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); } -- cgit v1.2.3 From 348a70181211b8fe37c569f8b3fb8324cc8c59ea Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 28 Sep 2011 00:41:10 -0500 Subject: SH-2507 Shave some unused/redundant varying state and make the max texture index debug setting rebuild shaders to use no flow control when set to 1 or lower --- indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 091a865160..63c7a6b13d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -48,7 +48,7 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_pointlight_col; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -VARYING float fog_depth; + uniform float near_clip; uniform float shadow_offset; @@ -139,7 +139,7 @@ void main() vertex_color = col; - fog_depth = pos.z; + vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); } -- cgit v1.2.3 From 969aa248a4c398dd0608a447f99cf74683d09f65 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 28 Oct 2011 16:26:20 -0500 Subject: SH-2633 Fix for avatar hair turning white when editing appearance --- .../newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl index 63c7a6b13d..9c7a332417 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl @@ -49,6 +49,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +uniform vec4 color; uniform float near_clip; uniform float shadow_offset; @@ -125,17 +126,17 @@ void main() col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - vary_pointlight_col = col.rgb; + vary_pointlight_col = col.rgb*color.rgb; col.rgb = vec3(0,0,0); // Add windlight lights col.rgb = atmosAmbient(vec3(0.)); - vary_ambient = col.rgb; + vary_ambient = col.rgb*color.rgb; vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0)); - col.rgb = min(col.rgb, 1.0); + col.rgb = col.rgb*color.rgb; vertex_color = col; -- cgit v1.2.3