|
From: <axl...@us...> - 2009-08-09 01:14:38
|
Revision: 466
http://hgengine.svn.sourceforge.net/hgengine/?rev=466&view=rev
Author: axlecrusher
Date: 2009-08-09 01:14:31 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraphDeferred.xml
Mercury2/Themes/default/Graphic/differedStep1.frag
Mercury2/Themes/default/Graphic/differedStep1.vert
Mercury2/Themes/default/Graphic/globalLight.frag
Mercury2/Themes/default/Graphic/pointLight.frag
Modified: Mercury2/Themes/default/File/scenegraphDeferred.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraphDeferred.xml 2009-08-09 01:13:57 UTC (rev 465)
+++ Mercury2/Themes/default/File/scenegraphDeferred.xml 2009-08-09 01:14:31 UTC (rev 466)
@@ -1,41 +1,38 @@
<SceneGraph name="root">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
- <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="screenFBO" usescreensize="true" colorbyte0="RGBA16F" colorbyte1="RGBA16F">
+ <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true" colorbyte0="RGBA16F" colorbyte1="RGBA16F">
<asset type="shader" file="GRAPHIC:differedStep1"/>
- <node type="light" atten="10,0,0" fullscreen="true" shader="GRAPHIC:globalLight" />
- <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
+ <node type="transformnode" movz="0" movx="0" movy="2">
+ <node type="light" atten="8,0,0" fullscreen="true" shader="GRAPHIC:globalLight" />
+ </node>
+ <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-1">
<asset type="texture" file="MODEL:map.png"/>
<asset type="hgmdlmodel" file="MODEL:map.hgmdl" />
</node>
- <node type="mercurynode" name="lampForest" >
- <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
- <node type="mercurynode" name="lamp">
- <node type="transformnode" rotx="-90" >
- <asset type="texture" file="MODEL:lamp.png"/>
- <asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" />
- <node type="light" atten="0.7,50,0.0" shader="GRAPHIC:pointLight" />
+ <node type="transformnode" movz="-8" movx="-1" name="lamps">
+ <node type="mercurynode" name="lamp">
+ <node type="transformnode" rotx="-90" >
+ <asset type="texture" file="MODEL:lamp.png"/>
+ <asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" />
+ <node type="light" atten="0.7,5,0" shader="GRAPHIC:pointLight" />
+ </node>
+ <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" >
+ <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true">
+ <asset type="texture" file="GRAPHIC:flame.png"/>
+ <asset type="quad" />
</node>
- <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" >
- <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true">
- <asset type="texture" file="GRAPHIC:flame.png"/>
- <asset type="quad" />
- </node>
- </node>
</node>
- <node type="transformnode" movx="1" fallback="lamprow.lamp" />
- <node type="transformnode" movx="2" fallback="lamprow.lamp" />
- <node type="transformnode" movx="3" fallback="lamprow.lamp" />
- <node type="transformnode" movx="-1" fallback="lamprow.lamp" />
- <node type="transformnode" movx="-2" fallback="lamprow.lamp" />
- <node type="transformnode" movx="-3" fallback="lamprow.lamp" />
</node>
- <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/>
- <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/>
- <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/>
- <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/>
- <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/>
- <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/>
+ <node type="transformnode" fallback="lamps.lamp" movz="3"/>
+ <node type="transformnode" fallback="lamps.lamp" movz="6"/>
+ <node type="transformnode" fallback="lamps.lamp" movz="-4"/>
+ <node type="transformnode" fallback="lamps.lamp" movz="-7"/>
+
+ <node type="transformnode" fallback="lamps.lamp" movx="2" movz="4.5"/>
+ <node type="transformnode" fallback="lamps.lamp" movx="2" movz="1.5"/>
+ <node type="transformnode" fallback="lamps.lamp" movx="2" movz="-2.5"/>
+
</node>
</node>
<asset type="texture" file="screenFBO_0" dynamic="true"/>
Modified: Mercury2/Themes/default/Graphic/differedStep1.frag
===================================================================
--- Mercury2/Themes/default/Graphic/differedStep1.frag 2009-08-09 01:13:57 UTC (rev 465)
+++ Mercury2/Themes/default/Graphic/differedStep1.frag 2009-08-09 01:14:31 UTC (rev 466)
@@ -1,14 +1,15 @@
+uniform vec4 HG_DepthRange;
+uniform sampler2D HG_Texture2;
+
varying vec3 normal;
varying vec3 pos;
varying float dist;
-uniform vec4 HG_DepthRange;
-uniform vec4 HG_EyePos;
vec2 CartesianToSpherical(vec3 cartesian)
{
vec2 spherical;
- spherical.x = atan2(cartesian.y, cartesian.x) / 3.14159;
+ spherical.x = atan2(cartesian.y, cartesian.x) * 0.318310155;
spherical.y = cartesian.z;
return spherical * 0.5 + 0.5;
@@ -24,6 +25,6 @@
n.xy = CartesianToSpherical( n );
gl_FragData[0] = vec4( n.xy, d, 1.0);
-// gl_FragData[1] = vec4(pos, 1.0);
+ gl_FragData[1] = texture2D(HG_Texture2, gl_TexCoord[0].st);
}
Modified: Mercury2/Themes/default/Graphic/differedStep1.vert
===================================================================
--- Mercury2/Themes/default/Graphic/differedStep1.vert 2009-08-09 01:13:57 UTC (rev 465)
+++ Mercury2/Themes/default/Graphic/differedStep1.vert 2009-08-09 01:14:31 UTC (rev 466)
@@ -7,7 +7,7 @@
void main()
{
-// gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
vec4 n = vec4(gl_Normal, 0);
Modified: Mercury2/Themes/default/Graphic/globalLight.frag
===================================================================
--- Mercury2/Themes/default/Graphic/globalLight.frag 2009-08-09 01:13:57 UTC (rev 465)
+++ Mercury2/Themes/default/Graphic/globalLight.frag 2009-08-09 01:14:31 UTC (rev 466)
@@ -1,4 +1,6 @@
uniform sampler2D HG_Texture0;
+uniform sampler2D HG_Texture1;
+
uniform vec4 HG_EyePos;
uniform ivec4 HG_ViewPort;
uniform vec4 HG_LightPos;
@@ -7,7 +9,9 @@
uniform mat4 HG_ModelMatrix;
uniform vec4 HG_DepthRange;
+uniform vec4 HG_LookVector;
+
varying vec3 ecEye;
varying vec3 ecLight;
varying vec3 ecFrag;
@@ -38,29 +42,25 @@
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;
+ if( dist > HG_LightAtten.w ) 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 +
+ float att = 1.0 / (HG_LightAtten.x + HG_LightAtten.y * dist +
HG_LightAtten.z * dist * dist);
- vec3 color = att * (HG_LightColor.rgb * NdotL);
+ vec3 diffuse = texture2D(HG_Texture1, coord).rgb;
- vec3 hv = normalize( lightDir+(ecEye-pos) );
- float NdotHV = max(dot(norm,hv),0.0);
+ vec3 R = reflect(-lightDir, norm);
+ vec3 specular = diffuse * pow( max(dot(R,HG_LookVector.xyz), 0.0), 10.0 );
- //pow(max(dot(H, normal.xyz), 0.0)
+ diffuse *= HG_LightColor.rgb * NdotL;
- color += att * materialSpec * lightSpec * pow(max(NdotHV, 0.0), 3.0);
- color = clamp(color, 0.0, 1.0);
- gl_FragColor = vec4(color, 1.0);
+ vec3 color = diffuse;
+
+ color += specular;
+ color *= att;
+
+ gl_FragColor.rgb = clamp(color, 0.0, 1.0);
}
Modified: Mercury2/Themes/default/Graphic/pointLight.frag
===================================================================
--- Mercury2/Themes/default/Graphic/pointLight.frag 2009-08-09 01:13:57 UTC (rev 465)
+++ Mercury2/Themes/default/Graphic/pointLight.frag 2009-08-09 01:14:31 UTC (rev 466)
@@ -1,11 +1,10 @@
uniform sampler2D HG_Texture0;
-uniform vec4 HG_EyePos;
+uniform sampler2D HG_Texture1;
+
uniform ivec4 HG_ViewPort;
-uniform vec4 HG_LightPos;
uniform vec4 HG_LightAtten;
uniform vec4 HG_LightColor;
-
-uniform mat4 HG_ModelMatrix;
+uniform vec4 HG_LookVector;
uniform vec4 HG_DepthRange;
varying vec3 ecEye;
@@ -27,40 +26,35 @@
{
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 );
+ vec3 mDiffuse = texture2D(HG_Texture1, coord).rgb;
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;
+ if( dist > HG_LightAtten.w ) 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 +
+ float att = 1.0 / (HG_LightAtten.x + HG_LightAtten.y * dist +
HG_LightAtten.z * dist * dist);
- vec3 color = att * (HG_LightColor.rgb * NdotL);
+ vec3 diffuse = texture2D(HG_Texture1, coord).rgb;
- vec3 hv = normalize( lightDir+(ecEye-pos) );
- float NdotHV = max(dot(norm,hv),0.0);
+ vec3 R = reflect(-lightDir, norm);
+ vec3 specular = diffuse * pow( max(dot(R,HG_LookVector.xyz), 0.0), 10.0 );
- //pow(max(dot(H, normal.xyz), 0.0)
+ diffuse *= HG_LightColor.rgb * NdotL;
- color += att * materialSpec * lightSpec * pow(max(NdotHV, 0.0), 100.0);
- color = clamp(color, 0.0, 1.0);
- gl_FragColor = vec4(color, 1.0);
+ vec3 color = diffuse;
+
+ color += specular;
+ color *= att;
+
+ gl_FragColor.rgb = clamp(color, 0.0, 1.0);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|