Thread: [Python-ogre-commit] SF.net SVN: python-ogre: [561] trunk/python-ogre/demos/caelum/media
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-02-04 04:24:39
|
Revision: 561 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=561&view=rev Author: andy_miller Date: 2008-02-03 20:24:38 -0800 (Sun, 03 Feb 2008) Log Message: ----------- Updated Caelum media to the latest from the SVN Modified Paths: -------------- trunk/python-ogre/demos/caelum/media/CaelumShaders.cg trunk/python-ogre/demos/caelum/media/GroundFog.material trunk/python-ogre/demos/caelum/media/GroundFog.program trunk/python-ogre/demos/caelum/media/Haze.program trunk/python-ogre/demos/caelum/media/LayeredClouds.material trunk/python-ogre/demos/caelum/media/Terrain.material Modified: trunk/python-ogre/demos/caelum/media/CaelumShaders.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumShaders.cg 2008-01-30 02:02:12 UTC (rev 560) +++ trunk/python-ogre/demos/caelum/media/CaelumShaders.cg 2008-02-04 04:24:38 UTC (rev 561) @@ -1,3 +1,23 @@ +/* +This file is part of Caelum. +See http://www.ogre3d.org/wiki/index.php/Caelum + +Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. + +Caelum is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Caelum is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Caelum. If not, see <http://www.gnu.org/licenses/>. +*/ + half bias (half b, half x) { return pow (x, log (b) / log (0.5)); } @@ -145,23 +165,18 @@ sampler cloud_shape2 : register(s1); sampler cloud_detail : register(s2); -// Global cloud parameters. -uniform float cloudMassInvScale; -uniform float cloudDetailInvScale; - -uniform float2 cloudMassOffset; -uniform float2 cloudDetailOffset; - -uniform float cloudCover; -uniform float cloudMassBlend; -uniform float cloudDetailBlend; - -uniform float cloudSharpness; -uniform float cloudThickness; -uniform float cloudShininess; - // Get cloud layer intensity at a certain point. -float LayeredClouds_intensity(in float2 pos) +float LayeredClouds_intensity +( + in float2 pos, + float cloudMassInvScale, + float cloudDetailInvScale, + float2 cloudMassOffset, + float2 cloudDetailOffset, + float cloudMassBlend, + float cloudDetailBlend, + float cloudCoverageThreshold +) { // Calculate the base alpha float2 finalMassOffset = cloudMassOffset + pos; @@ -170,7 +185,7 @@ cloudMassBlend); float aDetail = tex2D(cloud_detail, (cloudDetailOffset + pos) * cloudDetailInvScale).r; aCloud = (aCloud + aDetail * cloudDetailBlend) / (1 + cloudDetailBlend); - return max(0, aCloud - (1 - cloudCover)); + return max(0, aCloud - cloudCoverageThreshold); } // Entry point for Cloud vertex program. @@ -179,52 +194,74 @@ in float4 position : POSITION, in float2 uv : TEXCOORD0, + uniform float4x4 worldViewProj, + uniform float3 sunDirection, + out float4 oPosition : POSITION, out float2 oUv : TEXCOORD0, - out float oGlow : TEXCOORD1, - out float3 relPosition : TEXCOORD2, - - uniform float4x4 worldViewProj, - uniform float3 sunDirection + out float3 relPosition : TEXCOORD1, + out float sunGlow : TEXCOORD2 ) { - relPosition = normalize (position); - oGlow = dot (relPosition, normalize (-sunDirection)); oPosition = mul(worldViewProj, position); oUv = uv; + + // This is the relative position, or view direction. + relPosition = normalize (position.xyz); + + // Calculate the angle between the direction of the sun and the current + // view direction. This we call "glow" and ranges from 1 next to the sun + // to -1 in the opposite direction. + sunGlow = dot (relPosition, normalize (-sunDirection)); } // Entry point for Cloud fragment program. void LayeredClouds_fp ( - in float2 uv : TEXCOORD0, - in float glow : TEXCOORD1, - in float3 relPosition : TEXCOORD2, + in float2 uv : TEXCOORD0, + in float3 relPosition : TEXCOORD1, + in float sunGlow : TEXCOORD2, - uniform float cameraHeight, - uniform float3 sunDirection, - uniform float4 sunColour, - uniform float4 fogColour, + uniform float cloudMassInvScale, + uniform float cloudDetailInvScale, + uniform float2 cloudMassOffset, + uniform float2 cloudDetailOffset, + uniform float cloudMassBlend, + uniform float cloudDetailBlend, + uniform float cloudCoverageThreshold, + + uniform float4 sunColour, + uniform float4 fogColour, + uniform float cloudSharpness, + uniform float cloudThickness, + out float4 oCol : COLOR ) { - // Initialize output. + // Initialize output. oCol.rgba = float4(1, 1, 1, 0); // Get cloud intensity. - float intensity = LayeredClouds_intensity(uv); + float intensity = LayeredClouds_intensity + ( + uv, + cloudMassInvScale, + cloudDetailInvScale, + cloudMassOffset, + cloudDetailOffset, + cloudMassBlend, + cloudDetailBlend, + cloudCoverageThreshold + ); // Opacity is exponential. float aCloud = saturate(exp(cloudSharpness * intensity) - 1); - float shine = pow(saturate(glow), 8) / 4; + float shine = pow(saturate(sunGlow), 8) / 4; sunColour.rgb *= 1.5; float3 cloudColour = fogColour.rgb * (1 - intensity / 3); float thickness = saturate(0.8 - exp(-cloudThickness * (intensity + 0.2 - shine))); oCol.rgb = lerp(sunColour.rgb, cloudColour.rgb, thickness); - //oCol.rgb = thickness; - //oCol.rgb = sunColour.rgb; - //oCol.rgb = cloudColour.rgb; // bottom 20th of the sky clouds vanish. // Simple and effective.e Modified: trunk/python-ogre/demos/caelum/media/GroundFog.material =================================================================== --- trunk/python-ogre/demos/caelum/media/GroundFog.material 2008-01-30 02:02:12 UTC (rev 560) +++ trunk/python-ogre/demos/caelum/media/GroundFog.material 2008-02-04 04:24:38 UTC (rev 561) @@ -1,3 +1,23 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + // Sample base material for using CaelumGroundFog. material CaelumGroundFogBase { Modified: trunk/python-ogre/demos/caelum/media/GroundFog.program =================================================================== --- trunk/python-ogre/demos/caelum/media/GroundFog.program 2008-01-30 02:02:12 UTC (rev 560) +++ trunk/python-ogre/demos/caelum/media/GroundFog.program 2008-02-04 04:24:38 UTC (rev 561) @@ -1,3 +1,23 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + vertex_program CaelumGroundFogVP cg { source CaelumShaders.cg Modified: trunk/python-ogre/demos/caelum/media/Haze.program =================================================================== --- trunk/python-ogre/demos/caelum/media/Haze.program 2008-01-30 02:02:12 UTC (rev 560) +++ trunk/python-ogre/demos/caelum/media/Haze.program 2008-02-04 04:24:38 UTC (rev 561) @@ -1,3 +1,23 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + vertex_program CaelumHazeVP cg { source CaelumShaders.cg Modified: trunk/python-ogre/demos/caelum/media/LayeredClouds.material =================================================================== --- trunk/python-ogre/demos/caelum/media/LayeredClouds.material 2008-01-30 02:02:12 UTC (rev 560) +++ trunk/python-ogre/demos/caelum/media/LayeredClouds.material 2008-02-04 04:24:38 UTC (rev 561) @@ -1,3 +1,23 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + vertex_program CaelumLayeredCloudsVP cg { source CaelumShaders.cg @@ -14,42 +34,46 @@ fragment_program CaelumLayeredCloudsFP cg { - source CaelumShaders.cg - entry_point LayeredClouds_fp - profiles ps_2_0 arbfp1 + source CaelumShaders.cg + entry_point LayeredClouds_fp + profiles ps_2_0 arbfp1 - default_params - { - // Caelum sky properties - param_named sunDirection float3 -1 -1 0 - param_named sunColour float4 1 1 1 1 - - // The inverse of the cloud forms scale - param_named cloudMassInvScale float 1.2 - // The inverse of the cloud details scale - param_named cloudDetailInvScale float 4.8 - - // Cloud mass offset - param_named cloudMassOffset float2 0 0 - // Cloud details offset - param_named cloudDetailOffset float2 0.5 0.5 - - // Cloud coverage, between 0 and 1 - param_named cloudCover float 0.9 - // Blending factor between Cloud1 and Cloud2 - param_named cloudMassBlend float 0.9 - // Cloud detail weight. - param_named cloudDetailBlend float 0.5 - - // Cloud sharpness. Lower values result in softer clouds. - param_named cloudSharpness float 4 - - // Cloud thickness. Bigger values results in darker clouds. - param_named cloudThickness float 3 - - // Fog colour; used as the base cloud colour. - param_named fogColour float4 - } + default_params + { + // Caelum sky properties + //param_named sunDirection float3 -1 -1 0 + param_named sunColour float4 1 1 1 1 + + // Fog colour; used as the base cloud colour. + param_named fogColour float4 + + + // The inverse of the cloud forms scale + param_named cloudMassInvScale float 1.2 + // The inverse of the cloud details scale + param_named cloudDetailInvScale float 4.8 + + // Cloud mass offset + param_named cloudMassOffset float2 0 0 + // Cloud details offset + param_named cloudDetailOffset float2 0.5 0.5 + + // Blending factor between Cloud1 and Cloud2 + param_named cloudMassBlend float 0.9 + // Cloud detail weight. + param_named cloudDetailBlend float 0.5 + + + // Cloud coverage, between 0 and 1 + param_named cloudCoverageThreshold float 0.9 + + // Cloud sharpness. Lower values result in softer clouds. + param_named cloudSharpness float 4 + + // Cloud thickness. Bigger values results in darker clouds. + param_named cloudThickness float 3 + + } } material CaelumLayeredClouds Modified: trunk/python-ogre/demos/caelum/media/Terrain.material =================================================================== --- trunk/python-ogre/demos/caelum/media/Terrain.material 2008-01-30 02:02:12 UTC (rev 560) +++ trunk/python-ogre/demos/caelum/media/Terrain.material 2008-02-04 04:24:38 UTC (rev 561) @@ -1,3 +1,23 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + // Base class for materials in the caelum demo. // They have a main pass and additional fog passes. // Perhaps might be better to do this at runtime somehow? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2008-06-25 07:23:43
|
Revision: 614 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=614&view=rev Author: andy_miller Date: 2008-06-25 00:23:47 -0700 (Wed, 25 Jun 2008) Log Message: ----------- Media updates for Caelum Modified Paths: -------------- trunk/python-ogre/demos/caelum/media/LayeredClouds.material Added Paths: ----------- trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg trunk/python-ogre/demos/caelum/media/CloudCoverLookup.png trunk/python-ogre/demos/caelum/media/PointStarfield.material trunk/python-ogre/demos/caelum/media/SkyDome.material trunk/python-ogre/demos/caelum/media/Starfield.material trunk/python-ogre/demos/caelum/media/Sun.material trunk/python-ogre/demos/caelum/media/moon.material trunk/python-ogre/demos/caelum/media/moon_disc.dds trunk/python-ogre/demos/caelum/media/sphere.mesh trunk/python-ogre/demos/caelum/media/sun_disc.png Added: trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg (rev 0) +++ trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,121 @@ +/* +This file is part of Caelum. +See http://www.ogre3d.org/wiki/index.php/Caelum + +Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. + +Caelum is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Caelum is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Caelum. If not, see <http://www.gnu.org/licenses/>. +*/ + +// Return fogging through a layer of fog which drops exponentially by height. +// Foginess at a certain point is exp(-verticalDecay * (h - fogLevel)); +// A fogLevel from the ground fogginess is 1. +float ExpGroundFog (float invSinView, float h1, float h2, + float density, float verticalDecay, float fogLevel) +{ + // Integrate fog on a vertical line from h1 to h2. + float vFog = (-1 / verticalDecay) * + (exp (-verticalDecay * (h2 - fogLevel)) - + exp (-verticalDecay * (h1 - fogLevel))); + return 1 - exp (-density * invSinView * vFog); +} + +// Just like ExpGroundFog with infinite h2 +float ExpGroundFogInf (float invSinView, float h1, + float density, float verticalDecay, float fogLevel) +{ + // Integrate fog on a vertical line from h1 to h2. + float vFog = exp (-verticalDecay * (h1 - fogLevel)) / verticalDecay; + return 1 - exp (-density * invSinView * vFog); +} + +// Entry point for GroundFog vertex program. +void GroundFog_vp +( + float4 position : POSITION, + + out float4 oPosition : POSITION, + out float4 worldPos : TEXCOORD0, + + uniform float4x4 worldViewProj, + uniform float4x4 world +) { + oPosition = mul(worldViewProj, position); + worldPos = mul(world, position); +} + +// Entry point for GroundFog fragment program. +void GroundFog_fp +( + float3 worldPos : TEXCOORD0, + + uniform float3 camPos, + uniform float4 fogColour, + uniform float fogDensity, + uniform float fogVerticalDecay, + uniform float fogGroundLevel, + + out float4 oCol : COLOR +) { + float h1 = camPos.y; + float h2 = worldPos.y; + float invSinView = length(camPos - worldPos) / (h2 - h1); + float fog = ExpGroundFog(invSinView, + h1, h2, fogDensity, fogVerticalDecay, fogGroundLevel); + + oCol.rgb = fogColour.rgb; + oCol.a = fog; +} + +// Entry point for GroundFogDome vertex program. +void GroundFogDome_vp +( + in float4 position : POSITION, + out float4 oPosition : POSITION, + out float3 relPosition : TEXCOORD0, + uniform float4x4 worldViewProj +) { + oPosition = mul(worldViewProj, position); + relPosition = normalize(position); +} + +// Entry point for the GroundFogDome fragment program. +void GroundFogDome_fp +( + in float3 relPosition : TEXCOORD0, + + uniform float cameraHeight, + uniform float4 fogColour, + uniform float fogDensity, + uniform float fogVerticalDecay, + uniform float fogGroundLevel, + + out float4 oCol : COLOR +) { + // Fog magic. + float invSinView = 1 / (relPosition.y); + float h1 = cameraHeight; + float aFog; + + if (invSinView < 0) { + // Gazing into the abyss + aFog = 1; + } else { + aFog = saturate (ExpGroundFogInf ( + invSinView, h1, fogDensity, fogVerticalDecay, fogGroundLevel)); + } + + oCol.a = aFog; + oCol.rgb = fogColour.rgb; +} \ No newline at end of file Added: trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg (rev 0) +++ trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,130 @@ +/* +This file is part of Caelum. +See http://www.ogre3d.org/wiki/index.php/Caelum + +Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. + +Caelum is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Caelum is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Caelum. If not, see <http://www.gnu.org/licenses/>. +*/ + +// Global cloud textures +sampler cloud_shape1 : register(s0); +sampler cloud_shape2 : register(s1); +sampler cloud_detail : register(s2); + +// Get cloud layer intensity at a certain point. +float LayeredClouds_intensity +( + in float2 pos, + float cloudMassInvScale, + float cloudDetailInvScale, + float2 cloudMassOffset, + float2 cloudDetailOffset, + float cloudMassBlend, + float cloudDetailBlend, + float cloudCoverageThreshold +) +{ + // Calculate the base alpha + float2 finalMassOffset = cloudMassOffset + pos; + float aCloud = lerp(tex2D(cloud_shape1, finalMassOffset * cloudMassInvScale).r, + tex2D(cloud_shape2, finalMassOffset * cloudMassInvScale).r, + cloudMassBlend); + float aDetail = tex2D(cloud_detail, (cloudDetailOffset + pos) * cloudDetailInvScale).r; + aCloud = (aCloud + aDetail * cloudDetailBlend) / (1 + cloudDetailBlend); + return max(0, aCloud - cloudCoverageThreshold); +} + +// Entry point for Cloud vertex program. +void LayeredClouds_vp +( + in float4 position : POSITION, + in float2 uv : TEXCOORD0, + + uniform float4x4 worldViewProj, + uniform float3 sunDirection, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float3 relPosition : TEXCOORD1, + out float sunGlow : TEXCOORD2 +) { + oPosition = mul(worldViewProj, position); + oUv = uv; + + // This is the relative position, or view direction. + relPosition = normalize (position.xyz); + + // Calculate the angle between the direction of the sun and the current + // view direction. This we call "glow" and ranges from 1 next to the sun + // to -1 in the opposite direction. + sunGlow = dot (relPosition, normalize (-sunDirection)); +} + +// Entry point for Cloud fragment program. +void LayeredClouds_fp +( + in float2 uv : TEXCOORD0, + in float3 relPosition : TEXCOORD1, + in float sunGlow : TEXCOORD2, + + uniform float cloudMassInvScale, + uniform float cloudDetailInvScale, + uniform float2 cloudMassOffset, + uniform float2 cloudDetailOffset, + uniform float cloudMassBlend, + uniform float cloudDetailBlend, + + uniform float cloudCoverageThreshold, + + uniform float4 sunColour, + uniform float4 fogColour, + uniform float cloudSharpness, + uniform float cloudThickness, + + out float4 oCol : COLOR +) { + // Initialize output. + oCol.rgba = float4(1, 1, 1, 0); + + // Get cloud intensity. + float intensity = LayeredClouds_intensity + ( + uv, + cloudMassInvScale, + cloudDetailInvScale, + cloudMassOffset, + cloudDetailOffset, + cloudMassBlend, + cloudDetailBlend, + cloudCoverageThreshold + ); + + // Opacity is exponential. + float aCloud = saturate(exp(cloudSharpness * intensity) - 1); + + float shine = pow(saturate(sunGlow), 8) / 4; + sunColour.rgb *= 1.5; + float3 cloudColour = fogColour.rgb * (1 - intensity / 3); + float thickness = saturate(0.8 - exp(-cloudThickness * (intensity + 0.2 - shine))); + + oCol.rgb = lerp(sunColour.rgb, cloudColour.rgb, thickness); + + // bottom 20th of the sky clouds vanish. + // Simple and effective.e + aCloud *= saturate (20 * relPosition.y); + + oCol.a = aCloud; + oCol.rgb = (oCol.rgb); +} \ No newline at end of file Added: trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg (rev 0) +++ trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,61 @@ +/* +This file is part of Caelum. +See http://www.ogre3d.org/wiki/index.php/Caelum + +Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. + +Caelum is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Caelum is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Caelum. If not, see <http://www.gnu.org/licenses/>. +*/ + +// Get how much of a certain point on the moon is seen (or not) because of the phase. +// uv is the rect position on moon; as seen from the earth. +// phase ranges from 0 to 2 +float MoonPhaseFactor(float2 uv, float phase) +{ + float alpha = 1.0; + + float srefx = uv.x - 0.5; + float refx = abs(uv.x - 0.5); + float refy = abs(uv.y - 0.5); + float refxfory = sqrt(0.25 - refy * refy); + float xmin = -refxfory; + float xmax = refxfory; + float xmin1 = (xmax - xmin) * (phase / 2) + xmin; + float xmin2 = (xmax - xmin) * phase + xmin; + if (srefx < xmin1) { + alpha = 0; + } else if (srefx < xmin2 && xmin1 != xmin2) { + alpha = (srefx - xmin1) / (xmin2 - xmin1); + } + + return alpha; +} + +void PhaseMoonFP +( + in float2 uv: TEXCOORD0, + uniform float phase, + uniform sampler2D moonDisc: register(s0), + out float4 outcol : COLOR +) +{ + outcol = tex2D(moonDisc, uv); + float alpha = MoonPhaseFactor(uv, phase); + + // Get luminance from the texture. + float lum = dot(outcol.rgb, float3(0.3333, 0.3333, 0.3333)); + //float lum = dot(outcol.rgb, float3(0.3, 0.59, 0.11)); + outcol.a = min(outcol.a, lum * alpha); + outcol.rgb /= lum; +} Added: trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg (rev 0) +++ trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,75 @@ +/* +This file is part of Caelum. +See http://www.ogre3d.org/wiki/index.php/Caelum + +Copyright (c) 2008 Caelum team. See Contributors.txt for details. + +Caelum is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Caelum is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Caelum. If not, see <http://www.gnu.org/licenses/>. +*/ + +void StarPointVP +( + in float4 in_position : POSITION, + in float4 in_color : COLOR, + in float3 in_texcoord : TEXCOORD0, + + uniform float4x4 worldviewproj_matrix, + + // These params are in clipspace; not pixels + uniform float mag_scale, + uniform float mag0_size, + uniform float min_size, + uniform float max_size, + + // width/height + uniform float aspect_ratio, + + out float2 out_texcoord : TEXCOORD0, + out float4 out_position : POSITION, + out float4 out_color : COLOR +) +{ + out_position = mul(worldviewproj_matrix, in_position); + out_texcoord = in_texcoord.xy; + + float magnitude = in_texcoord.z; + float size = exp(mag_scale * magnitude) * mag0_size; + + // Fade below minSize. + float fade = saturate(size / min_size); + out_color = float4(in_color.rgb, fade * fade); + + // Clamp size to range. + size = clamp(size, min_size, max_size); + + // Spalt the billboard on the screen. + // It seems this can sometime mess order after transforms. + // Disabling culling works acceptably for the starfield. + out_position.xy += in_texcoord.xy * float2(size, size * aspect_ratio) * out_position.w; +} + +void StarPointFP +( + in float4 in_color : COLOR, + in float2 in_texcoord : TEXCOORD0, + + out float4 out_color : COLOR +) +{ + out_color = in_color; + float sqlen = dot(in_texcoord, in_texcoord); + + // A gaussian bell of sorts. + out_color.a *= 1.5 * exp(-(sqlen * 8)); +} \ No newline at end of file Added: trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg (rev 0) +++ trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,157 @@ +/* +This file is part of Caelum. +See http://www.ogre3d.org/wiki/index.php/Caelum + +Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. + +Caelum is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Caelum is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Caelum. If not, see <http://www.gnu.org/licenses/>. +*/ + +half bias (half b, half x) { + return pow (x, log (b) / log (0.5)); +} + +half4 sunlightInscatter (half4 sunColour, half absorption, half incidenceAngleCos, half sunlightScatteringFactor) { + half scatteredSunlight = bias (sunlightScatteringFactor * 0.5, incidenceAngleCos); + + sunColour = sunColour * (1 - absorption) * half4 (0.9, 0.5, 0.09, 1); + + return sunColour * scatteredSunlight; +} + +half fogExp (half z, half density) { + return 1 - clamp (pow (2.71828, -z * density), 0, 1); +} + +void SkyDome_vp (half4 position : POSITION, + half4 normal : NORMAL, + half2 uv : TEXCOORD0, + out half4 oPosition : POSITION, + out half4 oCol : COLOR, + out half2 oUv : TEXCOORD0, + out half incidenceAngleCos : TEXCOORD1, + out half y : TEXCOORD2, + out half3 oNormal : TEXCOORD3, + uniform half lightAbsorption, + uniform half4x4 worldViewProj, + uniform half3 sunDirection) +{ + sunDirection = normalize (sunDirection); + normal = normalize (normal); + half cosine = dot (-sunDirection, normal); + incidenceAngleCos = -cosine; + + y = -sunDirection.y; + + oPosition = mul(worldViewProj, position); + oCol = half4 (1, 1, 1, 1); + oUv = uv; + oNormal = -normal.xyz; +} + +void SkyDome_fp (half4 col : COLOR, + half2 uv : TEXCOORD0, + half incidenceAngleCos : TEXCOORD1, + half y : TEXCOORD2, + half3 normal : TEXCOORD3, + out half4 oCol : COLOR, + uniform sampler gradientsMap : register(s0), + uniform sampler1D atmRelativeDepth : register(s1), + uniform half4 hazeColour, + uniform half offset) +{ + half4 sunColour = half4 (3, 3, 3, 1); + +#ifdef HAZE + half fogDensity = 15; + // Haze amount calculation + half invHazeHeight = 100; + half haze = fogExp (pow (clamp (1 - normal.y, 0, 1), invHazeHeight), fogDensity); +#endif // HAZE + + // Pass the colour + oCol = tex2D (gradientsMap, uv + half2 (offset, 0)) * col; + + // Sunlight inscatter + if (incidenceAngleCos > 0) { + half sunlightScatteringFactor = 0.05; + half sunlightScatteringLossFactor = 0.1; + half atmLightAbsorptionFactor = 0.1; + + oCol.rgb += sunlightInscatter (sunColour, + clamp (atmLightAbsorptionFactor * (1 - tex1D (atmRelativeDepth, y).r), 0, 1), + clamp (incidenceAngleCos, 0, 1), + sunlightScatteringFactor).rgb * (1 - sunlightScatteringLossFactor); + } + +#ifdef HAZE + // Haze pass + hazeColour.a = 1; + oCol = oCol * (1 - haze) + hazeColour * haze; +#endif // HAZE +} + +void Haze_vp (half4 position : POSITION, + half4 normal : NORMAL, + out half4 oPosition : POSITION, + out half haze : TEXCOORD0, + out half2 sunlight : TEXCOORD1, + uniform half4x4 worldViewProj, + uniform half4 camPos, + uniform half3 sunDirection) +{ + sunDirection = normalize (sunDirection); + oPosition = mul(worldViewProj, position); + haze = length (camPos - position); + sunlight.x = dot (-sunDirection, normalize (position - camPos)); + sunlight.y = -sunDirection.y; +} + +void Haze_fp (half haze : TEXCOORD0, + half2 sunlight : TEXCOORD1, + out half4 oCol : COLOR, + uniform sampler1D atmRelativeDepth : register(s0), + uniform sampler2D gradientsMap : register (s1), + uniform half4 fogColour) +{ + half incidenceAngleCos = sunlight.x; + half y = sunlight.y; + + half4 sunColour = half4 (3, 2.5, 1, 1); + + half atmLightAbsorptionFactor = 0.1; // Factor determining the amount of light lost due to absorption + half fogDensity = 15; + + haze = fogExp (haze * 0.005, atmLightAbsorptionFactor); + + // Haze amount calculation + half invHazeHeight = 100; + half hazeAbsorption = fogExp (pow (1 - y, invHazeHeight), fogDensity); + + half4 hazeColour; + hazeColour = fogColour; + if (incidenceAngleCos > 0) { + half sunlightScatteringFactor = 0.1; // Factor determining the amount of scattering for the sun light + half sunlightScatteringLossFactor = 0.3; // Factor determining the amount of sun light intensity lost due to scattering + + half4 sunlightInscatterColour = sunlightInscatter (sunColour, + clamp ((1 - tex1D (atmRelativeDepth, y).r) * hazeAbsorption, 0, 1), + clamp (incidenceAngleCos, 0, 1), + sunlightScatteringFactor) * (1 - sunlightScatteringLossFactor); + hazeColour.rgb = hazeColour.rgb * (1 - sunlightInscatterColour.a) + sunlightInscatterColour.rgb * sunlightInscatterColour.a * haze; + } + + oCol = hazeColour; + oCol.a = haze; +} \ No newline at end of file Added: trunk/python-ogre/demos/caelum/media/CloudCoverLookup.png =================================================================== (Binary files differ) Property changes on: trunk/python-ogre/demos/caelum/media/CloudCoverLookup.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/python-ogre/demos/caelum/media/LayeredClouds.material =================================================================== --- trunk/python-ogre/demos/caelum/media/LayeredClouds.material 2008-06-25 07:20:00 UTC (rev 613) +++ trunk/python-ogre/demos/caelum/media/LayeredClouds.material 2008-06-25 07:23:47 UTC (rev 614) @@ -41,7 +41,6 @@ default_params { // Caelum sky properties - //param_named sunDirection float3 -1 -1 0 param_named sunColour float4 1 1 1 1 // Fog colour; used as the base cloud colour. @@ -112,4 +111,35 @@ } } } + + technique + { + pass + { + lighting off + depth_check off + depth_write off + scene_blend colour_blend + fog_override true + + texture_unit Cloud1 + { + anim_texture noise1.png noise2.png noise3.png noise4.png 600 + scale 1.2 1.2 + } + + texture_unit Cloud2 + { + anim_texture noise2.png noise3.png noise4.png noise1.png 600 + scale 1.2 1.2 + colour_op_ex blend_manual src_texture src_current 0.5 + } + + texture_unit Detail + { + texture noise1.png + colour_op_ex modulate src_manual src_current 0.1 0.1 0.1 + } + } + } } \ No newline at end of file Added: trunk/python-ogre/demos/caelum/media/PointStarfield.material =================================================================== --- trunk/python-ogre/demos/caelum/media/PointStarfield.material (rev 0) +++ trunk/python-ogre/demos/caelum/media/PointStarfield.material 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,74 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2008 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + +vertex_program Caelum/StarPointVP cg +{ + source CaelumPointStarfield.cg + entry_point StarPointVP + profiles vs_2_0 arbvp1 vp30 + + default_params + { + param_named_auto worldviewproj_matrix worldviewproj_matrix + + // Default parameters only here to quiet ogre. + param_named mag_scale float -1 + param_named mag0_size float -1 + param_named min_size float -1 + param_named max_size float -1 + param_named aspect_ratio float -1 + } +} + +fragment_program Caelum/StarPointFP cg +{ + source CaelumPointStarfield.cg + entry_point StarPointFP + profiles ps_2_0 arbfp1 fp30 + + default_params + { + } +} + +material Caelum/StarPoint +{ + receive_shadows off + + technique + { + pass + { + depth_check off + depth_write off + + vertex_program_ref Caelum/StarPointVP + { + } + + fragment_program_ref Caelum/StarPointFP + { + } + + scene_blend alpha_blend + cull_hardware none + } + } +} Added: trunk/python-ogre/demos/caelum/media/SkyDome.material =================================================================== --- trunk/python-ogre/demos/caelum/media/SkyDome.material (rev 0) +++ trunk/python-ogre/demos/caelum/media/SkyDome.material 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,117 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + +fragment_program CaelumSkyDomeFP cg +{ + source CaelumSkyDome.cg + entry_point SkyDome_fp + compile_arguments -DHAZE + profiles ps_2_0 arbfp1 + + default_params + { + // Caelum sky properties + param_named offset float 0 + param_named hazeColour float4 0 0 0 0 + } +} + +fragment_program CaelumSkyDomeFP_NoHaze cg +{ + source CaelumSkyDome.cg + entry_point SkyDome_fp + profiles ps_2_0 arbfp1 + + default_params + { + // Caelum sky properties + param_named offset float 0 + } +} + +vertex_program CaelumSkyDomeVP cg +{ + source CaelumSkyDome.cg + entry_point SkyDome_vp + profiles vs_2_0 arbvp1 + compile_arguments -posinv + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named sunDirection float3 1 0 0 + } +} + +material CaelumSkyDomeMaterial +{ + receive_shadows off + + technique + { + pass + { + lighting off + depth_check off + depth_write off + scene_blend alpha_blend + fog_override true none + + vertex_program_ref CaelumSkyDomeVP + { + } + + fragment_program_ref CaelumSkyDomeFP + { + } + + texture_unit + { + texture EarthClearSky2.png 0 + tex_address_mode clamp + } + + texture_unit + { + texture AtmosphereDepth.png 1d + tex_address_mode clamp + } + } + } + + technique + { + pass + { + lighting off + depth_check off + depth_write off + scene_blend alpha_blend + fog_override true + + texture_unit + { + texture EarthClearSky2.png 0 + tex_address_mode clamp + } + } + } +} + Added: trunk/python-ogre/demos/caelum/media/Starfield.material =================================================================== --- trunk/python-ogre/demos/caelum/media/Starfield.material (rev 0) +++ trunk/python-ogre/demos/caelum/media/Starfield.material 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,42 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + +material CaelumStarfieldMaterial +{ + receive_shadows off + + technique + { + pass + { + depth_check off + depth_write off + lighting off + fog_override true + + texture_unit + { + texture Starfield.jpg 0 + tex_address_mode wrap + } + } + } +} + Added: trunk/python-ogre/demos/caelum/media/Sun.material =================================================================== --- trunk/python-ogre/demos/caelum/media/Sun.material (rev 0) +++ trunk/python-ogre/demos/caelum/media/Sun.material 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,58 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2008 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + +material CaelumSphereSun +{ + technique Default + { + pass Main + { + depth_check off + depth_write off + fog_override true none + ambient 0 0 0 + diffuse 0 0 0 + } + } +} + +material CaelumSpriteSun +{ + receive_shadows off + technique Default + { + pass Main + { + lighting off + depth_check off + depth_write off + fog_override true none + ambient 0 0 0 + diffuse 0 0 0 + scene_blend src_colour one_minus_src_colour + alpha_rejection greater_equal 128 + emissive vertexcolour + texture_unit Texture0 + { + texture sun_disc.png 2d 0 + } + } + } +} \ No newline at end of file Added: trunk/python-ogre/demos/caelum/media/moon.material =================================================================== --- trunk/python-ogre/demos/caelum/media/moon.material (rev 0) +++ trunk/python-ogre/demos/caelum/media/moon.material 2008-06-25 07:23:47 UTC (rev 614) @@ -0,0 +1,107 @@ +// +//This file is part of Caelum. +//See http://www.ogre3d.org/wiki/index.php/Caelum +// +//Copyright (c) 2008 Caelum team. See Contributors.txt for details. +// +//Caelum is free software: you can redistribute it and/or modify +//it under the terms of the GNU Lesser General Public License as published +//by the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. +// +//Caelum is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public License +//along with Caelum. If not, see <http://www.gnu.org/licenses/>. +// + +fragment_program Caelum/PhaseMoonFP cg +{ + source CaelumPhaseMoon.cg + entry_point PhaseMoonFP + profiles ps_2_0 arbfp1 fp30 + + default_params + { + param_named phase float 0.3 + } +} + +material Caelum/FullMoon +{ + receive_shadows off + technique Default + { + pass Main + { + lighting off + depth_check off + depth_write off + fog_override true none + ambient 0 0 0 + diffuse 0 0 0 + scene_blend alpha_blend + emissive vertexcolour + + texture_unit Texture0 + { + texture moon_disc.dds 2d + } + } + } +} + +material Caelum/PhaseMoon +{ + receive_shadows off + technique Default + { + pass Main + { + lighting off + depth_check off + depth_write off + fog_override true none + ambient 0 0 0 + diffuse 0 0 0 + scene_blend alpha_blend + + texture_unit MoonDisc + { + texture moon_disc.dds + } + + fragment_program_ref Caelum/PhaseMoonFP + { + } + } + } +} + +material Caelum/MoonBackground +{ + receive_shadows off + technique Default + { + pass Main + { + // Used fixed function lighting to return black. + lighting off + + depth_check off + depth_write off + fog_override true none + scene_blend alpha_blend + + texture_unit MoonDisc + { + texture moon_disc.dds + colour_op_ex source1 src_manual src_diffuse 0 0 0 0 + } + } + } +} + Added: trunk/python-ogre/demos/caelum/media/moon_disc.dds =================================================================== (Binary files differ) Property changes on: trunk/python-ogre/demos/caelum/media/moon_disc.dds ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/python-ogre/demos/caelum/media/sphere.mesh =================================================================== (Binary files differ) Property changes on: trunk/python-ogre/demos/caelum/media/sphere.mesh ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/python-ogre/demos/caelum/media/sun_disc.png =================================================================== (Binary files differ) Property changes on: trunk/python-ogre/demos/caelum/media/sun_disc.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |