[PB4.30] Pixel/Vertex shaders examples DirectX/OpenGL
[PB4.30] Pixel/Vertex shaders examples DirectX/OpenGL
This is an example of pixel shaders taken from the ogre site and adapted to Purebasic.
Download there : http://djes.free.fr/purebasic/shader_un ... xample.zip
The first example is a simple orange cube. The color is generated by a simple shader, profiled for DirectX (HLSL) and OpenGL (GLSL), and should work on Windows and Linux.
The second example is a textured cube, with an altered color. Texture is given by the shader (HLSL only by now).
EDIT: First example unified version (no more assembler)
Download there : http://djes.free.fr/purebasic/shader_un ... xample.zip
The first example is a simple orange cube. The color is generated by a simple shader, profiled for DirectX (HLSL) and OpenGL (GLSL), and should work on Windows and Linux.
The second example is a textured cube, with an altered color. Texture is given by the shader (HLSL only by now).
EDIT: First example unified version (no more assembler)
Last edited by djes on Sat Nov 08, 2008 2:47 pm, edited 4 times in total.
Yup, no CG binding it seems.
On a Nvidia GF7 Series the simple shader doesent work.
Thalius
On a Nvidia GF7 Series the simple shader doesent work.
Cheers,: GPU Vendor: nvidia
14:25:41: Device Name: NVIDIA GeForce 7600 GS
14:25:41: Driver Version: 6.14.11.7813
14:25:41: * Fixed function pipeline: yes
14:25:41: * Hardware generation of mipmaps: yes
14:25:41: * Texture blending: yes
14:25:41: * Anisotropic texture filtering: yes
14:25:41: * Dot product texture operation: yes
14:25:41: * Cube mapping: yes
14:25:41: * Hardware stencil buffer: yes
14:25:41: - Stencil depth: 8
14:25:41: - Two sided stencil support: yes
14:25:41: - Wrap stencil values: yes
14:25:41: * Hardware vertex / index buffers: yes
14:25:41: * Vertex programs: yes
14:25:41: * Fragment programs: yes
14:25:41: * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 ps_2_a ps_2_b ps_2_x ps_3_0 vs_1_1 vs_2_0 vs_2_a vs_2_x vs_3_0
14:25:41: * Texture Compression: yes
14:25:41: - DXT: yes
14:25:41: - VTC: no
14:25:41: * Scissor Rectangle: yes
14:25:41: * Hardware Occlusion Query: yes
14:25:41: * User clip planes: yes
14:25:41: * VET_UBYTE4 vertex element type: yes
14:25:41: * Infinite far plane projection: yes
14:25:41: * Hardware render-to-texture: yes
14:25:41: * Floating point textures: yes
14:25:41: * Non-power-of-two textures: yes
14:25:41: * Volume textures: yes
14:25:41: * Multiple Render Targets: 4
14:25:41: - With different bit depths: no
14:25:41: * Point Sprites: yes
14:25:41: * Extended point parameters: yes
14:25:41: * Max Point Size: 8192
14:25:41: * Vertex texture fetch: yes
14:25:41: - Max vertex textures: 4
14:25:41: - Vertex textures shared: no
14:25:41: * DirectX per stage constants: yes
14:25:41: ResourceBackgroundQueue - threading disabled
14:25:41: Particle Renderer Type 'billboard' registered
14:25:41: Parsing scripts for resource group Autodetect
14:25:41: Finished parsing scripts for resource group Autodetect
14:25:41: Parsing scripts for resource group General
14:25:41: Parsing script shadercube.material
14:25:41: Finished parsing scripts for resource group General
14:25:41: Parsing scripts for resource group Internal
14:25:41: Finished parsing scripts for resource group Internal
14:25:41: Mesh: Loading shadercube.mesh.
14:25:41: WARNING: material shader has no supportable Techniques and will be blank. Explanation:
Pass 0: Fragment program orangeFP cannot be used - not supported.
Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
"
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!

