From: <re...@us...> - 2007-10-05 15:32:27
|
Revision: 27828 http://crystal.svn.sourceforge.net/crystal/?rev=27828&view=rev Author: res2002 Date: 2007-10-05 08:32:25 -0700 (Fri, 05 Oct 2007) Log Message: ----------- res changed the "classic lighting" weaver snippet to take advantage of directional lightmaps. Modified Paths: -------------- CS/trunk/data/shader/lighting/light-classic.xml CS/trunk/data/shader/std_lighting_2.xml CS/trunk/docs/history.txt Modified: CS/trunk/data/shader/lighting/light-classic.xml =================================================================== --- CS/trunk/data/shader/lighting/light-classic.xml 2007-10-05 15:30:30 UTC (rev 27827) +++ CS/trunk/data/shader/lighting/light-classic.xml 2007-10-05 15:32:25 UTC (rev 27828) @@ -17,6 +17,137 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --> <snippet> + <technique priority="150"> + <combiner name="cg" plugin="crystalspace.graphics3d.shader.combiner.glcg" /> + + <input file="/shader/snippets/primaryColor.inp" /> + + <input name="ambient" type="rgb" default="complex"> + <block location="cg:variablemap"> + <variablemap variable="dynamic ambient" destination="fragmentIn.lightingAmbient" /> + </block> + + <block location="cg:fragmentIn"> + <uniform type="rgb" name="lightingAmbient" /> + </block> + + <block location="cg:fragmentMain"> + ambient = fragmentIn.lightingAmbient; + </block> + </input> + + <input name="texCoordLM" type="texcoord2" default="complex" private="yes"> + <block location="pass"> + <buffer source="texture coordinate lightmap" + destination="vertexIn.texcoordLM" /> + </block> + + <block location="cg:vertexToFragment"> + <varying type="texcoord2" name="texCoordLM" /> + </block> + + <block location="cg:vertexIn"> + <varying type="texcoord2" name="texcoordLM" /> + </block> + + <block location="cg:vertexMain"> + texCoordLM = vertexIn.texcoordLM; + </block> + </input> + + <!-- Surface normal --> + <input name="normal" type="normal_tangent" /> + + <input name="lightmap" type="tex2d" default="complex" private="yes"> + <block location="pass"> + <texture name="tex lightmap" destination="fragmentIn.lightmap" /> + </block> + + <block location="cg:fragmentIn"> + <uniform type="tex2d" name="lightmap" /> + </block> + + <block location="cg:fragmentMain"> + lightmap = fragmentIn.lightmap; + </block> + </input> + <input name="lightmap_dir1" type="tex2d" default="complex" private="yes"> + <block location="pass"> + <texture name="tex lightmap dir 1" destination="fragmentIn.lightmap_dir1" /> + </block> + + <block location="cg:fragmentIn"> + <uniform type="tex2d" name="lightmap_dir1" /> + </block> + + <block location="cg:fragmentMain"> + lightmap_dir1 = fragmentIn.lightmap_dir1; + </block> + </input> + <input name="lightmap_dir2" type="tex2d" default="complex" private="yes"> + <block location="pass"> + <texture name="tex lightmap dir 2" destination="fragmentIn.lightmap_dir2" /> + </block> + + <block location="cg:fragmentIn"> + <uniform type="tex2d" name="lightmap_dir2" /> + </block> + + <block location="cg:fragmentMain"> + lightmap_dir2 = fragmentIn.lightmap_dir2; + </block> + </input> + <input name="lightmap_dir3" type="tex2d" default="complex" private="yes"> + <block location="pass"> + <texture name="tex lightmap dir 3" destination="fragmentIn.lightmap_dir3" /> + </block> + + <block location="cg:fragmentIn"> + <uniform type="tex2d" name="lightmap_dir3" /> + </block> + + <block location="cg:fragmentMain"> + lightmap_dir3 = fragmentIn.lightmap_dir3; + </block> + </input> + + <block location="cg:vertexMain"> + illumination = float3 (0); + </block> + + <block location="cg:fragmentMain"> + float3 illum_ambient = ambient; + float3 illum_diffuse; + <!-- The "tex normal" test is not nice... breaks "abstraction" ... --> + <?if vars."tex normal".texture && vars."tex lightmap dir 1".texture ?> + <![CDATA[ + /* These should really match up with those in lighter2... */ + float3 base[3] = + { + float3 (/* -1/sqrt(6) */ -0.408248, /* 1/sqrt(2) */ 0.707107, /* 1/sqrt(3) */ 0.577350), + float3 (/* sqrt(2/3) */ 0.816497, 0, /* 1/sqrt(3) */ 0.577350), + float3 (/* -1/sqrt(6) */ -0.408248, /* -1/sqrt(2) */ -0.707107, /* 1/sqrt(3) */ 0.577350) + }; + float3 coeff = float3 (saturate (dot (normal, base[0])), + saturate (dot (normal, base[1])), + saturate (dot (normal, base[2]))); + coeff *= coeff; + illum_diffuse = 2 * (coeff.x * tex2D (lightmap_dir1, texCoordLM).rgb + + coeff.y * tex2D (lightmap_dir2, texCoordLM).rgb + + coeff.z * tex2D (lightmap_dir3, texCoordLM).rgb); + ]]> + <?elsif vars."tex lightmap".texture ?> + illum_diffuse = 2 * tex2D (lightmap, texCoordLM).rgb; + <?else?> + illum_ambient = float3 (0, 0, 0); + illum_diffuse = primaryColor.rgb; + <?endif?> + illumination = illum_ambient + illum_diffuse; + </block> + + <output name="illumination" type="rgb" /> + </technique> + <technique priority="100"> <combiner name="cg" plugin="crystalspace.graphics3d.shader.combiner.glcg" /> @@ -36,9 +167,7 @@ </block> </input> - <!-- Keep non-private? --> - <input name="texCoordLM" type="texcoord2" default="complex" - condition='vars."tex lightmap".texture'> + <input name="texCoordLM" type="texcoord2" default="complex" private="yes"> <block location="pass"> <buffer source="texture coordinate lightmap" destination="vertexIn.texcoordLM" /> @@ -57,9 +186,7 @@ </block> </input> - <!-- Keep non-private? --> - <input name="lightmap" type="tex2d" default="complex" - condition='vars."tex lightmap".texture'> + <input name="lightmap" type="tex2d" default="complex" private="yes"> <block location="pass"> <texture name="tex lightmap" destination="fragmentIn.lightmap" /> </block> Modified: CS/trunk/data/shader/std_lighting_2.xml =================================================================== --- CS/trunk/data/shader/std_lighting_2.xml 2007-10-05 15:30:30 UTC (rev 27827) +++ CS/trunk/data/shader/std_lighting_2.xml 2007-10-05 15:32:25 UTC (rev 27828) @@ -30,6 +30,7 @@ <!-- Snippets - the building blocks of this shader. --> <snippet id="position" file="snippets/position.xml" /> <snippet id="parallax" file="surface/parallax.xml" /> + <snippet id="normalmap" file="/shader/snippets/surface/normalmap.xml" /> <snippet id="surface" file="surface/surface-classic.xml" /> <snippet id="lighting" file="lighting/light-classic.xml" /> <snippet id="mod_light_surf" file="snippets/modulate.xml" /> @@ -41,6 +42,7 @@ what output is linked to what input is done automatically. --> <connection from="position" to="parallax" /> <connection from="parallax" to="surface" /> + <connection from="normalmap" to="lighting" /> <connection from="surface" to="mod_light_surf" /> <connection from="lighting" to="mod_light_surf" /> <connection from="mod_light_surf" to="glow" /> Modified: CS/trunk/docs/history.txt =================================================================== --- CS/trunk/docs/history.txt 2007-10-05 15:30:30 UTC (rev 27827) +++ CS/trunk/docs/history.txt 2007-10-05 15:32:25 UTC (rev 27828) @@ -37,6 +37,8 @@ internally assigned to the wrong block (and hence cause invalid output). - res added initial support for directional lightmaps to lighter2. + - res changed the "classic lighting" weaver snippet to take advantage + of directional lightmaps. 04-Oct-2007 - andres added a VarFileInfo Block to the resources for win32 dlls/executables as they are invalid without and especially considered This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |