|
From: <axl...@us...> - 2009-08-08 23:19:15
|
Revision: 463
http://hgengine.svn.sourceforge.net/hgengine/?rev=463&view=rev
Author: axlecrusher
Date: 2009-08-08 23:19:07 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
light shader updates
Modified Paths:
--------------
Mercury2/Themes/default/Graphic/differedStep1.frag
Added Paths:
-----------
Mercury2/Themes/default/Graphic/globalLight.frag
Mercury2/Themes/default/Graphic/globalLight.vert
Mercury2/Themes/default/Graphic/pointLight.frag
Mercury2/Themes/default/Graphic/pointLight.vert
Removed Paths:
-------------
Mercury2/Themes/default/Graphic/differedStep2.frag
Mercury2/Themes/default/Graphic/differedStep2.vert
Modified: Mercury2/Themes/default/Graphic/differedStep1.frag
===================================================================
--- Mercury2/Themes/default/Graphic/differedStep1.frag 2009-08-08 23:08:31 UTC (rev 462)
+++ Mercury2/Themes/default/Graphic/differedStep1.frag 2009-08-08 23:19:07 UTC (rev 463)
@@ -23,5 +23,7 @@
vec3 n = normalize(normal);
n.xy = CartesianToSpherical( n );
gl_FragData[0] = vec4( n.xy, d, 1.0);
+
+// gl_FragData[1] = vec4(pos, 1.0);
}
Deleted: Mercury2/Themes/default/Graphic/differedStep2.frag
===================================================================
--- Mercury2/Themes/default/Graphic/differedStep2.frag 2009-08-08 23:08:31 UTC (rev 462)
+++ Mercury2/Themes/default/Graphic/differedStep2.frag 2009-08-08 23:19:07 UTC (rev 463)
@@ -1,67 +0,0 @@
-uniform sampler2D HG_Texture0;
-uniform vec4 HG_EyePos;
-uniform ivec4 HG_ViewPort;
-uniform vec4 HG_LightPos;
-uniform vec4 HG_LightAtten;
-uniform vec4 HG_LightColor;
-
-uniform mat4 HG_ModelMatrix;
-uniform vec4 HG_DepthRange;
-
-varying vec3 ecEye;
-varying vec3 ecLight;
-varying vec3 ecFrag;
-
-vec3 SphericalToCartesian(vec2 spherical)
-{
- vec2 sinCosTheta, sinCosPhi;
-
- spherical = spherical * 2.0 - 1.0;
- sincos(spherical.x * 3.14159, sinCosTheta.x, sinCosTheta.y);
- sinCosPhi = vec2(sqrt(1.0 - spherical.y * spherical.y), spherical.y);
-
- return vec3(sinCosTheta.y * sinCosPhi.x, sinCosTheta.x * sinCosPhi.x, sinCosPhi.y);
-}
-
-void main()
-{
- vec2 coord = gl_FragCoord.xy / vec2(HG_ViewPort.zw - HG_ViewPort.xy);
- vec4 t1 = texture2D(HG_Texture0, coord);
-// vec3 norm = texture2D(HG_Texture1, coord).rgb;
- vec3 norm = SphericalToCartesian( t1.rg );
- float depth = t1.b;
-
- vec3 ray = ecFrag * (HG_DepthRange.y/-ecFrag.z);
- vec3 pos = ray * depth;
-
- vec3 eyeVec = normalize(ecEye - pos);
- vec3 lightDir = ecLight - pos;
-
- float dist = length(lightDir);
- lightDir /= dist; //normalize
-// gl_FragColor = vec4(vec3(mod(depth,0.998)), 1.0);
-// gl_FragColor = vec4((norm+1.0)*0.5, 1.0);
-
- float NdotL = max(dot(norm, lightDir),0.0);
-
- if((dist > HG_LightAtten.w) || (NdotL <= 0.0)) discard;
-
- vec3 materialSpec = vec3(1.0,1.0,1.0);
- vec3 lightSpec = vec3(1.0,1.0,1.0);
-
- //x = constant, y = linear, z = quad
- float att = 1.0 / (HG_LightAtten.x +
- HG_LightAtten.y * dist +
- HG_LightAtten.z * dist * dist);
-
- vec3 color = att * (HG_LightColor.rgb * NdotL);
-
- vec3 hv = normalize( lightDir+(ecEye-pos) );
- float NdotHV = max(dot(norm,hv),0.0);
-
- //pow(max(dot(H, normal.xyz), 0.0)
-
- color += att * materialSpec * lightSpec * pow(max(NdotHV, 0.0), 100.0);
- color = clamp(color, 0.0, 1.0);
- gl_FragColor = vec4(color, 1.0);
-}
Deleted: Mercury2/Themes/default/Graphic/differedStep2.vert
===================================================================
--- Mercury2/Themes/default/Graphic/differedStep2.vert 2009-08-08 23:08:31 UTC (rev 462)
+++ Mercury2/Themes/default/Graphic/differedStep2.vert 2009-08-08 23:19:07 UTC (rev 463)
@@ -1,20 +0,0 @@
-uniform mat4 HG_ModelMatrix;
-uniform vec4 HG_EyePos;
-uniform vec4 HG_LightPos;
-
-//uniform vec4 HG_NearClip;
-uniform vec4 HG_FarClip;
-//uniform vec4 HG_ClipExtends;
-
-varying vec3 ecEye;
-varying vec3 ecLight;
-varying vec3 ecFrag;
-
-void main()
-{
- gl_Position = ftransform();
- ecFrag = (gl_ModelViewMatrix * gl_Vertex).xyz; //world position
-
- ecEye = (gl_ModelViewMatrix * HG_EyePos).xyz;
- ecLight = (gl_ModelViewMatrix * vec4(0,0,0,1)).xyz;
-}
Added: Mercury2/Themes/default/Graphic/globalLight.frag
===================================================================
--- Mercury2/Themes/default/Graphic/globalLight.frag (rev 0)
+++ Mercury2/Themes/default/Graphic/globalLight.frag 2009-08-08 23:19:07 UTC (rev 463)
@@ -0,0 +1,66 @@
+uniform sampler2D HG_Texture0;
+uniform vec4 HG_EyePos;
+uniform ivec4 HG_ViewPort;
+uniform vec4 HG_LightPos;
+uniform vec4 HG_LightAtten;
+uniform vec4 HG_LightColor;
+
+uniform mat4 HG_ModelMatrix;
+uniform vec4 HG_DepthRange;
+
+varying vec3 ecEye;
+varying vec3 ecLight;
+varying vec3 ecFrag;
+
+vec3 SphericalToCartesian(vec2 spherical)
+{
+ vec2 sinCosTheta, sinCosPhi;
+
+ spherical = spherical * 2.0 - 1.0;
+ sincos(spherical.x * 3.14159, sinCosTheta.x, sinCosTheta.y);
+ sinCosPhi = vec2(sqrt(1.0 - spherical.y * spherical.y), spherical.y);
+
+ return vec3(sinCosTheta.y * sinCosPhi.x, sinCosTheta.x * sinCosPhi.x, sinCosPhi.y);
+}
+
+void main()
+{
+ vec2 coord = gl_FragCoord.xy / vec2(HG_ViewPort.zw - HG_ViewPort.xy);
+ vec4 t1 = texture2D(HG_Texture0, coord);
+ vec3 norm = SphericalToCartesian( t1.rg );
+ float depth = t1.b;
+
+ vec3 ray = ecFrag * (HG_DepthRange.y/-ecFrag.z);
+ vec3 pos = ray * depth;
+
+ vec3 eyeVec = normalize(ecEye - pos);
+ vec3 lightDir = ecLight - pos;
+
+ float dist = length(lightDir);
+ lightDir /= dist; //normalize
+// gl_FragColor = vec4(vec3(mod(pos,0.998)), 1.0);
+// gl_FragColor = vec4((ray+1.0)*0.5, 1.0);
+
+ float NdotL = max(dot(norm, lightDir),0.0);
+
+ if((dist > HG_LightAtten.w) || (NdotL <= 0.0)) discard;
+
+ vec3 materialSpec = vec3(1.0,1.0,1.0);
+ vec3 lightSpec = vec3(1.0,1.0,1.0);
+
+ //x = constant, y = linear, z = quad
+ float att = 1.0 / (HG_LightAtten.x +
+ HG_LightAtten.y * dist +
+ HG_LightAtten.z * dist * dist);
+
+ vec3 color = att * (HG_LightColor.rgb * NdotL);
+
+ vec3 hv = normalize( lightDir+(ecEye-pos) );
+ float NdotHV = max(dot(norm,hv),0.0);
+
+ //pow(max(dot(H, normal.xyz), 0.0)
+
+ color += att * materialSpec * lightSpec * pow(max(NdotHV, 0.0), 3.0);
+ color = clamp(color, 0.0, 1.0);
+ gl_FragColor = vec4(color, 1.0);
+}
Added: Mercury2/Themes/default/Graphic/globalLight.vert
===================================================================
--- Mercury2/Themes/default/Graphic/globalLight.vert (rev 0)
+++ Mercury2/Themes/default/Graphic/globalLight.vert 2009-08-08 23:19:07 UTC (rev 463)
@@ -0,0 +1,21 @@
+uniform mat4 HG_ModelMatrix;
+uniform mat4 HG_ViewMatrix;
+uniform vec4 HG_EyePos;
+uniform vec4 HG_LightPos;
+
+//uniform vec4 HG_NearClip;
+uniform vec4 HG_FarClip;
+//uniform vec4 HG_ClipExtends;
+
+varying vec3 ecEye;
+varying vec3 ecLight;
+varying vec3 ecFrag;
+
+void main()
+{
+ gl_Position = ftransform();
+ ecFrag = (gl_ModelViewMatrix * gl_Vertex).xyz; //world position
+
+ ecEye = (gl_ModelViewMatrix * HG_EyePos).xyz;
+ ecLight = (HG_ViewMatrix * HG_ModelMatrix * HG_LightPos).xyz;
+}
Added: Mercury2/Themes/default/Graphic/pointLight.frag
===================================================================
--- Mercury2/Themes/default/Graphic/pointLight.frag (rev 0)
+++ Mercury2/Themes/default/Graphic/pointLight.frag 2009-08-08 23:19:07 UTC (rev 463)
@@ -0,0 +1,66 @@
+uniform sampler2D HG_Texture0;
+uniform vec4 HG_EyePos;
+uniform ivec4 HG_ViewPort;
+uniform vec4 HG_LightPos;
+uniform vec4 HG_LightAtten;
+uniform vec4 HG_LightColor;
+
+uniform mat4 HG_ModelMatrix;
+uniform vec4 HG_DepthRange;
+
+varying vec3 ecEye;
+varying vec3 ecLight;
+varying vec3 ecFrag;
+
+vec3 SphericalToCartesian(vec2 spherical)
+{
+ vec2 sinCosTheta, sinCosPhi;
+
+ spherical = spherical * 2.0 - 1.0;
+ sincos(spherical.x * 3.14159, sinCosTheta.x, sinCosTheta.y);
+ sinCosPhi = vec2(sqrt(1.0 - spherical.y * spherical.y), spherical.y);
+
+ return vec3(sinCosTheta.y * sinCosPhi.x, sinCosTheta.x * sinCosPhi.x, sinCosPhi.y);
+}
+
+void main()
+{
+ vec2 coord = gl_FragCoord.xy / vec2(HG_ViewPort.zw - HG_ViewPort.xy);
+ vec4 t1 = texture2D(HG_Texture0, coord);
+// vec3 norm = texture2D(HG_Texture1, coord).rgb;
+ vec3 norm = SphericalToCartesian( t1.rg );
+ float depth = t1.b;
+
+ vec3 ray = ecFrag * (HG_DepthRange.y/-ecFrag.z);
+ vec3 pos = ray * depth;
+
+ vec3 eyeVec = normalize(ecEye - pos);
+ vec3 lightDir = ecLight - pos;
+
+ float dist = length(lightDir);
+ lightDir /= dist; //normalize
+// gl_FragColor = vec4((norm+1.0)*0.5, 1.0);
+
+ float NdotL = max(dot(norm, lightDir),0.0);
+
+ if((dist > HG_LightAtten.w) || (NdotL <= 0.0)) discard;
+
+ vec3 materialSpec = vec3(1.0,1.0,1.0);
+ vec3 lightSpec = vec3(1.0,1.0,1.0);
+
+ //x = constant, y = linear, z = quad
+ float att = 1.0 / (HG_LightAtten.x +
+ HG_LightAtten.y * dist +
+ HG_LightAtten.z * dist * dist);
+
+ vec3 color = att * (HG_LightColor.rgb * NdotL);
+
+ vec3 hv = normalize( lightDir+(ecEye-pos) );
+ float NdotHV = max(dot(norm,hv),0.0);
+
+ //pow(max(dot(H, normal.xyz), 0.0)
+
+ color += att * materialSpec * lightSpec * pow(max(NdotHV, 0.0), 100.0);
+ color = clamp(color, 0.0, 1.0);
+ gl_FragColor = vec4(color, 1.0);
+}
Added: Mercury2/Themes/default/Graphic/pointLight.vert
===================================================================
--- Mercury2/Themes/default/Graphic/pointLight.vert (rev 0)
+++ Mercury2/Themes/default/Graphic/pointLight.vert 2009-08-08 23:19:07 UTC (rev 463)
@@ -0,0 +1,20 @@
+uniform mat4 HG_ModelMatrix;
+uniform vec4 HG_EyePos;
+uniform vec4 HG_LightPos;
+
+//uniform vec4 HG_NearClip;
+uniform vec4 HG_FarClip;
+//uniform vec4 HG_ClipExtends;
+
+varying vec3 ecEye;
+varying vec3 ecLight;
+varying vec3 ecFrag;
+
+void main()
+{
+ gl_Position = ftransform();
+ ecFrag = (gl_ModelViewMatrix * gl_Vertex).xyz; //world position
+
+ ecEye = (gl_ModelViewMatrix * HG_EyePos).xyz;
+ ecLight = (gl_ModelViewMatrix * vec4(0,0,0,1)).xyz;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|