thanks. neat.
the first test worked fine. i was able to change the color by modifying the script.
the second one didn't work (just white). here's the ogre.log:
[PB 4.30 on Windows XP]
the first test worked fine. i was able to change the color by modifying the script.
the second one didn't work (just white). here's the ogre.log:
have i done something wrong?16:19:07: Creating resource group General
16:19:07: Creating resource group Internal
16:19:07: Creating resource group Autodetect
16:19:07: SceneManagerFactory for type 'DefaultSceneManager' registered.
16:19:07: Registering ResourceManager for type Material
16:19:07: Registering ResourceManager for type Mesh
16:19:07: Registering ResourceManager for type Skeleton
16:19:07: MovableObjectFactory for type 'ParticleSystem' registered.
16:19:07: OverlayElementFactory for type Panel registered.
16:19:07: OverlayElementFactory for type BorderPanel registered.
16:19:07: OverlayElementFactory for type TextArea registered.
16:19:07: Registering ResourceManager for type Font
16:19:07: ArchiveFactory for archive type FileSystem registered.
16:19:07: ArchiveFactory for archive type Zip registered.
16:19:07: FreeImage version: 3.10.0
16:19:07: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
16:19:07: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,koa,iff,lbm,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,dds,gif,g3,sgi,j2k,j2c,jp2
16:19:07: DDS codec registering
16:19:07: Registering ResourceManager for type HighLevelGpuProgram
16:19:07: Registering ResourceManager for type Compositor
16:19:07: MovableObjectFactory for type 'Entity' registered.
16:19:07: MovableObjectFactory for type 'Light' registered.
16:19:07: MovableObjectFactory for type 'BillboardSet' registered.
16:19:07: MovableObjectFactory for type 'ManualObject' registered.
16:19:07: MovableObjectFactory for type 'BillboardChain' registered.
16:19:07: MovableObjectFactory for type 'RibbonTrail' registered.
16:19:07: OGRE EXCEPTION(6:FileNotFoundException): 'plugins.cfg' file not found! in ConfigFile::load at OgreConfigFile.cpp (line 84)
16:19:07: plugins.cfg not found, automatic plugin loading disabled.
16:19:07: *-*-* OGRE Initialising
16:19:07: *-*-* Version 1.6.0RC1 (Shoggoth)
16:19:07: D3D9 : Direct3D9 Rendering Subsystem created.
16:19:07: D3D9: Driver Detection Starts
16:19:07: D3D9: Driver Detection Ends
16:19:07: Particle Emitter Type 'Point' registered
16:19:07: Particle Emitter Type 'Box' registered
16:19:07: Particle Emitter Type 'Ellipsoid' registered
16:19:07: Particle Emitter Type 'Cylinder' registered
16:19:07: Particle Emitter Type 'Ring' registered
16:19:07: Particle Emitter Type 'HollowEllipsoid' registered
16:19:07: Particle Affector Type 'LinearForce' registered
16:19:07: Particle Affector Type 'ColourFader' registered
16:19:07: Particle Affector Type 'ColourFader2' registered
16:19:07: Particle Affector Type 'ColourImage' registered
16:19:07: Particle Affector Type 'ColourInterpolator' registered
16:19:07: Particle Affector Type 'Scaler' registered
16:19:07: Particle Affector Type 'Rotator' registered
16:19:07: Particle Affector Type 'DirectionRandomiser' registered
16:19:07: Particle Affector Type 'DeflectorPlane' registered
16:19:07: CPU Identifier & Features
16:19:07: -------------------------
16:19:07: * CPU ID: GenuineIntel: Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz
16:19:07: * SSE: yes
16:19:07: * SSE2: yes
16:19:07: * SSE3: yes
16:19:07: * MMX: yes
16:19:07: * MMXEXT: yes
16:19:07: * 3DNOW: no
16:19:07: * 3DNOWEXT: no
16:19:07: * CMOV: yes
16:19:07: * TSC: yes
16:19:07: * FPU: yes
16:19:07: * PRO: yes
16:19:07: * HT: no
16:19:07: -------------------------
16:19:07: D3D9 : Subsystem Initialising
16:19:07: ***************************************
16:19:07: *** D3D9 : Subsystem Initialised OK ***
16:19:07: ***************************************
16:19:07: SceneManagerFactory for type 'OctreeSceneManager' registered.
16:19:07: SceneManagerFactory for type 'TerrainSceneManager' registered.
16:19:07: SceneManagerFactory for type 'BspSceneManager' registered.
16:19:07: Registering ResourceManager for type BspLevel
16:19:07: Added resource location './test2/' of type 'FileSystem' to resource group 'General'
16:19:08: D3D9RenderSystem::_createRenderWindow "PureBasic Ogre", 512x384 windowed miscParams: FSAA=0 externalWindowHandle=4850934
16:19:08: D3D9 : Created D3D9 Rendering Window 'PureBasic Ogre' : 512x384, 32bpp
16:19:08: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem.
16:19:08: Registering ResourceManager for type Texture
16:19:08: Registering ResourceManager for type GpuProgram
16:19:08: RenderSystem capabilities
16:19:08: -------------------------
16:19:08: RenderSystem Name: Direct3D9 Rendering Subsystem
16:19:08: GPU Vendor: intel
16:19:08: Device Name: Mobile Intel(R) 945GM Express Chipset Family
16:19:08: Driver Version: 6.14.10.4543
16:19:08: * Fixed function pipeline: yes
16:19:08: * Hardware generation of mipmaps: no
16:19:08: * Texture blending: yes
16:19:08: * Anisotropic texture filtering: yes
16:19:08: * Dot product texture operation: yes
16:19:08: * Cube mapping: yes
16:19:08: * Hardware stencil buffer: yes
16:19:08: - Stencil depth: 8
16:19:08: - Two sided stencil support: yes
16:19:08: - Wrap stencil values: yes
16:19:08: * Hardware vertex / index buffers: yes
16:19:08: * Vertex programs: yes
16:19:08: * Fragment programs: yes
16:19:08: * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 vs_1_1 vs_2_0 vs_2_a vs_2_x vs_3_0
16:19:08: * Texture Compression: yes
16:19:08: - DXT: yes
16:19:08: - VTC: no
16:19:08: * Scissor Rectangle: yes
16:19:08: * Hardware Occlusion Query: no
16:19:08: * User clip planes: yes
16:19:08: * VET_UBYTE4 vertex element type: yes
16:19:08: * Infinite far plane projection: yes
16:19:08: * Hardware render-to-texture: yes
16:19:08: * Floating point textures: no
16:19:08: * Non-power-of-two textures: yes (limited)
16:19:08: * Volume textures: yes
16:19:08: * Multiple Render Targets: 1
16:19:08: - With different bit depths: no
16:19:08: * Point Sprites: yes
16:19:08: * Extended point parameters: yes
16:19:08: * Max Point Size: 256
16:19:08: * Vertex texture fetch: no
16:19:08: * DirectX per stage constants: yes
16:19:08: ResourceBackgroundQueue - threading disabled
16:19:08: Particle Renderer Type 'billboard' registered
16:19:08: Parsing scripts for resource group Autodetect
16:19:08: Finished parsing scripts for resource group Autodetect
16:19:08: Parsing scripts for resource group General
16:19:08: Parsing script shadercube.material
16:19:08: Finished parsing scripts for resource group General
16:19:08: Parsing scripts for resource group Internal
16:19:08: Finished parsing scripts for resource group Internal
16:19:08: Mesh: Loading shadercube.mesh.
16:19:08: WARNING: material shader has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program PlainTexture_VS cannot be used - not supported.
16:19:08: Creating viewport on target 'PureBasic Ogre', rendering from camera 'C0', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
[PB 4.30 on Windows XP]
Repeat this sequence out loud:
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions
I'm running a GeForce 8400 GS which has no problems rendering Unreal Tournament 3. But I don't see any texture in the second example and, unless I'm missing something, I only see a solid (no lighting or shading) orange cube in the first example.
The log also said this:
Code: Select all
18:47:10: RenderSystem capabilities
18:47:10: -------------------------
18:47:10: RenderSystem Name: Direct3D9 Rendering Subsystem
18:47:10: GPU Vendor: nvidia
18:47:10: Device Name: NVIDIA GeForce 8400M GS
18:47:10: Driver Version: 8.15.11.8585
18:47:10: * Fixed function pipeline: yes
18:47:10: * Hardware generation of mipmaps: yes
18:47:10: * Texture blending: yes
18:47:10: * Anisotropic texture filtering: yes
18:47:10: * Dot product texture operation: yes
18:47:10: * Cube mapping: yes
18:47:10: * Hardware stencil buffer: yes
18:47:10: - Stencil depth: 8
18:47:10: - Two sided stencil support: yes
18:47:10: - Wrap stencil values: yes
18:47:10: * Hardware vertex / index buffers: yes
18:47:10: * Vertex programs: yes
18:47:10: * Fragment programs: yes
18:47:10: * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 ps_2_a ps_2_b ps_2_x ps_3_0 vs_1_1 vs_2_0 vs_2_a vs_2_x vs_3_0
18:47:10: * Texture Compression: yes
18:47:10: - DXT: yes
18:47:10: - VTC: no
18:47:10: * Scissor Rectangle: yes
18:47:10: * Hardware Occlusion Query: yes
18:47:10: * User clip planes: yes
18:47:10: * VET_UBYTE4 vertex element type: yes
18:47:10: * Infinite far plane projection: yes
18:47:10: * Hardware render-to-texture: yes
18:47:10: * Floating point textures: yes
18:47:10: * Non-power-of-two textures: yes
18:47:10: * Volume textures: yes
18:47:10: * Multiple Render Targets: 4
18:47:10: - With different bit depths: yes
18:47:10: * Point Sprites: yes
18:47:10: * Extended point parameters: yes
18:47:10: * Max Point Size: 8192
18:47:10: * Vertex texture fetch: yes
18:47:10: - Max vertex textures: 4
18:47:10: - Vertex textures shared: no
18:47:10: * DirectX per stage constants: yes
18:47:10: ResourceBackgroundQueue - threading disabled
18:47:10: Particle Renderer Type 'billboard' registered
18:47:10: Parsing scripts for resource group Autodetect
18:47:10: Finished parsing scripts for resource group Autodetect
18:47:10: Parsing scripts for resource group General
18:47:10: Parsing script shadercube.material
18:47:10: Finished parsing scripts for resource group General
18:47:10: Parsing scripts for resource group Internal
18:47:10: Finished parsing scripts for resource group Internal
18:47:10: Mesh: Loading shadercube.mesh.
18:47:10: WARNING: material shader has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program PlainTexture_VS cannot be used - not supported.
18:47:08: OGRE EXCEPTION(6:FileNotFoundException): 'plugins.cfg' file not found! in ConfigFile::load at OgreConfigFile.cpp (line 84)
18:47:08: plugins.cfg not found, automatic plugin loading disabled.
Re: [PB4.30] Pixel/Vertex shaders examples DirectX/OpenGL
Parse3DScripts() gives the error "Invalid memory access. (read error at address 0)"
Re: [PB4.30] Pixel/Vertex shaders examples DirectX/OpenGL
I'm not supporting this anymore, as the new PB version is far more superior !