Revision: 736
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=736&view=rev
Author: andy_miller
Date: 2008-09-07 11:39:21 +0000 (Sun, 07 Sep 2008)
Log Message:
-----------
Updates for 1.6rc1 release
Modified Paths:
--------------
trunk/python-ogre/demos/OgreNewt/CEGUI_framework.py
trunk/python-ogre/demos/ogreal/Demo_AL_01.py
Added Paths:
-----------
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.compositor
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.program
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.material
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.program
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.program
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_minilight.program
trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_vs.program
trunk/python-ogre/demos/media/materials/programs/ASCIIFP.cg
trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.glsl
trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.hlsl
trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.glsl
trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.hlsl
trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.glsl
trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.hlsl
trunk/python-ogre/demos/media/materials/programs/Blur_vs.glsl
trunk/python-ogre/demos/media/materials/programs/Blur_vs11.hlsl
trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.glsl
trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.hlsl
trunk/python-ogre/demos/media/materials/programs/Common.cg
trunk/python-ogre/demos/media/materials/programs/DitherFP.cg
trunk/python-ogre/demos/media/materials/programs/HalftoneFP.cg
trunk/python-ogre/demos/media/materials/programs/NightVisionFP.cg
trunk/python-ogre/demos/media/materials/programs/ParticleGS.cg
trunk/python-ogre/demos/media/materials/programs/PassthroughVP.glsl
trunk/python-ogre/demos/media/materials/programs/Radial_Blur_FP.cg
trunk/python-ogre/demos/media/materials/programs/Swizzle.gp
trunk/python-ogre/demos/media/materials/programs/SwizzleGP.cg
trunk/python-ogre/demos/media/materials/programs/SwizzleGP.glsl
trunk/python-ogre/demos/media/materials/programs/hdrutils.hlsl
trunk/python-ogre/demos/media/materials/programs/isosurf.cg
trunk/python-ogre/demos/media/materials/programs/mrttestfp.hlsl
trunk/python-ogre/demos/media/materials/programs/mrttestfp_quad.glsl
trunk/python-ogre/demos/media/materials/programs/mrttestfp_scene.glsl
trunk/python-ogre/demos/media/materials/programs/pssm.cg
trunk/python-ogre/demos/media/materials/scripts/ASCII.material
trunk/python-ogre/demos/media/materials/scripts/ASMSwizzle.material
trunk/python-ogre/demos/media/materials/scripts/Bloom2.material
trunk/python-ogre/demos/media/materials/scripts/CGSwizzle.material
trunk/python-ogre/demos/media/materials/scripts/Dither.material
trunk/python-ogre/demos/media/materials/scripts/GLSLSwizzle.material
trunk/python-ogre/demos/media/materials/scripts/Halftone.material
trunk/python-ogre/demos/media/materials/scripts/IsoSurf.material
trunk/python-ogre/demos/media/materials/scripts/MRTtest.material
trunk/python-ogre/demos/media/materials/scripts/NightVision.material
trunk/python-ogre/demos/media/materials/scripts/ParticleGS.material
trunk/python-ogre/demos/media/materials/scripts/RadialBlur.material
trunk/python-ogre/demos/media/materials/scripts/pssm.material
trunk/python-ogre/demos/media/materials/textures/ASCII.dds
trunk/python-ogre/demos/media/materials/textures/grassWalpha.tga
trunk/python-ogre/demos/media/materials/textures/leaf.png
trunk/python-ogre/demos/media/materials/textures/particle.dds
trunk/python-ogre/demos/ogreal/Demo_AL_02.py
trunk/python-ogre/demos/ogreal/OpenAL32.dll
trunk/python-ogre/demos/ogreal/wrap_oal.dll
Modified: trunk/python-ogre/demos/OgreNewt/CEGUI_framework.py
===================================================================
--- trunk/python-ogre/demos/OgreNewt/CEGUI_framework.py 2008-09-07 06:24:31 UTC (rev 735)
+++ trunk/python-ogre/demos/OgreNewt/CEGUI_framework.py 2008-09-07 11:39:21 UTC (rev 736)
@@ -1,84 +1,100 @@
-import ogre.gui.CEGUI as CEGUI
-import ogre.io.OIS as OIS
-import ogre.renderer.OGRE as Ogre
-import SampleFramework
-
-##----------------------------------------------------------------##
-def convertOISMouseButtonToCegui( buttonID):
- if buttonID ==0:
- return CEGUI.LeftButton
- elif buttonID ==1:
- return CEGUI.RightButton
- elif buttonID ==2:
- return CEGUI.MiddleButton
- elif buttonID ==3:
- return CEGUI.X1Button
- else:
- return CEGUI.LeftButton
-
-def _PointHack(x, y):
- return CEGUI.Vector2(x, y)
-CEGUI.Point = _PointHack
-
-def cegui_reldim ( x ) :
- return CEGUI.UDim((x),0)
-
-class MouseListener ( OIS.MouseListener ):
- def __init__(self):
- OIS.MouseListener.__init__( self)
-
- ##----------------------------------------------------------------##
- def mouseMoved( self, arg ):
- CEGUI.System.getSingleton().injectMouseMove( arg.get_state().X.rel, arg.get_state().Y.rel )
- return True
-
- ##----------------------------------------------------------------##
- def mousePressed( self, arg, id ):
- CEGUI.System.getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id))
- return True
-
- ##----------------------------------------------------------------##
- def mouseReleased( self, arg, id ):
- CEGUI.System.getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id))
- return True
-
-
-class GuiFrameListener(SampleFramework.FrameListener, OIS.KeyListener, OIS.MouseListener):
-
- def __init__(self, renderWindow, camera, CEGUIRenderer):
-
- SampleFramework.FrameListener.__init__(self, renderWindow, camera, True, True, True)
- OIS.KeyListener.__init__(self)
- self.mouselistener = MouseListener ()
- #OIS.MouseListener.__init_(self)
-
- self.Mouse.setEventCallback(self.mouselistener)
- self.Keyboard.setEventCallback(self)
-
- self.ShutdownRequested = False
- self.GUIRenderer = CEGUIRenderer
- self.keepRendering = True # whether to continue rendering or not
- self.numScreenShots = 0 # screen shot count
-
- ## Tell the frame listener to exit at the end of the next frame
- def requestShutdown( self ):
- self.ShutdownRequested = True
-
- def frameEnded(self, evt):
- if self.ShutdownRequested:
- return False
- else:
- return SampleFramework.FrameListener.frameEnded(self, evt)
-
- ##----------------------------------------------------------------##
- def keyPressed( self, arg ):
- if arg.key == OIS.KC_ESCAPE:
- self.ShutdownRequested = True
- CEGUI.System.getSingleton().injectKeyDown( arg.key )
- CEGUI.System.getSingleton().injectChar( arg.text )
- return True
-
- ##----------------------------------------------------------------##
- def keyReleased( self, arg ):
- CEGUI.System.getSingleton().injectKeyUp( arg.key )
- return True
+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
+# the _cegui_.so module without RTLD_GLOBAL set - then when CEGUI opened it's dynamic modules it
+# couldn't find all the symbols.
+
+#print ctypes.CDLL("../../../root/usr/lib/libCEGUIBase.so", ctypes.RTLD_GLOBAL )
+
+import ogre.gui.CEGUI as CEGUI
+
+# Another fix for CEGUI to ensure we get a working parser..
+if os.name == 'nt':
+ CEGUI.System.setDefaultXMLParserName("ExpatParser")
+else:
+ CEGUI.System.setDefaultXMLParserName("TinyXMLParser")
+
+import ogre.io.OIS as OIS
+import SampleFramework
+
+##----------------------------------------------------------------##
+def convertOISMouseButtonToCegui( buttonID):
+ if buttonID ==0:
+ return CEGUI.LeftButton
+ elif buttonID ==1:
+ return CEGUI.RightButton
+ elif buttonID ==2:
+ return CEGUI.MiddleButton
+ elif buttonID ==3:
+ return CEGUI.X1Button
+ else:
+ return CEGUI.LeftButton
+
+def _PointHack(x, y):
+ return CEGUI.Vector2(x, y)
+CEGUI.Point = _PointHack
+
+def cegui_reldim ( x ) :
+ return CEGUI.UDim((x),0)
+
+class MouseListener ( OIS.MouseListener ):
+ def __init__(self):
+ OIS.MouseListener.__init__( self)
+
+ ##----------------------------------------------------------------##
+ def mouseMoved( self, arg ):
+ CEGUI.System.getSingleton().injectMouseMove( arg.get_state().X.rel, arg.get_state().Y.rel )
+ return True
+
+ ##----------------------------------------------------------------##
+ def mousePressed( self, arg, id ):
+ CEGUI.System.getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id))
+ return True
+
+ ##----------------------------------------------------------------##
+ def mouseReleased( self, arg, id ):
+ CEGUI.System.getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id))
+ return True
+
+
+class GuiFrameListener(SampleFramework.FrameListener , OIS.KeyListener, OIS.MouseListener):
+
+ def __init__(self, renderWindow, camera, CEGUIRenderer):
+
+ SampleFramework.FrameListener.__init__(self, renderWindow, camera, True, True, True)
+ OIS.KeyListener.__init__(self)
+ self.mouselistener = MouseListener ()
+ #OIS.MouseListener.__init_(self)
+
+ self.Mouse.setEventCallback(self.mouselistener)
+ self.Keyboard.setEventCallback(self)
+
+ self.ShutdownRequested = False
+ self.GUIRenderer = CEGUIRenderer
+ self.keepRendering = True # whether to continue rendering or not
+ self.numScreenShots = 0 # screen shot count
+
+ ## Tell the frame listener to exit at the end of the next frame
+ def requestShutdown( self ):
+ self.ShutdownRequested = True
+
+ def frameEnded(self, evt):
+ if self.ShutdownRequested:
+ return False
+ else:
+ return SampleFramework.FrameListener.frameEnded(self, evt)
+
+ ##----------------------------------------------------------------##
+ def keyPressed( self, arg ):
+ if arg.key == OIS.KC_ESCAPE:
+ self.ShutdownRequested = True
+ CEGUI.System.getSingleton().injectKeyDown( arg.key )
+ CEGUI.System.getSingleton().injectChar( arg.text )
+ return True
+
+ ##----------------------------------------------------------------##
+ def keyReleased( self, arg ):
+ CEGUI.System.getSingleton().injectKeyUp( arg.key )
+ return True
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.compositor
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.compositor (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.compositor 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,153 @@
+// Postfilter doing full deferred shading
+
+compositor DeferredShading/ShowLit
+{
+ technique
+ {
+ // temporary textures
+ texture mrt_output target_width target_height PF_FLOAT16_RGBA PF_FLOAT16_RGBA
+
+ target mrt_output
+ {
+ input none
+ pass clear
+ {
+ }
+
+ // everything but the lights and their meshes
+ // could do this with something like a visibility mask too
+ pass render_scene
+ {
+ first_render_queue 22
+ last_render_queue 90
+ }
+ }
+
+ target_output
+ {
+ input none
+
+ // render skies
+ pass render_scene
+ {
+ first_render_queue 5
+ last_render_queue 5
+ }
+
+ // just the lights and their meshes
+ pass render_scene
+ {
+ first_render_queue 20
+ last_render_queue 21
+ }
+ }
+ }
+}
+
+// Postfilter that shows the colour channel
+compositor DeferredShading/ShowColour
+{
+ technique
+ {
+ // temporary textures
+ texture mrt_output target_width target_height PF_FLOAT16_RGBA PF_FLOAT16_RGBA
+
+ target mrt_output
+ {
+ input none
+ pass clear
+ {
+ }
+
+ pass render_scene
+ {
+ first_render_queue 22
+ last_render_queue 90
+ }
+ }
+
+ target_output
+ {
+ input none
+
+ pass render_quad
+ {
+ material DeferredShading/Post/ShowColour
+ input 0 mrt_output 0
+ input 1 mrt_output 1
+ }
+ }
+ }
+}
+
+// Postfilter that shows the normal channel
+compositor DeferredShading/ShowNormals
+{
+ technique
+ {
+ // temporary textures
+ texture mrt_output target_width target_height PF_FLOAT16_RGBA PF_FLOAT16_RGBA
+
+ target mrt_output
+ {
+ input none
+ pass clear
+ {
+ }
+
+ pass render_scene
+ {
+ first_render_queue 22
+ last_render_queue 90
+ }
+ }
+
+ target_output
+ {
+ input none
+
+ pass render_quad
+ {
+ material DeferredShading/Post/ShowNormal
+ input 0 mrt_output 0
+ input 1 mrt_output 1
+ }
+ }
+ }
+}
+
+// Postfilter that shows the depth and specular channel
+compositor DeferredShading/ShowDepthSpecular
+{
+ technique
+ {
+ // temporary textures
+ texture mrt_output target_width target_height PF_FLOAT16_RGBA PF_FLOAT16_RGBA
+
+ target mrt_output
+ {
+ input none
+ pass clear
+ {
+ }
+
+ pass render_scene
+ {
+ first_render_queue 22
+ last_render_queue 90
+ }
+ }
+
+ target_output
+ {
+ input none
+
+ pass render_quad
+ {
+ material DeferredShading/Post/ShowDS
+ input 0 mrt_output 0
+ input 1 mrt_output 1
+ }
+ }
+ }
+}
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.program
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.program (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred.program 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,157 @@
+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
+ }
+}
+
+vertex_program DeferredShading/material/glsl/vs glsl
+{
+ source DeferredShading/material/glsl/vs.glsl
+}
+
+vertex_program DeferredShading/material/vs unified
+{
+ delegate DeferredShading/material/hlsl/vs
+ delegate DeferredShading/material/glsl/vs
+}
+
+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/glsl/ps glsl
+{
+ source DeferredShading/material/glsl/ps.glsl
+ default_params
+ {
+ param_named specularity float 0.0
+ }
+}
+
+fragment_program DeferredShading/material/ps unified
+{
+ delegate DeferredShading/material/hlsl/ps
+ delegate DeferredShading/material/glsl/ps
+}
+
+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
+ }
+}
+
+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
+ }
+}
+
+fragment_program DeferredShading/material/notex_ps unified
+{
+ delegate DeferredShading/material/hlsl/notex_ps
+ delegate DeferredShading/material/glsl/notex_ps
+}
+
+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
+ }
+}
+
+vertex_program DeferredShading/material/glsl/nm_vs glsl
+{
+ source DeferredShading/material/glsl/nm_vs.glsl
+}
+
+vertex_program DeferredShading/material/nm_vs unified
+{
+ delegate DeferredShading/material/hlsl/nm_vs
+ delegate DeferredShading/material/glsl/nm_vs
+}
+
+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/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/nm_ps unified
+{
+ delegate DeferredShading/material/hlsl/nm_ps
+ delegate DeferredShading/material/glsl/nm_ps
+}
+
+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
+ }
+}
+
+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
+ }
+}
+
+fragment_program DeferredShading/material/nm_notex_ps unified
+{
+ delegate DeferredShading/material/hlsl/nm_notex_ps
+ delegate DeferredShading/material/glsl/nm_notex_ps
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.material
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.material (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.material 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,34 @@
+material DeferredShading/AmbientLight
+{
+ technique
+ {
+ pass
+ {
+ lighting off
+
+ depth_write on
+ depth_check on
+
+ vertex_program_ref DeferredShading/post/vs
+ {
+
+ }
+ fragment_program_ref DeferredShading/post/Ambient_ps
+ {
+
+ }
+
+ texture_unit
+ {
+ tex_address_mode clamp
+ filtering none
+ }
+ texture_unit
+ {
+ tex_address_mode clamp
+ filtering none
+ }
+ }
+
+ }
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.program
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.program (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_ambient.program 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,36 @@
+
+// HLSL
+fragment_program DeferredShading/post/hlsl/Ambient_ps hlsl
+{
+ source DeferredShading/post/hlsl/Ambient_ps.hlsl
+ target ps_2_0
+ entry_point main
+
+ default_params
+ {
+ param_named_auto ambientColor ambient_light_colour 0
+ param_named_auto proj projection_matrix
+ }
+}
+
+
+// GLSL
+fragment_program DeferredShading/post/glsl/Ambient_ps glsl
+{
+ source DeferredShading/post/glsl/Ambient_ps.glsl
+
+ default_params
+ {
+ param_named_auto ambientColor ambient_light_colour 0
+ param_named_auto proj projection_matrix
+ param_named tex0 int 0
+ param_named tex1 int 1
+ }
+}
+
+// Unified
+fragment_program DeferredShading/post/Ambient_ps unified
+{
+ delegate DeferredShading/post/hlsl/Ambient_ps
+ delegate DeferredShading/post/glsl/Ambient_ps
+}
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.program
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.program (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_debug.program 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,65 @@
+// HLSL
+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
+}
+
+// GLSL
+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
+ }
+}
+
+// Unified
+fragment_program DeferredShading/post/ShowNormal_ps unified
+{
+ delegate DeferredShading/post/hlsl/ShowNormal_ps
+ delegate DeferredShading/post/glsl/ShowNormal_ps
+}
+fragment_program DeferredShading/post/ShowDS_ps unified
+{
+ delegate DeferredShading/post/hlsl/ShowDS_ps
+ delegate DeferredShading/post/glsl/ShowDS_ps
+}
+fragment_program DeferredShading/post/ShowColour_ps unified
+{
+ delegate DeferredShading/post/hlsl/ShowColour_ps
+ delegate DeferredShading/post/glsl/ShowColour_ps
+}
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_minilight.program
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_minilight.program (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_minilight.program 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,86 @@
+// Auxilary lights
+
+// N.B This is not used directly, since the mini light programs are set up in code.
+
+// HLSL
+vertex_program DeferredShading/post/hlsl/LightMaterial_vs hlsl
+{
+ source DeferredShading/post/hlsl/LightMaterial_vs.hlsl
+ target vs_1_1
+ entry_point main
+ default_params
+ {
+ param_named_auto worldViewProj worldviewproj_matrix
+ param_named_auto invProj inverse_projection_matrix
+ param_named_auto vpWidth viewport_width
+ param_named_auto vpHeight viewport_height
+ }
+}
+
+fragment_program DeferredShading/post/hlsl/LightMaterial_ps hlsl
+{
+ source DeferredShading/post/hlsl/LightMaterial_ps.hlsl
+ target ps_2_0
+ entry_point main
+ preprocessor_defines IS_ATTENUATED=1;IS_SPECULAR=1
+
+ default_params
+ {
+ param_named_auto worldView worldview_matrix
+
+ param_named lightDiffuseColor float4 0.0 0.0 0.0 0.0
+ param_named lightSpecularColor float4 0.0 0.0 0.0 0.0
+ param_named lightFalloff float4 0.0 0.0 0.0 0.0
+
+
+ //param_named_auto lightDiffuseColor custom 1
+ //param_named_auto lightSpecularColor custom 2
+ //param_named_auto lightFalloff custom 3
+ }
+}
+
+// GLSL
+vertex_program DeferredShading/post/glsl/LightMaterial_vs glsl
+{
+ source DeferredShading/post/glsl/LightMaterial_vs.glsl
+ default_params
+ {
+ param_named_auto invProj inverse_projection_matrix
+ param_named_auto vpWidth viewport_width
+ param_named_auto vpHeight viewport_height
+ }
+}
+fragment_program DeferredShading/post/glsl/LightMaterial_ps glsl
+{
+ source DeferredShading/post/glsl/LightMaterial_ps.glsl
+ preprocessor_defines IS_ATTENUATED=1,IS_SPECULAR=1
+ default_params
+ {
+ param_named_auto worldView worldview_matrix
+
+ param_named lightDiffuseColor float3 0.0 0.0 0.0 0.0
+ param_named lightSpecularColor float3 0.0 0.0 0.0 0.0
+ param_named lightFalloff float3 0.0 0.0 0.0 0.0
+
+
+ //param_named_auto lightDiffuseColor custom 1
+ //param_named_auto lightSpecularColor custom 2
+ //param_named_auto lightFalloff custom 3
+
+ param_named tex0 int 0
+ param_named tex1 int 1
+ }
+}
+
+// Unified
+vertex_program DeferredShading/post/LightMaterial_vs unified
+{
+ delegate DeferredShading/post/hlsl/LightMaterial_vs
+ delegate DeferredShading/post/glsl/LightMaterial_vs
+}
+
+fragment_program DeferredShading/post/LightMaterial_ps unified
+{
+ delegate DeferredShading/post/hlsl/LightMaterial_ps
+ delegate DeferredShading/post/glsl/LightMaterial_ps
+}
Added: trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_vs.program
===================================================================
--- trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_vs.program (rev 0)
+++ trunk/python-ogre/demos/media/DeferredShadingMedia/deferred_post_vs.program 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,28 @@
+// HLSL
+vertex_program DeferredShading/post/hlsl/vs hlsl
+{
+ source DeferredShading/post/hlsl/vs.hlsl
+ target vs_1_1
+ entry_point main
+ default_params
+ {
+ param_named_auto invProj inverse_projection_matrix
+ }
+}
+
+// GLSL
+vertex_program DeferredShading/post/glsl/vs glsl
+{
+ source DeferredShading/post/glsl/vs.glsl
+ default_params
+ {
+ param_named_auto invProj inverse_projection_matrix
+ }
+}
+
+// Unified
+vertex_program DeferredShading/post/vs unified
+{
+ delegate DeferredShading/post/hlsl/vs
+ delegate DeferredShading/post/glsl/vs
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/ASCIIFP.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/ASCIIFP.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/ASCIIFP.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,31 @@
+sampler RT : register(s0);
+sampler pattern : register(s1);
+
+float4 ASCII_ps( float2 TexCoord : TEXCOORD0,
+ uniform float2 numTiles,
+ uniform float2 iNumTiles,
+ uniform float2 iNumTiles2,
+ uniform float4 lum,
+ uniform float charBias) : COLOR
+{
+ float3 local;
+
+ //sample RT
+ local.xy = fmod(TexCoord, iNumTiles);
+ float2 middle = TexCoord - local.xy;
+ local.xy = local.xy * numTiles;
+
+ //iNumTiles2 = iNumTiles / 2
+ middle = middle + iNumTiles2;
+ float4 c = tex2D(RT, middle );
+
+ //multiply luminance by charbias , beacause not all slices of the ascii
+ //volume texture are used
+ local.z = dot(c , lum)*charBias;
+
+ //fix to brighten the dark pixels with small characters
+ //c *= lerp(2.0,1.0, local.z);
+
+ c *= tex3D(pattern,local);
+ return c;
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,27 @@
+//-------------------------------
+//Bloom_ps20.glsl
+// Blends using weights the blurred image with the sharp one
+// Params:
+// OriginalImageWeight
+// BlurWeight
+//-------------------------------
+
+uniform sampler2D RT;
+uniform sampler2D Blur1;
+
+uniform float OriginalImageWeight;
+uniform float BlurWeight;
+
+void main()
+{
+ vec4 sharp;
+ vec4 blur;
+
+ vec2 texCoord = vec2( gl_TexCoord[0] );
+
+ sharp = texture2D( RT, texCoord);
+ blur = texture2D( Blur1, texCoord);
+
+ gl_FragColor = ( (blur * BlurWeight) + (sharp * OriginalImageWeight) );
+ //gl_FragColor = vec4(0);
+}
Added: trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.hlsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.hlsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Bloom2_ps20.hlsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,58 @@
+//---------------------------------------------
+// Bloom
+
+
+float4 main(float2 texCoord: TEXCOORD0,
+ uniform sampler RT: register(s0),
+ uniform sampler Blur1: register(s1),
+ uniform float OriginalImageWeight,
+ uniform float BlurWeight
+ ) : COLOR {
+
+
+ float4 sharp = tex2D(RT, texCoord);
+ float4 blur = tex2D(Blur1, texCoord);
+
+ //return blur*0.5+sharp*0.5;
+ return blur*BlurWeight+sharp*OriginalImageWeight;
+ //return blur;
+
+ //return ( sharp + blur * 1.8 ) / 2;
+
+// return (sharp*3/6 + (blur*4/6))*float4(1.5, 1.5, 1.5, 1);;
+
+// float4 color = lerp( sharp, blur, 0.4f );
+
+// return color;
+
+
+/*
+ return ( sharp + blur * 1.8 ) / 2 +
+ luminance(blur) *
+ float4( 0.5, 0.5, 0.5, 0) +
+ luminance(sharp) *
+ float4( 0.3, 0.3, 0.3, 0);
+*/
+/*
+ return ( sharp + blur * 0.9) / 2 +
+ luminance(blur) * float4(0.1, 0.15, 0.7, 0);
+*/
+
+/*
+ return ( sharp + blur * 0.9) / 2 +
+ luminance(blur) * float4(0.1, 0.15, 0.7, 0);
+*/
+
+// float4 retColor = luminance( sharp ) +
+// luminance( blur ) + blur / 2;
+// return retColor;
+}
+
+
+
+
+
+
+
+
+
Added: trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,56 @@
+//-------------------------------
+//BlurH_ps20.glsl
+// Horizontal Gaussian-Blur pass
+//-------------------------------
+
+uniform sampler2D Blur0;
+vec2 pos[11] =
+{
+ vec2( -5, 0),
+ vec2( -4, 0),
+ vec2( -3, 0),
+ vec2( -2, 0),
+ vec2( -1, 0),
+ vec2( 0, 0),
+ vec2( 1, 0),
+ vec2( 2, 0),
+ vec2( 3, 0),
+ vec2( 4, 0),
+ vec2( 5, 0)
+};
+
+//We use the Normal-gauss distribution formula
+//f(x) being the formula, we used f(0.5)-f(-0.5); f(1.5)-f(0.5)...
+float samples[11] =
+{//stddev=2.0
+0.01222447,
+0.02783468,
+0.06559061,
+0.12097757,
+0.17466632,
+
+0.19741265,
+
+0.17466632,
+0.12097757,
+0.06559061,
+0.02783468,
+0.01222447
+};
+
+void main()
+{
+ vec4 retVal;
+
+ vec4 sum;
+ vec2 texcoord = vec2( gl_TexCoord[0] );
+ int i = 0;
+
+ sum = vec4( 0 );
+ for( i=0;i < 11; i++ )
+ {
+ sum += texture2D( Blur0, texcoord + (pos[i] * 0.0100000) ) * samples[i];
+ }
+
+ gl_FragColor = sum;
+}
Added: trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.hlsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.hlsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/BlurH_ps20.hlsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,51 @@
+//-------------------------------
+//BlurH_ps20.hlsl
+// Horizontal Gaussian-Blur pass
+//-------------------------------
+
+sampler Blur0: register(s0);
+// Simple blur filter
+
+//We use the Normal-gauss distribution formula
+//f(x) being the formula, we used f(0.5)-f(-0.5); f(1.5)-f(0.5)...
+static const float samples[11] =
+{//stddev=2.0
+0.01222447,
+0.02783468,
+0.06559061,
+0.12097757,
+0.17466632,
+
+0.19741265,
+
+0.17466632,
+0.12097757,
+0.06559061,
+0.02783468,
+0.01222447
+};
+
+static const float2 pos[11] =
+{
+-5, 0,
+-4, 0,
+-3, 0,
+-2, 0,
+-1, 0,
+ 0, 0,
+ 1, 0,
+ 2, 0,
+ 3, 0,
+ 4, 0,
+ 5, 0,
+};
+
+float4 main(float2 texCoord: TEXCOORD0) : COLOR
+{
+ float4 sum = 0;
+ for (int i = 0; i < 11; i++)
+ {
+ sum += tex2D(Blur0, texCoord + pos[i]*0.01) * samples[i];
+ }
+ return sum;
+}
Added: trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,60 @@
+// Note, this won't work on ATI which is why it's not used
+// the issue is with the array initializers
+// no card supports GL_3DL_array_objects but it does work on nvidia, not on ATI
+//#extension GL_3DL_array_objects : enable
+
+//-------------------------------
+//BlurV_ps20.glsl
+// Vertical Gaussian-Blur pass
+//-------------------------------
+
+uniform sampler2D Blur0;
+vec2 pos[11] = vec2[11](
+ vec2(0.0, -5.0),
+ vec2(0.0, -4.0),
+ vec2(0.0, -3.0),
+ vec2(0.0, -2.0),
+ vec2(0.0, -1.0),
+ vec2(0.0, 0.0),
+ vec2(0.0, 1.0),
+ vec2(0.0, 2.0),
+ vec2(0.0, 3.0),
+ vec2(0.0, 4.0),
+ vec2(0.0, 5.0)
+);
+
+//We use the Normal-gauss distribution formula
+//f(x) being the formula, we used f(0.5)-f(-0.5); f(1.5)-f(0.5)...
+float samples[11] = float[11]
+(//stddev=2.0
+0.01222447,
+0.02783468,
+0.06559061,
+0.12097757,
+0.17466632,
+
+0.19741265,
+
+0.17466632,
+0.12097757,
+0.06559061,
+0.02783468,
+0.01222447
+);
+
+void main()
+{
+ vec4 retVal;
+
+ vec4 sum;
+ vec2 texcoord = vec2(gl_TexCoord[0]);
+ int i = 0;
+
+ sum = vec4( 0 );
+ for( ;i < 11; i++ )
+ {
+ sum += texture2D( Blur0, texcoord + (pos[i] * 0.0100000) ) * samples[i];
+ }
+
+ gl_FragColor = sum;
+}
Added: trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.hlsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.hlsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/BlurV_ps20.hlsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,51 @@
+//-------------------------------
+//BlurV_ps20.hlsl
+// Vertical Gaussian-Blur pass
+//-------------------------------
+
+sampler Blur0: register(s0);
+// Simple blur filter
+
+//We use the Normal-gauss distribution formula
+//f(x) being the formula, we used f(0.5)-f(-0.5); f(1.5)-f(0.5)...
+static const float samples[11] =
+{//stddev=2.0
+0.01222447,
+0.02783468,
+0.06559061,
+0.12097757,
+0.17466632,
+
+0.19741265,
+
+0.17466632,
+0.12097757,
+0.06559061,
+0.02783468,
+0.01222447
+};
+
+static const float2 pos[11] =
+{
+0, -5,
+0, -4,
+0, -3,
+0, -2,
+0, -1,
+0, 0,
+0, 1,
+0, 2,
+0, 3,
+0, 4,
+0, 5
+};
+
+float4 main(float2 texCoord: TEXCOORD0) : COLOR
+{
+ float4 sum = 0;
+ for (int i = 0; i < 11; i++)
+ {
+ sum += tex2D(Blur0, texCoord + pos[i]*0.01) * samples[i];
+ }
+ return sum;
+}
Added: trunk/python-ogre/demos/media/materials/programs/Blur_vs.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Blur_vs.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Blur_vs.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,14 @@
+void main()
+{
+ vec2 inPos = sign(gl_Vertex.xy);
+ gl_Position = vec4(inPos.xy, 0.0, 1.0);
+
+ vec2 uv = (vec2(inPos.x, -inPos.y) + 1.0)*0.5;
+ gl_TexCoord[0] = vec4( uv, 0, 0 );
+
+ const float size = 0.01;
+ gl_TexCoord[1] = vec4( uv + vec2(0.0, 1.0)*size, 0, 0);
+ gl_TexCoord[2] = vec4( uv + vec2(0.0, 2.0)*size, 0, 0);
+ gl_TexCoord[3] = vec4( uv + vec2(0.0, -1.0)*size, 0, 0);
+ gl_TexCoord[4] = vec4( uv + vec2(0.0, -2.0)*size, 0, 0);
+}
Added: trunk/python-ogre/demos/media/materials/programs/Blur_vs11.hlsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Blur_vs11.hlsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Blur_vs11.hlsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,19 @@
+struct VS_OUTPUT {
+ float4 Pos: POSITION;
+ float2 texCoord: TEXCOORD0;
+};
+
+VS_OUTPUT main(float4 Pos: POSITION){
+ VS_OUTPUT Out;
+
+ // Clean up inaccuracies
+ Pos.xy = sign(Pos.xy);
+
+ Out.Pos = float4(Pos.xy, 0, 1);
+ // Image-space
+ Out.texCoord.x = 0.5 * (1 + Pos.x);
+ Out.texCoord.y = 0.5 * (1 - Pos.y);
+
+ return Out;
+}
+
Added: trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,29 @@
+//-------------------------------
+//BrightBloom_ps20.glsl
+// High-pass filter for obtaining lumminance
+// We use an aproximation formula that is pretty fast:
+// f(x) = ( -3 * ( x - 1 )^2 + 1 ) * 2
+// Color += Grayscale( f(Color) ) + 0.6
+//
+// Special thanks to ATI for their great HLSL2GLSL utility
+// http://sourceforge.net/projects/hlsl2glsl
+//-------------------------------
+
+uniform sampler2D RT;
+
+void main()
+{
+ vec4 tex;
+ vec4 bright4;
+ float bright;
+
+ vec2 texCoord = vec2( gl_TexCoord[0] );
+
+ tex = texture2D( RT, texCoord);
+ tex -= 1.00000;
+ bright4 = -6.00000 * tex * tex + 2.00000;
+ bright = dot( bright4, vec4( 0.333333, 0.333333, 0.333333, 0.000000) );
+ tex += (bright + 0.600000);
+
+ gl_FragColor = tex;
+}
Added: trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.hlsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.hlsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/BrightBloom2_ps20.hlsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,20 @@
+//-------------------------------
+//BrightBloom_ps20.hlsl
+// High-pass filter for obtaining lumminance
+// We use an aproximation formula that is pretty fast:
+// f(x) = ( -3 * ( x - 1 )^2 + 1 ) * 2
+// Color += f(Color)
+//-------------------------------
+
+float4 main(float2 texCoord: TEXCOORD0,
+ uniform sampler RT: register(s0)
+ ) : COLOR {
+ float4 tex = tex2D(RT, texCoord);
+
+ tex -= 1;
+ float4 bright4= -6 * tex * tex + 2; //float4 bright4= ( -3 * tex * tex + 1 ) * 2;
+ float bright = dot( bright4, float4( 0.333333, 0.333333, 0.333333, 0) );
+ tex += bright + 0.6;
+
+ return tex;
+}
Added: trunk/python-ogre/demos/media/materials/programs/Common.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Common.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Common.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,81 @@
+struct outPixel
+{
+ float4 colour : COLOR0;
+};
+
+// General functions
+
+// Expand a range-compressed vector
+half4 expand(half4 v)
+{
+ return v * 2 - 1;
+}
+half3 expand(half3 v)
+{
+ return v * 2 - 1;
+}
+half2 expand(half2 v)
+{
+ return v * 2 - 1;
+}
+half1 expand(half1 v)
+{
+ return v * 2 - 1;
+}
+
+// Returns light direction from light position and vertex position
+half3 getLightDirection(float4 lightPosition, float4 position)
+{
+ // calculate tangent space light vector
+ // Get object space light direction
+ // Non-normalised since we'll do that in the fragment program anyway
+ return lightPosition.xyz - (position.xyz * lightPosition.w);
+}
+
+// Returns eye direction from eye position and vertex position
+half3 getEyeDirection(float3 eyePosition, float4 position)
+{
+ return eyePosition - position.xyz;
+}
+
+// Returns a Tangent Binormal Normal matrix
+half3x3 getTBNMatrix(float3 tangent, float3 normal)
+{
+ // Calculate the binormal (NB we assume both normal and tangent are
+ // already normalised)
+ // NB looks like nvidia cross params are BACKWARDS to what you'd expect
+ // this equates to NxT, not TxN
+ float3 binormal = cross(tangent, normal);
+
+ // Form a rotation matrix out of the vectors
+ return half3x3(tangent, binormal, normal);
+}
+
+// Returns expanded normal vector from texture map
+half3 getNormalMapVector(sampler2D normalMap, float2 uv)
+{
+ // get bump map vector, again expand from range-compressed
+ return expand(tex2D(normalMap, uv).xyz);
+}
+
+// Returns displacement vector from normalmaps alpha channel
+half getDisplacement(sampler2D normalMap, float2 uv, half scale, half bias)
+{
+ // get the height using the tex coords
+ half height = tex2D(normalMap, uv).a;
+
+ // calculate displacement
+ return (height * scale) + bias;
+}
+
+// Returns a specular component from normal vector, specular colour and specular power
+half3 getSpecularComponent(float3 normal, float3 halfAngle, float3 specularcolour, float specularPower)
+{
+ return pow(saturate(dot(normal, halfAngle)), specularPower) * specularcolour;
+}
+
+// Returns a per-pixel lighted component from normal vector, lightdir and colour
+half3 getLightingComponent(float3 normal, float3 lightDir, float3 colour)
+{
+ return saturate(dot(normal, lightDir)) * colour;
+}
Added: trunk/python-ogre/demos/media/materials/programs/DitherFP.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/DitherFP.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/DitherFP.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,18 @@
+sampler RT : register(s0);
+sampler pattern : register(s1);
+
+half4 Dither_ps( float2 TexCoord : TEXCOORD0) : COLOR
+{
+ half c = dot(tex2D(RT, TexCoord),half4(0.30,0.11,0.59,0.00));
+ half n = tex2D(pattern, TexCoord).a*2 - 1.0;
+ c += n;
+ if (c > 0.5)
+ {
+ c = 0.0;
+ }
+ else
+ {
+ c = 1.0;
+ }
+ return half4(c,c,c,1.0);
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/HalftoneFP.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/HalftoneFP.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/HalftoneFP.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,18 @@
+sampler RT : register(s0);
+sampler pattern : register(s1);
+
+float4 Halftone_ps( float2 TexCoord : TEXCOORD0,
+ uniform float2 numTiles,
+ uniform float2 iNumTiles,
+ uniform float2 iNumTiles2,
+ uniform float4 lum) : COLOR
+{
+ float3 local;
+ local.xy = fmod(TexCoord, iNumTiles);
+ float2 middle = TexCoord - local.xy;
+ local.xy = local.xy * numTiles;
+ middle += iNumTiles2;
+ local.z = dot(tex2D(RT, middle ) , lum);
+ float4 c = tex3D(pattern,local).a;
+ return c;
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/NightVisionFP.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/NightVisionFP.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/NightVisionFP.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,26 @@
+sampler RT : register(s0);
+sampler noiseVol : register(s1);
+
+float4 NightVision_ps( float2 TexCoord : TEXCOORD0,
+ uniform float4 lum,
+ uniform float time) : COLOR
+{
+ float4 oC;
+ oC = tex2D(RT, TexCoord);
+
+ //obtain luminence value
+ oC = dot(oC,lum);
+
+ //add some random noise
+ oC += 0.2 *(tex3D(noiseVol, float3(TexCoord*5,time)))- 0.05;
+
+ //add lens circle effect
+ //(could be optimised by using texture)
+ float dist = distance(TexCoord, float2(0.5,0.5));
+ oC *= smoothstep(0.5,0.45,dist);
+
+ //add rb to the brightest pixels
+ oC.rb = max (oC.r - 0.75, 0)*4;
+
+ return oC ;
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/ParticleGS.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/ParticleGS.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/ParticleGS.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,324 @@
+//
+// Explanation of different particle types
+//
+#define PT_LAUNCHER 0 //Firework Launcher - launches a PT_SHELL every so many seconds
+#define PT_SHELL 1 //Unexploded shell - flies from the origin and explodes into many PT_EMBERXs
+#define PT_EMBER1 2 //basic particle - after it's emitted from the shell, it dies
+#define PT_EMBER2 3 //after it's emitted, it explodes again into many PT_EMBER1s
+#define PT_EMBER3 4 //just a differently colored ember1
+#define P_SHELLLIFE 3.0
+#define P_EMBER1LIFE 2.5
+#define P_EMBER2LIFE 1.5
+#define P_EMBER3LIFE 2.0
+
+//These two were originally shader params, but they caused runtime errors
+#define NUM_EMBER_1S 30
+#define NUM_EMBER_2S 15
+#define NUM_EMBER_3S 10
+//This one was originally a variant, but this also causes runtime errors
+//#define MAX_EMBER_2S 15.0
+
+//
+// Generic particle motion handler
+//
+
+void GSGenericHandler( float3 Pos, float3 Vel, float Timer, float Type,
+ float elapsedTime,
+ float3 frameGravity)
+{
+ Pos += Vel * elapsedTime;
+ Vel += frameGravity;
+ Timer -= elapsedTime;
+ if (Pos.y > -100)
+ {
+ emitVertex( Pos : POSITION, Vel : TEXCOORD2, Timer : TEXCOORD0, Type : TEXCOORD1);
+ }
+}
+
+//
+// Sample a random direction from our random texture
+//
+float3 RandomDir(float fOffset, float globalTime, sampler1D randomTex)
+{
+ float tCoord = (globalTime + fOffset) / 300.0;
+ return tex1D(randomTex, tCoord).rgb;
+}
+
+//
+// Launcher type particle handler
+//
+void GSLauncherHandler( float3 Pos, float3 Vel, float Timer, float Type,
+ float elapsedTime,
+ float globalTime,
+ sampler1D randomTex,
+ float secondsPerFirework)
+{
+ if(Timer <= 0)
+ {
+ float3 vRandom = normalize( RandomDir( Type, globalTime, randomTex) );
+ //Give it more of an up bias
+ vRandom = normalize(vRandom + float3(0,2.5,0));
+
+ //time to emit a new SHELL
+ float3 outputPos = Pos + Vel*elapsedTime;
+ float3 outputVel = Vel + vRandom*35.0;
+ float outputTimer = P_SHELLLIFE + vRandom.y*0.5;
+ float outputType = PT_SHELL;
+ emitVertex(outputPos : POSITION, outputVel : TEXCOORD2, outputTimer : TEXCOORD0, outputType : TEXCOORD1);
+
+ //reset our timer
+ Timer = secondsPerFirework + vRandom.x*0.4;
+ }
+ else
+ {
+ Timer -= elapsedTime;
+ }
+
+ //emit ourselves to keep us alive
+ emitVertex( Pos : POSITION, Vel : TEXCOORD2, Timer : TEXCOORD0, Type : TEXCOORD1);
+}
+
+//
+// Shell type particle handler
+//
+void GSShellHandler( float3 Pos, float3 Vel, float Timer, float Type,
+ float elapsedTime,
+ float globalTime,
+ sampler1D randomTex,
+ float3 frameGravity)
+{
+ if(Timer <= 0)
+ {
+ float3 outputPos;
+ float3 outputVel;
+ float outputTimer;
+ float outputType;
+
+ float3 vRandom = float3(0,0,0);
+
+ //time to emit a series of new Ember1s
+ for(int i=0; i<NUM_EMBER_1S; i++)
+ {
+ vRandom = normalize( RandomDir( Type+i, globalTime, randomTex ) );
+ outputPos = Pos + Vel*elapsedTime;
+ outputVel = Vel + vRandom*15.0;
+ outputTimer = P_EMBER1LIFE;
+ outputType = PT_EMBER1;
+ emitVertex(outputPos : POSITION, outputTimer : TEXCOORD0, outputType : TEXCOORD1, outputVel : TEXCOORD2);
+ }
+
+ //find out how many Ember2s to emit
+ //Not doing this because it causes a runtime error
+ //int numEmber2s = abs(vRandom.x)*MAX_EMBER_2S;
+ for(int i=0; i<NUM_EMBER_2S; i++)
+ {
+ vRandom = normalize( RandomDir( Type, globalTime, randomTex) );
+ outputPos = Pos + Vel*elapsedTime;
+ outputVel = Vel + vRandom*10.0;
+ outputTimer = P_EMBER2LIFE + 0.4*vRandom.x;
+ outputType = PT_EMBER2;
+ emitVertex(outputPos : POSITION, outputVel : TEXCOORD2, outputTimer : TEXCOORD0, outputType : TEXCOORD1);
+ }
+
+ }
+ else
+ {
+ GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity );
+ }
+}
+
+//
+// Ember1 and Ember3 type particle handler
+//
+void GSEmber1Handler( float3 Pos, float3 Vel, float Timer, float Type,
+ float elapsedTime,
+ float3 frameGravity)
+{
+ if(Timer > 0)
+ {
+ GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity );
+ }
+}
+
+//
+// Ember2 type particle handler
+//
+void GSEmber2Handler( float3 Pos, float3 Vel, float Timer, float Type,
+ float elapsedTime,
+ float globalTime,
+ sampler1D randomTex,
+ float3 frameGravity)
+{
+ if(Timer <= 0)
+ {
+ float3 outputPos;
+ float3 outputVel;
+ float outputTimer;
+ float outputType;
+
+ //time to emit a series of new Ember3s
+ for(int i=0; i<NUM_EMBER_3S; i++)
+ {
+ outputPos = Pos + Vel*elapsedTime;
+ outputVel = Vel + normalize( RandomDir( Type + i, globalTime, randomTex ) )*10.0;
+ outputTimer = P_EMBER3LIFE;
+ outputType = PT_EMBER3;
+ emitVertex(outputPos : POSITION, outputVel : TEXCOORD2, outputTimer : TEXCOORD0, outputType : TEXCOORD1);
+ }
+ }
+ else
+ {
+ GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity );
+ }
+}
+
+struct FireworkData
+{
+ float3 Pos : POSITION;
+ float Timer : TEXCOORD0;
+ float Type : TEXCOORD1;
+ float3 Velocity : TEXCOORD2;
+};
+
+//The vertex shader that prepares the fireworks for display
+FireworkData GenerateParticles_VS(
+ in float3 inPos : POSITION,
+ in float inTimer : TEXCOORD0,
+ in float inType : TEXCOORD1,
+ in float3 inVelocity : TEXCOORD2
+ )
+{
+ FireworkData output;
+ output.Pos = inPos;
+ output.Timer = inTimer;
+ output.Type = inType;
+ output.Velocity = inVelocity;
+
+ return output;
+}
+
+POINT
+POINT_OUT
+void GenerateParticles_GS(
+ AttribArray<float3> Pos : POSITION,
+ AttribArray<float> Timer : TEXCOORD0,
+ AttribArray<float> Type : TEXCOORD1,
+ AttribArray<float3> Vel : TEXCOORD2,
+
+ uniform sampler1D randomTex : TEXUNIT0,
+ uniform float3 frameGravity,
+ uniform float globalTime,
+ uniform float elapsedTime,
+ uniform float secondsPerFirework
+ )
+{
+ if( Type[0] == PT_LAUNCHER )
+ GSLauncherHandler( Pos[0], Vel[0], Timer[0], Type[0],
+ elapsedTime, globalTime, randomTex, secondsPerFirework);
+ else if ( Type[0] == PT_SHELL )
+ GSShellHandler( Pos[0], Vel[0], Timer[0], Type[0],
+ elapsedTime, globalTime, randomTex, frameGravity);
+ else if ( Type[0] == PT_EMBER1 ||
+ Type[0] == PT_EMBER3 )
+ GSEmber1Handler( Pos[0], Vel[0], Timer[0], Type[0],
+ elapsedTime, frameGravity);
+ else if( Type[0] == PT_EMBER2 )
+ GSEmber2Handler( Pos[0], Vel[0], Timer[0], Type[0],
+ elapsedTime, globalTime, randomTex, frameGravity);
+}
+
+struct ColoredFirework
+{
+ float3 pos : POSITION;
+ float4 color : COLOR;
+ float radius : TEXCOORD0;
+};
+
+//The vertex shader that prepares the fireworks for display
+ColoredFirework DisplayParticles_VS
+(
+ in float3 inPos : POSITION,
+ in float inTimer : TEXCOORD0,
+ in float inType : TEXCOORD1,
+ in float3 inVelocity : TEXCOORD2
+
+
+ //uniform float4x4 worldViewProj
+)
+{
+ ColoredFirework output;
+ //
+ // Pass the point through
+ //
+ output.pos = inPos; //Multiply by world matrix?
+ output.radius = 1.5;
+
+ //
+ // calculate the color
+ //
+ if( inType == PT_LAUNCHER )
+ {
+ output.color = float4(1,0.1,0.1,1);
+ output.radius = 1.0;
+ }
+ else if( inType == PT_SHELL )
+ {
+ output.color = float4(0.1,1,1,1);
+ output.radius = 1.0;
+ }
+ else if( inType == PT_EMBER1 )
+ {
+ output.color = float4(1,1,0.1,1);
+ output.color *= (inTimer / P_EMBER1LIFE );
+ }
+ else if( inType == PT_EMBER2 )
+ {
+ output.color = float4(1,0.1,1,1);
+ }
+ else if( inType == PT_EMBER3 )
+ {
+ output.color = float4(1,0.1,0.1,1);
+ output.color *= (inTimer / P_EMBER3LIFE );
+ }
+
+ return output;
+}
+
+//The geometry shader that prepares the fireworks for display
+POINT
+TRIANGLE_OUT
+void DisplayParticles_GS( AttribArray<float3> Pos : POSITION,
+ AttribArray<float4> Color : COLOR,
+ AttribArray<float> Radius : TEXCOORD0,
+
+ uniform float4x4 inverseView,
+ uniform float4x4 worldViewProj)
+{
+ //float3 g_positions[4] = { float3( -1, 1, 0 ), float3( 1, 1, 0 ), float3( -1, -1, 0 ), float3( 1, -1, 0 ) };
+ float3 g_positions[4] = { float3( -1, 1, 0 ), float3( -1, -1, 0 ), float3( 1, 1, 0 ), float3( 1, -1, 0 ) };
+ float2 g_texcoords[4] = { float2(0,1), float2(1,1), float2(0,0), float2(1,0) };
+
+
+ //
+ // Emit two new triangles
+ //
+ for(int i=0; i<4; i++)
+ {
+ float3 position = -g_positions[i]*Radius[0];
+ position = mul( (float3x3)inverseView, position ) + Pos[0];
+ float4 outPos = mul( worldViewProj, float4(position,1.0) );
+
+ emitVertex(outPos : POSITION, Color[0] : COLOR0, g_texcoords[i] : TEXCOORD0);
+ }
+ restartStrip();
+}
+
+//The pixels shaders that colors the fireworks
+float4 DisplayParticles_PS( float2 iTexCoord : TEXCOORD0,
+ float4 iColor : COLOR0,
+ uniform sampler diffuseTex : register(s0)) : COLOR
+{
+ return tex2D(diffuseTex, iTexCoord) * iColor;
+ //return float4(iTexCoord.x, iTexCoord.y, 0, 1) + iColor * 0.01;
+ //return float4(iTexCoord.xy, 0, 1) * 0.3 + tex2D(diffuseTex, iTexCoord) * 0.7 + iColor * 0.01;
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/PassthroughVP.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/PassthroughVP.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/PassthroughVP.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,5 @@
+void main()
+{
+ //Transform the vertex (ModelViewProj matrix)
+ gl_Position = ftransform();
+}
Added: trunk/python-ogre/demos/media/materials/programs/Radial_Blur_FP.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Radial_Blur_FP.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Radial_Blur_FP.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,57 @@
+//------------------------------------------------------
+//Radial_Blur_FP.cg
+// Implements radial blur to be used with the compositor
+// It's very dependant on screen resolution
+//------------------------------------------------------
+
+uniform sampler tex: register(s0);
+
+static const float samples[10] =
+{
+-0.08,
+-0.05,
+-0.03,
+-0.02,
+-0.01,
+0.01,
+0.02,
+0.03,
+0.05,
+0.08
+};
+
+float4 main(float2 texCoord: TEXCOORD0,
+ uniform float sampleDist,
+ uniform float sampleStrength
+ ) : COLOR
+{
+ //Vector from pixel to the center of the screen
+ float2 dir = 0.5 - texCoord;
+
+ //Distance from pixel to the center (distant pixels have stronger effect)
+ //float dist = distance( float2( 0.5, 0.5 ), texCoord );
+ float dist = sqrt( dir.x*dir.x + dir.y*dir.y );
+
+
+ //Now that we have dist, we can normlize vector
+ dir = normalize( dir );
+
+ //Save the color to be used later
+ float4 color = tex2D( tex, texCoord );
+
+ //Average the pixels going along the vector
+ float4 sum = color;
+ for (int i = 0; i < 10; i++)
+ {
+ sum += tex2D( tex, texCoord + dir * samples[i] * sampleDist );
+ }
+ sum /= 11;
+
+ //Calculate amount of blur based on
+ //distance and a strength parameter
+ float t = dist * sampleStrength;
+ t = saturate( t );//We need 0 <= t <= 1
+
+ //Blend the original color with the averaged pixels
+ return lerp( color, sum, t );
+}
Added: trunk/python-ogre/demos/media/materials/programs/Swizzle.gp
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/Swizzle.gp (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/Swizzle.gp 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,39 @@
+!!NVgp4.0
+PRIMITIVE_IN TRIANGLES;
+PRIMITIVE_OUT TRIANGLE_STRIP;
+VERTICES_OUT 6;
+# cgc version 2.0.0015, build date May 15 2008
+# command line args: -profile gpu_gp
+# source file: gs_simple.cg
+#vendor NVIDIA Corporation
+#version 2.0.0.15
+#profile gpu_gp
+#program geometry_swizzle
+#semantic geometry_swizzle.position : POSITION
+#var float4 position.__data[0] : $vin.VERTEX[0].POSITION : HPOS[0][32] : 0 : 1
+#var float4 position.__data[1] : $vin.VERTEX[1].POSITION : HPOS[1][32] : 0 : 1
+#var float4 position.__data[2] : $vin.VERTEX[2].POSITION : HPOS[2][32] : 0 : 1
+ATTRIB vertex_position = vertex.position;
+TEMP RC, HC;
+MOV.F result.position, vertex[0].position;
+MOV.F result.color, {1, 0}.xyyx;
+EMIT;
+MOV.F result.position, vertex[1].position;
+MOV.F result.color, {1, 0}.xyyx;
+EMIT;
+MOV.F result.position, vertex[2].position;
+MOV.F result.color, {1, 0}.xyyx;
+EMIT;
+ENDPRIM;
+MOV.F result.position, vertex[0].position.yxzw;
+MOV.F result.color, {0, 1}.xxyy;
+EMIT;
+MOV.F result.position, vertex[1].position.yxzw;
+MOV.F result.color, {0, 1}.xxyy;
+EMIT;
+MOV.F result.position, vertex[2].position.yxzw;
+MOV.F result.color, {0, 1}.xxyy;
+EMIT;
+ENDPRIM;
+END
+# 20 instructions, 0 R-regs
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/SwizzleGP.cg
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/SwizzleGP.cg (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/SwizzleGP.cg 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,14 @@
+// Geometry pass-through program for colored triangles
+TRIANGLE void gs_swizzle(AttribArray<float4> position : POSITION)
+{
+ for (int i=0; i<position.length; i++) {
+ emitVertex(position[i], float4(1,0.9,0.8,0.7):COLOR0);
+ }
+ restartStrip();
+ for (int i=0; i<position.length; i++) {
+ float4 newPosition = position[i].yxzw;
+ newPosition.z += 20;
+ emitVertex(newPosition:POSITION, float4(0.3,0.4,0.5,0.6):COLOR0);
+ }
+ restartStrip();
+}
\ No newline at end of file
Added: trunk/python-ogre/demos/media/materials/programs/SwizzleGP.glsl
===================================================================
--- trunk/python-ogre/demos/media/materials/programs/SwizzleGP.glsl (rev 0)
+++ trunk/python-ogre/demos/media/materials/programs/SwizzleGP.glsl 2008-09-07 11:39:21 UTC (rev 736)
@@ -0,0 +1,40 @@
+#version 120
+#extension GL_EXT_geometry_shader4 : enable
+
+uniform vec4 origColor;
+uniform vec4 cloneColor;
+
+void main(void)
+{
+
+ //increment variable
+ int i;
+
+ /////////////////////////////////////////////////////////////
+ //This example has two parts
+ // step a) draw the primitive pushed down the pipeline
+ // there are gl_Vertices # of vertices
+ // put the vertex value into gl_Position
+ // use EmitVertex => 'create' a new vertex
+ // use EndPrimitive to signal that you are done creating a primitive!
+ // step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!)
+ // I just do the same loop, but swizzle the x and y values
+ // result => the line we want to draw, and the same line, but along the other axis
+
+ //Pass-thru!
+ for(i=0; i< gl_VerticesIn; i++){
+ gl_Position = gl_PositionIn[i];
+ gl_FrontColor = origColor;
+ EmitVertex();
+ }
+ EndPrimitive();
+ //New piece of geometry! We just swizzle the x and y terms
+ for(i=0; i< gl_VerticesIn; i++){
+ gl_Position = gl_PositionIn[i];
+ gl_Position.xy = gl_Position.yx;
+ gl_FrontColor = cloneColor;
+ EmitVertex();
+ }
+ EndPrimitive(); ...
[truncated message content] |