[Python-ogre-commit] SF.net SVN: python-ogre:[716] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-09-01 14:19:36
|
Revision: 716 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=716&view=rev Author: andy_miller Date: 2008-09-01 14:19:39 +0000 (Mon, 01 Sep 2008) Log Message: ----------- Updates getting ready for the next binary release Updates to Hikari -- fixed some alaises Added and updated media for Ogre and particle universe Modified Paths: -------------- trunk/python-ogre/code_generators/hikari/customization_data.py trunk/python-ogre/code_generators/hikari/generate_code.py trunk/python-ogre/code_generators/hikari/python_hikari_aliases.h trunk/python-ogre/code_generators/ogre/generate_code.py trunk/python-ogre/demos/cegui/CEGUI_framework.py trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.glsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.hlsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.glsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.hlsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_minilight.glsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_multipass.glsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_multipass.hlsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_onepass.glsl.program trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_onepass.hlsl.program trunk/python-ogre/demos/media/materials/scripts/Examples.compositor trunk/python-ogre/demos/particleuniverse/Demo_Particle.py trunk/python-ogre/demos/particleuniverse/media/ParticleUniverse/models/fxpression.mesh trunk/python-ogre/demos/particleuniverse/media/ParticleUniverse/models/pu_stone.mesh trunk/python-ogre/environment.py trunk/python-ogre/scripts/MakeRelease.bat trunk/python-ogre/scripts/UpdateDLLs.bat trunk/python-ogre/scripts/build_html.bat trunk/python-ogre/scripts/compilesource.bat trunk/python-ogre/scripts/epydoc_config Added Paths: ----------- trunk/python-ogre/demos/media/ParticleUniverse/ trunk/python-ogre/demos/media/ParticleUniverse/gui/ trunk/python-ogre/demos/media/ParticleUniverse/gui/puviewer.layout trunk/python-ogre/demos/media/ParticleUniverse/material/ trunk/python-ogre/demos/media/ParticleUniverse/material/pu_burst.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_explosion.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_flame.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_fxpression.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_generic.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_lightning.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_lod.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_rain.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_stone.material trunk/python-ogre/demos/media/ParticleUniverse/material/pu_tornado.material trunk/python-ogre/demos/media/ParticleUniverse/models/ trunk/python-ogre/demos/media/ParticleUniverse/models/fxpression.mesh trunk/python-ogre/demos/media/ParticleUniverse/models/pu_stone.mesh trunk/python-ogre/demos/media/ParticleUniverse/scripts/ trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_example_11_20.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_example_1_10.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_example_21_30.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_explosion.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_flame.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_fxpression.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_generic.pua trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_lightning.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_lod.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_rain.pu trunk/python-ogre/demos/media/ParticleUniverse/scripts/pu_tornado.pu trunk/python-ogre/demos/media/ParticleUniverse/textures/ trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/ trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/pu_mist_01_128x128.png trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/pu_smoke_01_128x128.png trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/pu_smoke_02_128x128.png trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/pu_star_01_128x128.png trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/pu_star_02_128x128.png trunk/python-ogre/demos/media/ParticleUniverse/textures/128x128/pu_water_01_128x128.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/ trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_10_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_11_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_12_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_13_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_14_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_15_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_16_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_17_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_flare_23_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/256x256/pu_smoke_01_256x256.png trunk/python-ogre/demos/media/ParticleUniverse/textures/32x32/ trunk/python-ogre/demos/media/ParticleUniverse/textures/32x32/pu_rain_01.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/ trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_dot_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_dot_02_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_dot_03_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_dot_04_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_explode_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_fire_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_flare_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_flare_02_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_flare_03_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_ice_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_nucleus.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_smoke_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_smoke_02_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_star_01_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_star_02_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_star_03_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_star_04_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_star_05_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/64x64/pu_star_06_64x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/ trunk/python-ogre/demos/media/ParticleUniverse/textures/various/crate6.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_barrel.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_blue_ball.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_circle.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_dirt_256x512.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_dot_5x5.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_flame.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_green_ball.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_hart.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_lightning_20x64.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_plate.jpg trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_red_ball.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_ribbontrail.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_sand_336x330.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke_428x427.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke_black_192x192.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke_brown_336x330.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke_grey_312x312.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke_grey_336x330.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_smoke_red_192x192.png trunk/python-ogre/demos/media/ParticleUniverse/textures/various/pu_stone.jpeg trunk/python-ogre/demos/media/ParticleUniverse/textures/various/sand.jpeg Removed Paths: ------------- trunk/python-ogre/scripts/00-PreReqs.sh Modified: trunk/python-ogre/code_generators/hikari/customization_data.py =================================================================== --- trunk/python-ogre/code_generators/hikari/customization_data.py 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/code_generators/hikari/customization_data.py 2008-09-01 14:19:39 UTC (rev 716) @@ -1,6 +1,6 @@ def header_files( version ): - return [ 'Hikair.h'] + return [ 'Hikari.h'] def huge_classes( version ): return [] Modified: trunk/python-ogre/code_generators/hikari/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/hikari/generate_code.py 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/code_generators/hikari/generate_code.py 2008-09-01 14:19:39 UTC (rev 716) @@ -54,7 +54,15 @@ main_ns = global_ns.namespace( MAIN_NAMESPACE ) else: main_ns = global_ns - + excludes = ['::Hikari::Position::left', + '::Hikari::Position::top', + '::Hikari::Position::position', + '::Hikari::Position::x', + '::Hikari::Position::y' + ] + for x in excludes: + main_ns.variable(x).exclude() + ############################################################ ## ## And there are things that manually need to be INCLUDED @@ -195,7 +203,8 @@ os.path.join( environment.hikari.root_dir, "python_hikari.h" ) , environment.hikari.cache_file ) - defined_symbols = ['OGRE_NONCLIENT_BUILD', 'HIKARI_NONCLIENT_BUILD', '__VECTOR_C' ] + # Vector_c define to allow GCC to process delegates.h + defined_symbols = ['OGRE_NONCLIENT_BUILD', 'HIKARI_NONCLIENT_BUILD', '__VECTOR_C' ] defined_symbols.append( 'VERSION_' + environment.hikari.version ) # Modified: trunk/python-ogre/code_generators/hikari/python_hikari_aliases.h =================================================================== --- trunk/python-ogre/code_generators/hikari/python_hikari_aliases.h 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/code_generators/hikari/python_hikari_aliases.h 2008-09-01 14:19:39 UTC (rev 716) @@ -1 +1,6 @@ // typedef name nicename; +typedef ::Hikari::Impl::fastdelegate::detail::SimplifyMemFunc< 8 > fastdelegateSimplifyMemFunc8; +typedef ::Hikari::Impl::fastdelegate::detail::SimplifyMemFunc< 12 > fastdelegateSimplifyMemFunc12; +typedef ::Hikari::Impl::fastdelegate::detail::SimplifyMemFunc< 16 > fastdelegateSimplifyMemFunc16; +typedef ::Hikari::Impl::fastdelegate::detail::SimplifyMemFunc< 20 > fastdelegateSimplifyMemFunc20; +typedef ::Hikari::Impl::fastdelegate::detail::VoidToDefaultVoid< void > fastdelegateVoidToDefaultVoidVoid; Modified: trunk/python-ogre/code_generators/ogre/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogre/generate_code.py 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/code_generators/ogre/generate_code.py 2008-09-01 14:19:39 UTC (rev 716) @@ -408,7 +408,8 @@ for fix in AliasFixList: c=mb.member_function(fix[0] ,arg_types=fix[1]) c.add_transformation( fix[2], alias=fix[3]) - + mb.member_function('::Ogre::Math::Abs', arg_types['::Ogre::Real']).alias="AbsReal" + ############################################################ ## ## And things that need to have their argument and call values fixed. Modified: trunk/python-ogre/demos/cegui/CEGUI_framework.py =================================================================== --- trunk/python-ogre/demos/cegui/CEGUI_framework.py 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/cegui/CEGUI_framework.py 2008-09-01 14:19:39 UTC (rev 716) @@ -1,4 +1,5 @@ import ctypes +import os # The follow patch from Tim (Mithro) fixes a loder issue with CEGUI - previously we'd patched CEGUI to # ensure the CEGUIBase was linked to every module to solve the issue with Python dynamically loading @@ -10,7 +11,10 @@ import ogre.gui.CEGUI as CEGUI # Another fix for CEGUI to ensure we get a working parser.. -CEGUI.System.setDefaultXMLParserName("TinyXMLParser") +if os.name == 'nt': + CEGUI.System.setDefaultXMLParserName("ExpatParser") +else: + CEGUI.System.setDefaultXMLParserName("TinyXMLParser") import ogre.io.OIS as OIS import SampleFramework Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl 2008-09-01 14:19:39 UTC (rev 716) @@ -1,96 +1,96 @@ -/****************************************************************************** -Copyright (c) W.J. van der Laan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -Software, and to permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ -/** Deferred shading framework - // W.J. :wumpus: van der Laan 2005 // - - Post shader: Multipass, one light -*/ -uniform sampler2D tex0; -uniform sampler2D tex1; - -varying vec2 texCoord; -varying vec3 projCoord; - -// Attributes of light -uniform vec4 lightPos0; -uniform vec3 lightDiffuseColor0; -uniform vec3 lightSpecularColor0; - -// Global parameters for lights -struct LightGlobal -{ - vec3 position; - vec3 normal; - vec3 viewDir; -}; - -// Current state of light -struct LightAccum -{ - vec3 light_diffuse; - vec3 light_specular; -}; - -// Do lighting calculations for one light -void processLight( - inout LightAccum accum, - LightGlobal global, - vec4 lightPos, - vec3 lightDiffuseColor, - vec3 lightSpecularColor) -{ - vec3 lightVec = vec3(lightPos) - global.position; - vec3 lightDir = normalize(lightVec); - accum.light_diffuse += max(0.0,dot(lightDir, global.normal)) * lightDiffuseColor; - - vec3 h = normalize(global.viewDir + lightDir); - accum.light_specular += pow(dot(global.normal, h),32.0) * lightSpecularColor; -} - -void main() -{ - vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess - vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth - - // Attributes - vec3 colour = a0.rgb; - float alpha = a0.a; // Specularity - float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted - - LightGlobal global; - global.normal = a1.xyz; - global.position = projCoord*distance; - - // Apply light - LightAccum accum; - accum.light_diffuse = vec3(0,0,0); - accum.light_specular = vec3(0,0,0); - global.viewDir = -normalize(global.position); - - processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); - - // Calcalate total lighting for this fragment - vec3 total_light_contrib; - total_light_contrib = accum.light_diffuse+alpha*accum.light_specular; - - // Calculate colour of fragment - gl_FragColor = vec4( total_light_contrib*colour ,0); -} +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Multipass, one light +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +// Attributes of light +uniform vec4 lightPos0; +uniform vec3 lightDiffuseColor0; +uniform vec3 lightSpecularColor0; + +// Global parameters for lights +struct LightGlobal +{ + vec3 position; + vec3 normal; + vec3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + vec3 light_diffuse; + vec3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + vec4 lightPos, + vec3 lightDiffuseColor, + vec3 lightSpecularColor) +{ + vec3 lightVec = vec3(lightPos) - global.position; + vec3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0.0,dot(lightDir, global.normal)) * lightDiffuseColor; + + vec3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32.0) * lightSpecularColor; +} + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + // Attributes + vec3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + + LightGlobal global; + global.normal = a1.xyz; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = vec3(0,0,0); + accum.light_specular = vec3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + + // Calcalate total lighting for this fragment + vec3 total_light_contrib; + total_light_contrib = accum.light_diffuse+alpha*accum.light_specular; + + // Calculate colour of fragment + gl_FragColor = vec4( total_light_contrib*colour ,0); +} Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl 2008-09-01 14:19:39 UTC (rev 716) @@ -1,111 +1,111 @@ -/****************************************************************************** -Copyright (c) W.J. van der Laan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -Software, and to permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ -/** Deferred shading framework - // W.J. :wumpus: van der Laan 2005 // - - Post shader: Single pass -*/ -uniform sampler2D tex0; -uniform sampler2D tex1; - -varying vec2 texCoord; -varying vec3 projCoord; - -uniform mat4 proj; - -uniform vec3 ambientColor; -// Attributes of light 0 -uniform vec4 lightPos0; -uniform vec3 lightDiffuseColor0; -uniform vec3 lightSpecularColor0; -// Attributes of light 1 -uniform vec4 lightPos1; -uniform vec3 lightDiffuseColor1; -uniform vec3 lightSpecularColor1; - -// Global parameters for lights -struct LightGlobal -{ - vec3 position; - vec3 normal; - vec3 viewDir; -}; - -// Current state of light -struct LightAccum -{ - vec3 light_diffuse; - vec3 light_specular; -}; - -// Do lighting calculations for one light -void processLight( - inout LightAccum accum, - LightGlobal global, - vec4 lightPos, - vec3 lightDiffuseColor, - vec3 lightSpecularColor) -{ - vec3 lightVec = vec3(lightPos) - global.position; - vec3 lightDir = normalize(lightVec); - accum.light_diffuse += max(0.0,dot(lightDir, global.normal)) * lightDiffuseColor; - - vec3 h = normalize(global.viewDir + lightDir); - accum.light_specular += pow(dot(global.normal, h),32.0) * lightSpecularColor; -} - -void main() -{ - vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess - vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth - - // Clip fragment if depth is too far, so the skybox can be rendered on the background - if(a1.w==0.0) - discard; - - // Attributes - vec3 colour = a0.rgb; - float alpha = a0.a; // Specularity - float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted - - LightGlobal global; - global.normal = a1.xyz; - global.position = projCoord*distance; - - // Apply light - LightAccum accum; - accum.light_diffuse = vec3(0,0,0); - accum.light_specular = vec3(0,0,0); - global.viewDir = -normalize(global.position); - - processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); - processLight(accum, global, lightPos1, lightDiffuseColor1, lightSpecularColor1); - - // Calcalate total lighting for this fragment - vec3 total_light_contrib; - total_light_contrib = ambientColor+accum.light_diffuse+alpha*accum.light_specular; - - // Calculate colour of fragment - gl_FragColor = vec4( total_light_contrib*colour ,0); - - // Calculate depth of fragment; GL requires a 2.0* here as the range is [-1, 1] - gl_FragDepth = projCoord.z*proj[2][2] + proj[3][2]/(2.0*distance); +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Single pass +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +uniform mat4 proj; + +uniform vec3 ambientColor; +// Attributes of light 0 +uniform vec4 lightPos0; +uniform vec3 lightDiffuseColor0; +uniform vec3 lightSpecularColor0; +// Attributes of light 1 +uniform vec4 lightPos1; +uniform vec3 lightDiffuseColor1; +uniform vec3 lightSpecularColor1; + +// Global parameters for lights +struct LightGlobal +{ + vec3 position; + vec3 normal; + vec3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + vec3 light_diffuse; + vec3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + vec4 lightPos, + vec3 lightDiffuseColor, + vec3 lightSpecularColor) +{ + vec3 lightVec = vec3(lightPos) - global.position; + vec3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0.0,dot(lightDir, global.normal)) * lightDiffuseColor; + + vec3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32.0) * lightSpecularColor; +} + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + // Clip fragment if depth is too far, so the skybox can be rendered on the background + if(a1.w==0.0) + discard; + + // Attributes + vec3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + + LightGlobal global; + global.normal = a1.xyz; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = vec3(0,0,0); + accum.light_specular = vec3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + processLight(accum, global, lightPos1, lightDiffuseColor1, lightSpecularColor1); + + // Calcalate total lighting for this fragment + vec3 total_light_contrib; + total_light_contrib = ambientColor+accum.light_diffuse+alpha*accum.light_specular; + + // Calculate colour of fragment + gl_FragColor = vec4( total_light_contrib*colour ,0); + + // Calculate depth of fragment; GL requires a 2.0* here as the range is [-1, 1] + gl_FragDepth = projCoord.z*proj[2][2] + proj[3][2]/(2.0*distance); } \ No newline at end of file Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl 2008-09-01 14:19:39 UTC (rev 716) @@ -1,42 +1,42 @@ -/****************************************************************************** -Copyright (c) W.J. van der Laan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -Software, and to permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ -/** Deferred shading framework - // W.J. :wumpus: van der Laan 2005 // - - Post shader: Generic fullscreen quad -*/ -varying vec2 texCoord; -varying vec3 projCoord; - -uniform mat4 invProj; - -void main() -{ - vec2 inPos = sign(gl_Vertex.xy); - gl_Position = vec4(inPos.xy, 0.0, 1.0); - - texCoord = (vec2(inPos.x, -inPos.y) + 1.0)/2.0; - - // Projection coordinates - // Inverted projection matrix - // These interpolate over the frustrum plane for w=1 - projCoord = vec3(invProj*vec4(inPos.x, inPos.y, 0, 1)); -} +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Generic fullscreen quad +*/ +varying vec2 texCoord; +varying vec3 projCoord; + +uniform mat4 invProj; + +void main() +{ + vec2 inPos = sign(gl_Vertex.xy); + gl_Position = vec4(inPos.xy, 0.0, 1.0); + + texCoord = (vec2(inPos.x, -inPos.y) + 1.0)/2.0; + + // Projection coordinates + // Inverted projection matrix + // These interpolate over the frustrum plane for w=1 + projCoord = vec3(invProj*vec4(inPos.x, inPos.y, 0, 1)); +} Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl 2008-09-01 14:19:39 UTC (rev 716) @@ -1,101 +1,101 @@ -/****************************************************************************** -Copyright (c) W.J. van der Laan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -Software, and to permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ -/** Deferred shading framework - // W.J. :wumpus: van der Laan 2005 // - - Post shader: Multipass, one light -*/ -sampler Tex0: register(s0); -sampler Tex1: register(s1); - -// Attributes of light 0 -float4 lightPos0; -float4 lightDiffuseColor0; -float4 lightSpecularColor0; - -// Global parameters for lights -struct LightGlobal -{ - float3 position; - float3 normal; - float3 viewDir; -}; - -// Current state of light -struct LightAccum -{ - float3 light_diffuse; - float3 light_specular; -}; - -// Do lighting calculations for one light -void processLight( - inout LightAccum accum, - LightGlobal global, - float4 lightPos, - float4 lightDiffuseColor, - float4 lightSpecularColor) -{ - float3 lightVec = lightPos - global.position; - float3 lightDir = normalize(lightVec); - accum.light_diffuse += max(0,dot(lightDir, global.normal)) * lightDiffuseColor; - - float3 h = normalize(global.viewDir + lightDir); - accum.light_specular += pow(dot(global.normal, h),32) * lightSpecularColor; -} - -float4 main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) : COLOR -{ - float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess - float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth - - LightGlobal global; - - // Clip fragment if depth is too close, so the skybox can be rendered on the background - //clip(a1.w-0.001); - - // Attributes - float3 colour = a0.rgb; - float alpha = a0.a; // Specularity - float distance = a1.w; // Distance from viewer - //global.normal = normalize(a1.xyz); - global.normal = a1.xyz; - - // Acquire view space position via inverse projection transformation - //global.position = mul(invProj, float4(projCoord, 0, 1))*distance; - global.position = projCoord*distance; - - // Apply light - LightAccum accum; - accum.light_diffuse = float3(0,0,0); - accum.light_specular = float3(0,0,0); - global.viewDir = -normalize(global.position); - - processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); - - // Calcalate total lighting for this fragment - float3 total_light_contrib; - total_light_contrib = accum.light_diffuse+alpha*accum.light_specular; - return float4( total_light_contrib*colour ,0); - //return float4(accum.light_diffuse,0); - //return float4(global.position/1000.0,0); -} - +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Multipass, one light +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +// Attributes of light 0 +float4 lightPos0; +float4 lightDiffuseColor0; +float4 lightSpecularColor0; + +// Global parameters for lights +struct LightGlobal +{ + float3 position; + float3 normal; + float3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + float3 light_diffuse; + float3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + float4 lightPos, + float4 lightDiffuseColor, + float4 lightSpecularColor) +{ + float3 lightVec = lightPos - global.position; + float3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0,dot(lightDir, global.normal)) * lightDiffuseColor; + + float3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32) * lightSpecularColor; +} + +float4 main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) : COLOR +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + LightGlobal global; + + // Clip fragment if depth is too close, so the skybox can be rendered on the background + //clip(a1.w-0.001); + + // Attributes + float3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer + //global.normal = normalize(a1.xyz); + global.normal = a1.xyz; + + // Acquire view space position via inverse projection transformation + //global.position = mul(invProj, float4(projCoord, 0, 1))*distance; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = float3(0,0,0); + accum.light_specular = float3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + + // Calcalate total lighting for this fragment + float3 total_light_contrib; + total_light_contrib = accum.light_diffuse+alpha*accum.light_specular; + return float4( total_light_contrib*colour ,0); + //return float4(accum.light_diffuse,0); + //return float4(global.position/1000.0,0); +} + Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl 2008-09-01 14:19:39 UTC (rev 716) @@ -1,132 +1,132 @@ -/****************************************************************************** -Copyright (c) W.J. van der Laan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -Software, and to permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ -/** Deferred shading framework - // W.J. :wumpus: van der Laan 2005 // - - Post shader: Single pass -*/ -sampler Tex0: register(s0); -sampler Tex1: register(s1); - -float4x4 proj; - -float4 ambientColor; -// Attributes of light 0 -float4 lightPos0; -float4 lightDiffuseColor0; -float4 lightSpecularColor0; -// Attributes of light 1 -float4 lightPos1; -float4 lightDiffuseColor1; -float4 lightSpecularColor1; - -// Global parameters for lights -struct LightGlobal -{ - float3 position; - float3 normal; - float3 viewDir; -}; - -// Current state of light -struct LightAccum -{ - float3 light_diffuse; - float3 light_specular; -}; - -// Do lighting calculations for one light -void processLight( - inout LightAccum accum, - LightGlobal global, - float4 lightPos, - float4 lightDiffuseColor, - float4 lightSpecularColor) -{ - float3 lightVec = lightPos - global.position; - float3 lightDir = normalize(lightVec); - accum.light_diffuse += max(0,dot(lightDir, global.normal)) * lightDiffuseColor; - - float3 h = normalize(global.viewDir + lightDir); - accum.light_specular += pow(dot(global.normal, h),32) * lightSpecularColor; -} - -struct POUTPUT -{ - float4 colour: COLOR; - float depth: DEPTH; -}; - -POUTPUT main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) -{ - POUTPUT o; - - float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess - float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth - - LightGlobal global; - - // Clip fragment if depth is too far, so the skybox can be rendered on the background - clip(a1.w-0.001); - - // Attributes - float3 colour = a0.rgb; - float alpha = a0.a; // Specularity - float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted - //global.normal = normalize(a1.xyz); // normalizing done already - global.normal = a1.xyz; - - // Acquire view space position via inverse projection transformation - //global.position = mul(invProj, float4(projCoord, 0, 1))*distance; - // Acquire view space position via inverse projection transformation - //float4 tpos; - //tpos = float4(projCoord, distance, 1.0); - //tpos = mul(invProj, tpos); - //tpos = tpos / tpos.w; - //global.position = tpos; - //global.position = float3( - // invProj[0][0], // X vector component from X - // invProj[1][1], // Y vector component from Y - // invProj[2][3] // Z vector component from W - //)*projCoord*distance; - global.position = projCoord*distance; - - // Apply light - LightAccum accum; - accum.light_diffuse = float3(0,0,0); - accum.light_specular = float3(0,0,0); - global.viewDir = -normalize(global.position); - - processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); - processLight(accum, global, lightPos1, lightDiffuseColor1, lightSpecularColor1); - - // Calcalate total lighting for this fragment - float3 total_light_contrib; - total_light_contrib = ambientColor+accum.light_diffuse+alpha*accum.light_specular; - - o.colour = float4( total_light_contrib*colour ,0); - // Depth buffer value - // Transfering depth makes it possible to render particle effects and other transparent - // things unaffected by light in the postprocessing phase. - o.depth = projCoord.z*proj[2][2] + proj[2][3]/distance; - return o; -} - +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Single pass +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +float4x4 proj; + +float4 ambientColor; +// Attributes of light 0 +float4 lightPos0; +float4 lightDiffuseColor0; +float4 lightSpecularColor0; +// Attributes of light 1 +float4 lightPos1; +float4 lightDiffuseColor1; +float4 lightSpecularColor1; + +// Global parameters for lights +struct LightGlobal +{ + float3 position; + float3 normal; + float3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + float3 light_diffuse; + float3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + float4 lightPos, + float4 lightDiffuseColor, + float4 lightSpecularColor) +{ + float3 lightVec = lightPos - global.position; + float3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0,dot(lightDir, global.normal)) * lightDiffuseColor; + + float3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32) * lightSpecularColor; +} + +struct POUTPUT +{ + float4 colour: COLOR; + float depth: DEPTH; +}; + +POUTPUT main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) +{ + POUTPUT o; + + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + LightGlobal global; + + // Clip fragment if depth is too far, so the skybox can be rendered on the background + clip(a1.w-0.001); + + // Attributes + float3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + //global.normal = normalize(a1.xyz); // normalizing done already + global.normal = a1.xyz; + + // Acquire view space position via inverse projection transformation + //global.position = mul(invProj, float4(projCoord, 0, 1))*distance; + // Acquire view space position via inverse projection transformation + //float4 tpos; + //tpos = float4(projCoord, distance, 1.0); + //tpos = mul(invProj, tpos); + //tpos = tpos / tpos.w; + //global.position = tpos; + //global.position = float3( + // invProj[0][0], // X vector component from X + // invProj[1][1], // Y vector component from Y + // invProj[2][3] // Z vector component from W + //)*projCoord*distance; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = float3(0,0,0); + accum.light_specular = float3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + processLight(accum, global, lightPos1, lightDiffuseColor1, lightSpecularColor1); + + // Calcalate total lighting for this fragment + float3 total_light_contrib; + total_light_contrib = ambientColor+accum.light_diffuse+alpha*accum.light_specular; + + o.colour = float4( total_light_contrib*colour ,0); + // Depth buffer value + // Transfering depth makes it possible to render particle effects and other transparent + // things unaffected by light in the postprocessing phase. + o.depth = projCoord.z*proj[2][2] + proj[2][3]/distance; + return o; +} + Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.glsl.program =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.glsl.program 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.glsl.program 2008-09-01 14:19:39 UTC (rev 716) @@ -1,50 +1,50 @@ -// Materials for rendering to the fat buffer - -// Plain phong -vertex_program DeferredShading/material/glsl/vs glsl -{ - source DeferredShading/material/glsl/vs.glsl -} -fragment_program DeferredShading/material/glsl/ps glsl -{ - source DeferredShading/material/glsl/ps.glsl - default_params - { - param_named specularity float 0.0 - } -} -fragment_program DeferredShading/material/glsl/notex_ps glsl -{ - source DeferredShading/material/glsl/notex_ps.glsl - default_params - { - param_named specularity float 0.0 - param_named colour float3 0.7 0.7 0.7 - } -} - -// Normal mapping -vertex_program DeferredShading/material/glsl/nm_vs glsl -{ - source DeferredShading/material/glsl/nm_vs.glsl -} -fragment_program DeferredShading/material/glsl/nm_ps glsl -{ - source DeferredShading/material/glsl/nm_ps.glsl - default_params - { - param_named specularity float 0.0 - param_named tex0 int 0 - param_named normTex int 1 - } -} -fragment_program DeferredShading/material/glsl/nm_notex_ps glsl -{ - source DeferredShading/material/glsl/nm_notex_ps.glsl - default_params - { - param_named colour float3 0.7 0.7 0.7 - param_named specularity float 0.0 - param_named normTex int 0 - } -} +// Materials for rendering to the fat buffer + +// Plain phong +vertex_program DeferredShading/material/glsl/vs glsl +{ + source DeferredShading/material/glsl/vs.glsl +} +fragment_program DeferredShading/material/glsl/ps glsl +{ + source DeferredShading/material/glsl/ps.glsl + default_params + { + param_named specularity float 0.0 + } +} +fragment_program DeferredShading/material/glsl/notex_ps glsl +{ + source DeferredShading/material/glsl/notex_ps.glsl + default_params + { + param_named specularity float 0.0 + param_named colour float3 0.7 0.7 0.7 + } +} + +// Normal mapping +vertex_program DeferredShading/material/glsl/nm_vs glsl +{ + source DeferredShading/material/glsl/nm_vs.glsl +} +fragment_program DeferredShading/material/glsl/nm_ps glsl +{ + source DeferredShading/material/glsl/nm_ps.glsl + default_params + { + param_named specularity float 0.0 + param_named tex0 int 0 + param_named normTex int 1 + } +} +fragment_program DeferredShading/material/glsl/nm_notex_ps glsl +{ + source DeferredShading/material/glsl/nm_notex_ps.glsl + default_params + { + param_named colour float3 0.7 0.7 0.7 + param_named specularity float 0.0 + param_named normTex int 0 + } +} Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.hlsl.program =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.hlsl.program 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.hlsl.program 2008-09-01 14:19:39 UTC (rev 716) @@ -1,70 +1,70 @@ -// Materials for rendering to the fat buffer - -// Plain phong -vertex_program DeferredShading/material/hlsl/vs hlsl -{ - source DeferredShading/material/hlsl/vs.hlsl - target vs_1_1 - entry_point main - - default_params - { - param_named_auto worldView worldview_matrix - param_named_auto worldViewProj worldviewproj_matrix - } -} -fragment_program DeferredShading/material/hlsl/ps hlsl -{ - source DeferredShading/material/hlsl/ps.hlsl - target ps_2_0 - entry_point main - default_params - { - param_named specularity float 0.0 - } -} -fragment_program DeferredShading/material/hlsl/notex_ps hlsl -{ - source DeferredShading/material/hlsl/notex_ps.hlsl - target ps_2_0 - entry_point main - default_params - { - param_named specularity float 0.0 - } -} - -// Normal mapping -vertex_program DeferredShading/material/hlsl/nm_vs hlsl -{ - source DeferredShading/material/hlsl/nm_vs.hlsl - target vs_1_1 - entry_point main - - default_params - { - param_named_auto worldView worldview_matrix - param_named_auto worldViewProj worldviewproj_matrix - } -} -fragment_program DeferredShading/material/hlsl/nm_ps hlsl -{ - source DeferredShading/material/hlsl/nm_ps.hlsl - target ps_2_0 - entry_point main - default_params - { - param_named specularity float 0.0 - } -} -fragment_program DeferredShading/material/hlsl/nm_notex_ps hlsl -{ - source DeferredShading/material/hlsl/nm_notex_ps.hlsl - target ps_2_0 - entry_point main - default_params - { - param_named colour float3 0.7 0.7 0.7 - param_named specularity float 0.0 - } -} +// Materials for rendering to the fat buffer + +// Plain phong +vertex_program DeferredShading/material/hlsl/vs hlsl +{ + source DeferredShading/material/hlsl/vs.hlsl + target vs_1_1 + entry_point main + + default_params + { + param_named_auto worldView worldview_matrix + param_named_auto worldViewProj worldviewproj_matrix + } +} +fragment_program DeferredShading/material/hlsl/ps hlsl +{ + source DeferredShading/material/hlsl/ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named specularity float 0.0 + } +} +fragment_program DeferredShading/material/hlsl/notex_ps hlsl +{ + source DeferredShading/material/hlsl/notex_ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named specularity float 0.0 + } +} + +// Normal mapping +vertex_program DeferredShading/material/hlsl/nm_vs hlsl +{ + source DeferredShading/material/hlsl/nm_vs.hlsl + target vs_1_1 + entry_point main + + default_params + { + param_named_auto worldView worldview_matrix + param_named_auto worldViewProj worldviewproj_matrix + } +} +fragment_program DeferredShading/material/hlsl/nm_ps hlsl +{ + source DeferredShading/material/hlsl/nm_ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named specularity float 0.0 + } +} +fragment_program DeferredShading/material/hlsl/nm_notex_ps hlsl +{ + source DeferredShading/material/hlsl/nm_notex_ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named colour float3 0.7 0.7 0.7 + param_named specularity float 0.0 + } +} Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.glsl.program =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.glsl.program 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.glsl.program 2008-09-01 14:19:39 UTC (rev 716) @@ -1,27 +1,27 @@ -fragment_program DeferredShading/post/glsl/ShowNormal_ps glsl -{ - source DeferredShading/post/glsl/ShowNormal_ps.glsl - default_params - { - param_named tex0 int 0 - param_named tex1 int 1 - } -} -fragment_program DeferredShading/post/glsl/ShowDS_ps glsl -{ - source DeferredShading/post/glsl/ShowDS_ps.glsl - default_params - { - param_named tex0 int 0 - param_named tex1 int 1 - } -} -fragment_program DeferredShading/post/glsl/ShowColour_ps glsl -{ - source DeferredShading/post/glsl/ShowColour_ps.glsl - default_params - { - param_named tex0 int 0 - param_named tex1 int 1 - } -} +fragment_program DeferredShading/post/glsl/ShowNormal_ps glsl +{ + source DeferredShading/post/glsl/ShowNormal_ps.glsl + default_params + { + param_named tex0 int 0 + param_named tex1 int 1 + } +} +fragment_program DeferredShading/post/glsl/ShowDS_ps glsl +{ + source DeferredShading/post/glsl/ShowDS_ps.glsl + default_params + { + param_named tex0 int 0 + param_named tex1 int 1 + } +} +fragment_program DeferredShading/post/glsl/ShowColour_ps glsl +{ + source DeferredShading/post/glsl/ShowColour_ps.glsl + default_params + { + param_named tex0 int 0 + param_named tex1 int 1 + } +} Modified: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.hlsl.program =================================================================== --- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.hlsl.program 2008-09-01 11:45:49 UTC (rev 715) +++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.hlsl.program 2008-09-01 14:19:39 UTC (rev 716) @@ -1,18 +1,18 @@ -fragment_program DeferredShading/post/hlsl/ShowNormal_ps hlsl -{ - source DeferredShading/post/hlsl/ShowNormal_ps.hlsl - target ps_2_0 - entry_point main -} -fragment_program DeferredShading/post/hlsl/ShowDS_ps hlsl -{ - source DeferredShading/post/hlsl/ShowDS_ps.hlsl - target ps_2_0 - entry_point main -} -fragment_program DeferredShading/post/hlsl/ShowColour_ps hlsl -{ - source DeferredShading/post/hlsl/ShowColour_ps.hlsl - target ps_2_0 - entry_point main -} +fragment_program DeferredShading/post/hlsl/ShowNormal_ps hlsl +{ + source DeferredShading/post/hlsl/ShowNormal_ps.hlsl + target ps_2_0 + entry_point main +} +fragment_program DeferredShading/post/hlsl/ShowDS_ps hlsl +{ + source DeferredShading/post/hlsl/ShowDS_ps.hlsl + target ps_2_0 + entry_point main +} +fragment_program DeferredShading/post/hlsl/ShowColour_ps hlsl +{ + source DeferredShading/post/hlsl/ShowColour_ps.hlsl + target ps_2_0 + entry_point main +} Modified: trunk/pytho... [truncated message content] |