diff options
Diffstat (limited to 'indra/newview/app_settings/shaders')
22 files changed, 862 insertions, 0 deletions
| diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl new file mode 100644 index 0000000000..5731add4d5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl @@ -0,0 +1,7 @@ +void default_lighting(); + +void main()  +{ +	default_lighting(); +} +	 diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl new file mode 100644 index 0000000000..1fcc001911 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl @@ -0,0 +1,19 @@ +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color); + +attribute vec4 weight;  //1 + +uniform vec4 matrixPalette[45]; + +mat4 getSkinnedTransform() +{ +	mat4 ret; +	int i = int(floor(weight.x)); +	float x = fract(weight.x); +		 +	ret[0] = mix(matrixPalette[i+0], matrixPalette[i+1], x); +	ret[1] = mix(matrixPalette[i+15],matrixPalette[i+16], x); +	ret[2] = mix(matrixPalette[i+30],matrixPalette[i+31], x); +	ret[3] = vec4(0,0,0,1); + +	return ret; +} diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl new file mode 100644 index 0000000000..50f9b0192e --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl @@ -0,0 +1,35 @@ +void default_scatter(vec3 viewVec, vec3 lightDir); +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +mat4 getSkinnedTransform(); +vec2 getScatterCoord(vec3 viewVec, vec3 lightDir); + +attribute vec4 materialColor; + +void main() +{ +	gl_TexCoord[0] = gl_MultiTexCoord0; +				 +	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); +	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 = normalize(norm); +		 +	gl_Position = gl_ProjectionMatrix * pos; +	  +	//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +	 +	default_scatter(pos.xyz, gl_LightSource[0].position.xyz); + +	vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color); +	gl_FrontColor = color;  + +} diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl new file mode 100644 index 0000000000..5731add4d5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl @@ -0,0 +1,7 @@ +void default_lighting(); + +void main()  +{ +	default_lighting(); +} +	 diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl new file mode 100644 index 0000000000..d436b4e00a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl @@ -0,0 +1,20 @@ +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol); +void default_scatter(vec3 viewVec, vec3 lightDir); + +attribute vec4 materialColor; + +void main() +{ +	//transform vertex +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; +	 +	vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; +	vec3 norm = normalize(gl_NormalMatrix * gl_Normal); +		 +	vec4 color = calcLighting(pos, norm, materialColor, gl_Color.rgb); +	default_scatter(pos, gl_LightSource[0].position.xyz); +	 +	gl_FrontColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl new file mode 100644 index 0000000000..b311afb59c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl @@ -0,0 +1,6 @@ +uniform sampler2D diffuseMap; + +void main()  +{ +	gl_FragColor = vec4(gl_Color.rgb, texture2D(diffuseMap, gl_TexCoord[0].xy).a); +} diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl new file mode 100644 index 0000000000..b6dcbe1693 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl @@ -0,0 +1,17 @@ +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color); +mat4 getSkinnedTransform(); + +void main() +{ +	vec4 pos; +		 +	mat4 trans = getSkinnedTransform(); +	pos.x = dot(trans[0], gl_Vertex); +	pos.y = dot(trans[1], gl_Vertex); +	pos.z = dot(trans[2], gl_Vertex); +	pos.w = 1.0; +			 +	gl_FrontColor = gl_Color; +	gl_TexCoord[0] = gl_MultiTexCoord0; +	gl_Position = gl_ProjectionMatrix * pos; +}
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl new file mode 100644 index 0000000000..fde370155d --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl @@ -0,0 +1,19 @@ +void terrain_lighting(inout vec3 color); + +uniform sampler2D detail0; //0 +uniform sampler2D detail1; //2 +uniform sampler2D alphaRamp; //1 + + +void main()  +{ +	float a = texture2D(alphaRamp, gl_TexCoord[1].xy).a; +	vec3 color = mix(texture2D(detail1, gl_TexCoord[2].xy).rgb, +					 texture2D(detail0, gl_TexCoord[0].xy).rgb, +					 a); + +	terrain_lighting(color); +	 +	gl_FragColor.rgb = color; +	gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a; +} diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl new file mode 100644 index 0000000000..3153a80e93 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl @@ -0,0 +1,37 @@ +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void default_scatter(vec3 viewVec, vec3 lightDir); + +attribute vec4 materialColor; + +vec4 texgen_object(vec4  vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) +{ +	vec4 tcoord; +	 +	tcoord.x = dot(vpos, tp0); +	tcoord.y = dot(vpos, tp1); +	tcoord.z = tc.z; +	tcoord.w = tc.w; +	 +	tcoord = mat * tcoord;  +	 +	return tcoord;  +} + +void main() +{ +	//transform vertex +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +			 +	vec4 pos = gl_ModelViewMatrix * gl_Vertex; +	vec3 norm = normalize(gl_NormalMatrix * gl_Normal); +	 +	vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color); +	 +	gl_FrontColor = color; +	 +	gl_TexCoord[0] = texgen_object(gl_Vertex,gl_MultiTexCoord0,gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]); +	gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord1; +	gl_TexCoord[2] = texgen_object(gl_Vertex,gl_MultiTexCoord2,gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]); +	gl_TexCoord[3] = gl_TextureMatrix[3]*gl_MultiTexCoord3; +	default_scatter(pos.xyz, gl_LightSource[0].position.xyz);	 +} diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl new file mode 100644 index 0000000000..f8b8031ce6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -0,0 +1,22 @@ +void water_lighting(inout vec3 diff); + +uniform samplerCube environmentMap; +uniform sampler2D diffuseMap; +uniform sampler2D bumpMap; + +varying vec4 specular; + +void main()  +{ +	vec4 depth = texture2D(diffuseMap, gl_TexCoord[0].xy); +	vec4 diff = texture2D(bumpMap, gl_TexCoord[1].xy); +	vec3 ref = textureCube(environmentMap, gl_TexCoord[2].xyz).rgb; +	 +	diff.rgb *= depth.rgb; +		 +	vec3 col = mix(diff.rgb, ref, specular.a)+specular.rgb*diff.rgb; +	 +	water_lighting(col.rgb);  +	gl_FragColor.rgb = col.rgb; +	gl_FragColor.a = (gl_Color.a+depth.a)*0.5;	 +} diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl new file mode 100644 index 0000000000..873a6fcb34 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl @@ -0,0 +1,41 @@ +void default_scatter(vec3 viewVec, vec3 lightDir); +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol); +vec2 getScatterCoord(vec3 viewVec, vec3 lightDir); + +varying vec4 specular; + +vec4 texgen_object(vec4  vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) +{ +	vec4 tcoord; +	 +	tcoord.x = dot(vpos, tp0); +	tcoord.y = dot(vpos, tp1); +	tcoord.z = tc.z; +	tcoord.w = tc.w; +	 +	tcoord = mat * tcoord;  +	 +	return tcoord;  +} + +void main() +{ +	//transform vertex +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +	gl_TexCoord[0] = gl_MultiTexCoord0; +	gl_TexCoord[1] = texgen_object(gl_Vertex, gl_MultiTexCoord1, gl_TextureMatrix[1], gl_ObjectPlaneS[1],gl_ObjectPlaneT[1]); +	 +	vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; +	vec3 norm = normalize(gl_NormalMatrix * gl_Normal); +	vec4 spec = gl_Color; +	gl_FrontColor.rgb = calcLightingSpecular(pos, norm, gl_Color, spec, vec3(0.0, 0.0, 0.0)).rgb;			 +	gl_FrontColor.a = gl_Color.a; +	specular = spec; +	specular.a = gl_Color.a*0.5; +	vec3 ref = reflect(pos,norm); +	 +	gl_TexCoord[2] = gl_TextureMatrix[2]*vec4(ref,1); +		 +	default_scatter(pos.xyz, gl_LightSource[0].position.xyz); +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl new file mode 100644 index 0000000000..1e342fb51b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -0,0 +1,6 @@ +uniform sampler2D diffuseMap; + +void main()  +{ +	gl_FragColor = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl new file mode 100644 index 0000000000..bb6707b2a9 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl @@ -0,0 +1,20 @@ +attribute vec4 materialColor; + +void main() +{ +	//transform vertex +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +	vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; +	pos = normalize(pos); +	float d = dot(pos, normalize(gl_NormalMatrix * gl_Normal)); +	d *= d; +	d = 1.0 - d; +	d *= d; +		 +	d = min(d, materialColor.a*2.0); +			 +	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; +	gl_FrontColor.rgb = materialColor.rgb; +	gl_FrontColor.a = max(d, materialColor.a); +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl new file mode 100644 index 0000000000..b2a6d67621 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl @@ -0,0 +1,31 @@ +void applyScatter(inout vec3 color); + +uniform sampler2D diffuseMap; + +void default_lighting()  +{ +	vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); +	applyScatter(color.rgb); +	gl_FragColor = color; +} + +void alpha_lighting()  +{ +	default_lighting(); +} + +void water_lighting(inout vec3 diff) +{ +	applyScatter(diff); +} + +void terrain_lighting(inout vec3 color) +{ +	color.rgb *= gl_Color.rgb; +	applyScatter(color); +} + +vec4 getLightColor() +{ +	return gl_Color; +}
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl new file mode 100644 index 0000000000..e3816318a1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl @@ -0,0 +1,99 @@ + +float calcDirectionalLight(vec3 n, vec3 l) +{ +	float a = max(dot(n,l),0.0); +	return a; +} + +float calcPointLight(vec3 v, vec3 n, vec3 l, float r, float pw) +{ +	//get light vector +	vec3 lv = l-v; +	 +	//get distance +	float d = length(lv); +	 +	//normalize light vector +	lv *= 1.0/d; +	 +	//distance attenuation +	float da = max((r-d)/r, 0.0); +	 +	//da = pow(da, pw); +	 +	//angular attenuation +	da *= calcDirectionalLight(n, lv); +	 +	return da;	 +} + +float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l) +{ +	float a = max(dot(n,l),0.0); +	return a; +} + +float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da) +{ +	 +	specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da; +	return calcDirectionalLight(n,l); +} + +vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol) +{ +	//get light vector +	vec3 lv = l-v; +	 +	//get distance +	float d = length(lv); +	 +	//normalize light vector +	lv *= 1.0/d; +	 +	//distance attenuation +	float da = clamp((r-d)/r, 0.0, 1.0); + +	//da = pow(da, pw); +	 +	//angular attenuation +	da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da); +	 +	return da*lightCol;	 +} + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) +{ +	vec4 col; +	col.a = color.a; +	 +	col.rgb = gl_LightModel.ambient.rgb + baseLight.rgb; +	 +	col.rgb += gl_LightSource[0].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[0].position.xyz); +	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); +						 +	col.rgb = min(col.rgb*color.rgb, 1.0); +	 +	return col;	 +} + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseLight) +{ +	return calcLighting(pos, norm, color, vec4(baseLight, 1.0)); +} + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) +{ +	return calcLighting(pos, norm, color, vec3(0.0,0.0,0.0)); +} + +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) +{ +	specularColor.rgb = vec3(0.0, 0.0, 0.0); +	return calcLighting(pos, norm, color, baseCol); +} + +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol) +{ +	return calcLightingSpecular(pos, norm, color, specularColor, vec4(baseCol, 1.0)); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl new file mode 100644 index 0000000000..ce5ab12b74 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl @@ -0,0 +1,6 @@ +void default_lighting(); + +void main()  +{ +	default_lighting(); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl new file mode 100644 index 0000000000..2aa3521931 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl @@ -0,0 +1,21 @@ +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void default_scatter(vec3 viewVec, vec3 lightDir); + +attribute vec4 materialColor; + +void main() +{ +	//transform vertex +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; +	 +	vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; +	vec3 norm = normalize(gl_NormalMatrix * gl_Normal); +	 +	default_scatter(pos, gl_LightSource[0].position.xyz); + +	vec4 color = calcLighting(pos, norm, materialColor, gl_Color); +	gl_FrontColor = color; + +	gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl new file mode 100644 index 0000000000..7957eddb31 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl @@ -0,0 +1,23 @@ +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol); +void default_scatter(vec3 viewVec, vec3 lightDir); + +attribute vec4 materialColor; +attribute vec4 specularColor; + +void main() +{ +	//transform vertex +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; +	 +	vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; +	vec3 norm = normalize(gl_NormalMatrix * gl_Normal); +	 +	default_scatter(pos.xyz, gl_LightSource[0].position.xyz); +	vec4 specular = specularColor; +	vec4 color = calcLightingSpecular(pos, norm, materialColor, specular, gl_Color.rgb); +			 +	gl_FrontColor = color; +	gl_FogFragCoord = pos.z; +} + diff --git a/indra/newview/app_settings/shaders/class2/environment/waterF.glsl b/indra/newview/app_settings/shaders/class2/environment/waterF.glsl new file mode 100644 index 0000000000..e0e79e95ba --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/environment/waterF.glsl @@ -0,0 +1,136 @@ +void applyScatter(inout vec3 color); + +uniform sampler2D diffuseMap; +uniform sampler2D bumpMap;    +uniform samplerCube environmentMap; //: TEXUNIT4,   // Environment map texture +uniform sampler2D screenTex;   //   : TEXUNIT5 + +uniform vec3 lightDir; +uniform vec3 specular; +uniform float lightExp; +uniform vec2 fbScale; +uniform float refScale; + +float msin(float x) { +   float k = sin(x)+1.0; +   k *= 0.5; +   k *= k; +   return 2.0 * k; +} + +float mcos(float x) { +   float k = cos(x)+1.0; +   k *= 0.5; +   k *= k; +   return 2.0 * k; +} + +float waveS(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap)  +{ +   return texture1D(sinMap, (dot(d, v)*f + t*s)*f).r*a; +} + +float waveC(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap)  +{ +   return texture1D(sinMap, (dot(d, v)*f + t*s)*f).g*a*2.0-1.0; +} + +float magnitude(vec3 vec) { +   return sqrt(dot(vec,vec)); +} + +vec3 mreflect(vec3 i, vec3 n) { +   return i + n * 2.0 * abs(dot(n,i))+vec3(0.0,0.0,0.5); +} + +void main()  +{ +   vec2 texCoord = gl_TexCoord[0].xy;   // Texture coordinates +   vec2 littleWave1 = gl_TexCoord[0].zw; +   vec2 littleWave2 = gl_TexCoord[1].xy; +   vec2 bigWave = gl_TexCoord[1].zw; +   vec3 viewVec = gl_TexCoord[2].xyz; +   vec4 refCoord = gl_TexCoord[3]; +   vec4 col = gl_Color; +   vec4 color; +    +   //get color from alpha map (alpha denotes water depth), rgb denotes water color +   vec4 wcol = texture2D(diffuseMap, texCoord.xy); +       +   //store texture alpha +   float da = wcol.a; +          +   //modulate by incoming water color +   //wcol.a *= refCoord.w; +    +   //scale wcol.a (water depth) for steep transition +   wcol.a *= wcol.a; +    +   //normalize view vector +   viewVec = normalize(viewVec); +    +   //get bigwave normal +   vec3 wavef = texture2D(bumpMap, bigWave).xyz*2.0; +       +   vec3 view = vec3(viewVec.x, viewVec.y, viewVec.z); +    +   float dx = 1.0-(dot(wavef*2.0-vec3(1.0), view))*da; +   dx *= 0.274; +       +   //get detail normals +   vec3 dcol = texture2D(bumpMap, littleWave1+dx*view.xy).rgb*0.75; +   dcol += texture2D(bumpMap, littleWave2+view.xy*dx*0.1).rgb*1.25; +       +   //interpolate between big waves and little waves (big waves in deep water) +   wavef = wavef*wcol.a + dcol*(1.0-wcol.a); +    +   //crunch normal to range [-1,1] +   wavef -= vec3(1,1,1); +    +   //get base fresnel component +   float df = dot(viewVec,wavef); +   //reposition fresnel to latter half of [0,1] +   df = 1.0-clamp(df,0.0,1.0); + +   //set output alpha based on fresnel +   color.a = clamp((df+da)*0.5,0.0,1.0); +       +   //calculate reflection vector +   vec3 ref = reflect(viewVec.xyz, wavef); +    +   //get specular component +   float spec = clamp(dot(lightDir, normalize(ref)),0.0,1.0); +       +   //fudge reflection to be more noisy at good angles +   ref.z = ref.z*ref.z+df*df*0.5; +    +   //get diffuse component +   float diff = clamp((abs(dot(ref, wavef))),0.0,1.0)*0.9; +       +   //fudge diffuse for extra contrast and ambience +   diff *= diff;       +   diff += 0.4; +     +   //set diffuse color contribution +   color.rgb = textureCube(environmentMap, ref).rgb*diff; +    +   //harden specular +   spec = pow(spec, lightExp); +    +   //add specular color contribution +   color.rgb += spec * specular; + +   //figure out distortion vector (ripply)    +   vec2 distort = clamp(((refCoord.xy/refCoord.z) * 0.5 + 0.5 + wavef.xy*refScale),0.0,0.99); +    +   //read from framebuffer (offset) +   vec4 fb = texture2D(screenTex, distort*fbScale); +    +   //tint by framebuffer +   color.rgb = color.a*color.rgb + (1.0-color.a)*fb.rgb; +    +   //apply fog +   applyScatter(color.rgb); +    +   gl_FragColor = color; +} diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl new file mode 100644 index 0000000000..0ef1129253 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl @@ -0,0 +1,36 @@ +void applyScatter(inout vec3 color); + +uniform sampler2D diffuseMap; + +void default_lighting()  +{ +	vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); +	applyScatter(color.rgb); +	gl_FragColor = color; +} + +void alpha_lighting()  +{ +	vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy); +	vec3 color = gl_Color.rgb * diff.rgb; +	applyScatter(color); +	gl_FragColor.rgb = color; +	gl_FragColor.a = diff.a * gl_Color.a;	 +} + +void water_lighting(inout vec3 diff) +{ +	diff = (diff*0.9 + gl_Color.rgb*0.1); +	applyScatter(diff); +} + +void terrain_lighting(inout vec3 color) +{ +	color.rgb *= gl_Color.rgb; +	applyScatter(color); +} + +vec4 getLightColor() +{ +	return gl_Color; +}
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl new file mode 100644 index 0000000000..b15960dea2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl @@ -0,0 +1,126 @@ +// All lights, no specular highlights + +float calcDirectionalLight(vec3 n, vec3 l) +{ +	float a = max(dot(n,l),0.0); +	return a; +} + +float calcPointLight(vec3 v, vec3 n, vec4 lp, float la) +{ +	//get light vector +	vec3 lv = lp.xyz-v; +	 +	//get distance +	float d = length(lv); +	 +	//normalize light vector +	lv *= 1.0/d; +	 +	//distance attenuation +	float da = clamp(1.0/(la * d), 0.0, 1.0); +	 +	//angular attenuation +	da *= calcDirectionalLight(n, lv); +	 +	return da;	 +} + +float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l) +{ +	return pow(max(dot(reflect(view, n),l), 0.0),8.0); +} + +float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da) +{ +	 +	specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da; +	return calcDirectionalLight(n,l); +} + +vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol) +{ +	//get light vector +	vec3 lv = l-v; +	 +	//get distance +	float d = length(lv); +	 +	//normalize light vector +	lv *= 1.0/d; +	 +	//distance attenuation +	float da = clamp(1.0/(r * d), 0.0, 1.0); +	 +	//angular attenuation +	 +	da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da); +	 +	return da*lightCol;	 +} + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) +{ +	vec4 col; +	col.a = color.a; +	 +	col.rgb = gl_LightModel.ambient.rgb + baseLight.rgb; +	 +	col.rgb += gl_LightSource[0].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[0].position.xyz); +	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); +	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation); +	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation); +	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation); +	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation); +	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation); +	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation); +				 +	col.rgb = min(col.rgb*color.rgb, 1.0); +	 +	gl_FrontColor = vec4(col.rgb, col.a); +	return col;	 +} + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseLight) +{ +	return calcLighting(pos, norm, color, vec4(baseLight, 1.0)); +} + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) +{ +	return calcLighting(pos, norm, color, vec3(0.0,0.0,0.0)); +} + +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) +{ +	vec4 col; +	col.a = color.a; +	 +	col.rgb = gl_LightModel.ambient.rgb; +	 +	vec3 view = normalize(pos); +	 +	vec4 specular = specularColor; +	specularColor.rgb = vec3(0.0, 0.0, 0.0); +	 +	col.rgb += baseCol.a*gl_LightSource[0].diffuse.rgb*calcDirectionalLightSpecular(specularColor, view, norm, gl_LightSource[0].position.xyz,gl_LightSource[0].diffuse.rgb*baseCol.a, 1.0); +	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLightSpecular(specularColor, view, norm, gl_LightSource[1].position.xyz,gl_LightSource[1].diffuse.rgb, 1.0); +	col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[2].position.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation,gl_LightSource[2].diffuse.rgb); +	col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[3].position.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation,gl_LightSource[3].diffuse.rgb); +	col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[4].position.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation,gl_LightSource[4].diffuse.rgb); +	col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[5].position.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].quadraticAttenuation,gl_LightSource[5].diffuse.rgb); +	//col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[6].position.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation,gl_LightSource[6].diffuse.rgb); +	//col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[7].position.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation,gl_LightSource[7].diffuse.rgb); +	col.rgb += baseCol.rgb; +						 +	col.rgb = min(col.rgb*color.rgb, 1.0); +	specularColor.rgb = min(specularColor.rgb*specular.rgb, 1.0); + +	gl_FrontColor = vec4(col.rgb+specularColor.rgb,col.a);	 +	return col;	 +} + +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol) +{ +	return calcLightingSpecular(pos, norm, color, specularColor, vec4(baseCol, 1.0)); +} diff --git a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl new file mode 100644 index 0000000000..2505afea65 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl @@ -0,0 +1,128 @@ +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol); +mat4 getSkinnedTransform(); +void default_scatter(vec3 viewVec, vec3 lightDir); + +attribute vec4 materialColor; //2 + +attribute vec4 binormal; //6 +attribute vec4 clothing; //4 + +attribute vec4 gWindDir;		//7 +attribute vec4 gSinWaveParams; //3 +attribute vec4 gGravity;		//5 + +const vec4 gMinMaxConstants = vec4(1.0, 0.166666, 0.0083143, .00018542);	 // #minimax-generated coefficients +const vec4 gPiConstants	= vec4(0.159154943, 6.28318530, 3.141592653, 1.5707963); //	# {1/2PI, 2PI, PI, PI/2} + +void main() +{ +	gl_TexCoord[0] = gl_MultiTexCoord0; +		 +	vec4 pos; +	mat4 trans = getSkinnedTransform(); +		 +	vec3 norm; +	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 = normalize(norm); +		 +	vec3 binorm; +	binorm.x = dot(trans[0].xyz, binormal.xyz); +	binorm.y = dot(trans[1].xyz, binormal.xyz); +	binorm.z = dot(trans[2].xyz, binormal.xyz); +	norm = normalize(norm); +	 +	//wind +	vec4 windEffect; +	windEffect = vec4(dot(norm, gWindDir.xyz));				//	DP3 windEffect, blendNorm, gWindDir; +	pos.x = dot(trans[2].xyz, gl_Vertex.xyz);				//	DP3 blendPos.x, blendMatZ, iPos; +	windEffect.xyz = pos.x * vec3(0.015, 0.015, 0.015) +						+ windEffect.xyz;					//	MAD windEffect.xyz, blendPos.x, {0.015, 0.015, 0.015, 0}, windEffect; +	windEffect.w = windEffect.w * 2.0 + 1.0;				//	MAD	windEffect.w, windEffect, {0, 0, 0, 2}, {0, 0, 0, 1};	# move wind offset value to [-1, 3] +	windEffect.w = windEffect.w*gWindDir.w;					//	MUL windEffect.w, windEffect, gWindDir;								# modulate wind strength  +	 +	windEffect.xyz = windEffect.xyz*gSinWaveParams.xyz +						+vec3(gSinWaveParams.w);			//	MAD windEffect.xyz, windEffect, gSinWaveParams, gSinWaveParams.w;		# use sin wave params to scale and offset input + +		 +	//reduce to period of 2 PI +	vec4 temp1, temp0, temp2, offsetPos; +	temp1.xyz = windEffect.xyz * gPiConstants.x;			//	MUL    temp1.xyz, windEffect, gPiConstants.x;						# change input as multiple of [0-2PI] to [0-1] +	temp0.y = mod(temp1.x,1.0);								//	EXP    temp0, temp1.x;												# find mod(x, 1) +	windEffect.x = temp0.y * gPiConstants.y;				//	MUL    windEffect.x, temp0.y, gPiConstants.y;						# scale from [0,1] to [0, 2PI] +	temp1.z = temp1.z - gPiConstants.w;						//	ADD    temp1.z, temp1.z, -gPiConstants.w;							# shift normal oscillation by PI/2 +	temp0.y = mod(temp1.z,1.0);								//	EXP    temp0, temp1.z;												# find mod(x, 1) +	 +	windEffect.z = temp0.y * gPiConstants.y;				//	MUL    windEffect.z, temp0.y, gPiConstants.y;						# scale from [0,1] to [0, 2PI] +	windEffect.xyz = windEffect.xyz + vec3(-3.141592);		//	# offset to [-PI, PI] +															//	ADD    windEffect.xyz, windEffect, {-3.141592, -3.141592, -3.141592, -3.141592}; + +	//calculate sinusoid +	vec4 sinWave; +	temp1 = windEffect*windEffect;							//	MUL    temp1,    windEffect, windEffect;							# x^2 +	sinWave = -temp1 * gMinMaxConstants.w  +				+ vec4(gMinMaxConstants.z);					//	MAD    sinWave, -temp1, gMinMaxConstants.w, gMinMaxConstants.z;		# y = -(x^2)/7! + 1/5! +	sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.y);	//	MAD    sinWave, sinWave, -temp1, gMinMaxConstants.y;				# y = -(x^2) * (-(x^2)/7! + 1/5!) + 1/3! +	sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.x);	//	MAD    sinWave, sinWave, -temp1, gMinMaxConstants.x;				# y = -(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1 +	sinWave = sinWave * windEffect;							//	MUL    sinWave, sinWave, windEffect;								# y = x * (-(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1) +	 +	// sinWave.x holds sin(norm . wind_direction) with primary frequency +	// sinWave.y holds sin(norm . wind_direction) with secondary frequency +	// sinWave.z hold cos(norm . wind_direction) with primary frequency +	sinWave.xyz = sinWave.xyz * gWindDir.w  +				+ vec3(windEffect.w);						//	MAD sinWave.xyz, sinWave, gWindDir.w, windEffect.w;					# multiply by wind strength in gWindDir.w [-wind, wind] + +	// add normal facing bias offset [-wind,wind] -> [-wind - .25, wind + 1] +	temp1 = vec4(dot(norm, gGravity.xyz));					//	DP3 temp1, blendNorm, gGravity;										# how much is this normal facing in direction of gGravity? +	temp1 = min(temp1, vec4(0.2,0.0,0.0,0.0));				//	MIN temp1, temp1, {0.2, 0, 0, 0};									# clamp [-1, 1] to [-1, 0.2] +	temp1 = temp1*vec4(1.5,0.0,0.0,0.0);					//	MUL temp1, temp1, {1.5, 0, 0, 0};									# scale from [-1,0.2] to [-1.5, 0.3] +	sinWave.x = sinWave.x + temp1.x;						//	ADD sinWave.x, sinWave, temp1;										# add gGravity effect to sinwave (only primary frequency) +	sinWave.xyz = sinWave.xyz * clothing.w;					//	MUL sinWave.xyz, sinWave, iClothing.w;								# modulate by clothing coverage +	 +	sinWave.xyz = max(sinWave.xyz, vec3(-1.0, -1.0, -1.0));	//	MAX sinWave.xyz, sinWave, {-1, -1, -1, -1};							# clamp to underlying body shape +	offsetPos = clothing * sinWave.x;						//	MUL offsetPos, iClothing, sinWave.x;								# multiply wind effect times clothing displacement +	temp2 = gWindDir*sinWave.z + vec4(norm,0);				//	MAD temp2, gWindDir, sinWave.z, blendNorm;							# calculate normal offset due to wind oscillation +	offsetPos = vec4(1.0,1.0,1.0,0.0)*offsetPos+gl_Vertex;	//	MAD offsetPos, {1.0, 1.0, 1.0, 0.0}, offsetPos, iPos;				# add to offset vertex position, and zero out effect from w +	norm += temp2.xyz*2.0;									//	MAD blendNorm, temp2, {2, 2, 2, 2}, blendNorm;						# add sin wave effect on normals (exaggerated) +	 +	//add "backlighting" effect +	float colorAcc; +	colorAcc = 1.0 - clothing.w;							//	SUB colorAcc, {1, 1, 1, 1}, iClothing; +	norm.z -= colorAcc * 0.2;								//	MAD blendNorm, colorAcc.w, {0, 0, -0.2, 0}, blendNorm; +	 +	//renormalize normal (again) +	norm = normalize(norm);									//	DP3 divisor.w, blendNorm, blendNorm; +															// RSQ divisor.xyz, divisor.w; +															// MUL blendNorm.xyz, blendNorm, divisor; + +	//project binormal to normal plane to ensure orthogonality +	temp2 = vec4(dot(norm, binorm));						//	DP3 temp2, blendNorm, blendBinorm; +	binorm = binorm - temp2.xyz;							//	SUB blendBinorm, blendBinorm, temp2; + +	//renormalize binormal +	binorm = normalize(binorm);								//	DP3 divisor.w, blendBinorm, blendBinorm; +															//	RSQ divisor.xyz, divisor.w; +															//	MUL blendBinorm.xyz, blendBinorm, divisor; + +	pos.x = dot(trans[0], offsetPos); +	pos.y = dot(trans[1], offsetPos); +	pos.z = dot(trans[2], offsetPos); +	pos.w = 1.0; +	 +	vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color.rgb);			 +	gl_FrontColor = color;  +					 +	gl_Position = gl_ProjectionMatrix * pos; +	 +	vec3 N = norm; +	vec3 B = binorm; +	vec3 T = cross(N,B); +	 +	//gl_TexCoord[1].xy = gl_MultiTexCoord0.xy + 1.0/512.0 * vec2(dot(T,gl_LightSource[0].position.xyz), +	//												dot(B,gl_LightSource[0].position.xyz)); + +	gl_TexCoord[2] = vec4(pos.xyz, 1.0); +	default_scatter(pos.xyz, gl_LightSource[0].position.xyz); +										  +}
\ No newline at end of file | 
