   Learning Shaders
  Can anyone direct me to a few good tutorials on writting shaders ? Had a poke around the features section here, and while the stuff was really intresting, none of it was on shaders :(Cheers   
  What kind of shaders?There is HLSL for DirectX, GLSL for OpenGL, assembly versions for both and NVIDIA's Cg, etc...If you want GLSL then check out the tutorials here.  There are also some tutorials for DirectX HLSL and OpenGL GLSL here and here (Quick Google).If you want to check out some shader editors then NVIDIA Cg is here and ATi RenderMonkey is here.  They both contain lots of sample shaders to examine.  There is also a GLSL only editor here.  I prefer RenderMonkey. There are also lots of books, I don't know of any for beginners off the top of my head though.Hope that helps, ;Quote:Original post by ntsI prefer RenderMonkey.Why?  (Just curious.)   ;  +1 for RenderMonkey, Shader Designer reboots my machine. RenderMonkey has a good interface. You also can pass it some data and run the shaders for a while to see the effect in action.   ;  Thanks for your replies, but i'm a bit confused. Rendermonkey is just an editor right, like visual studio ? Now all those langauges, is there any real difference between them ? Will say HLSL work with an OpenGL render, or alteratively will GLSL work with DirectX. If not, I'll need to different write scripts for each render my game uses right ? (I'm using OGRE3D btw). Which is the best one to use ? Also do you need the SDK's from each manufacturer to complie HLSL and GLSL programs, or are they just dumped into the GPU.I'm assuming GL and ATI's assembler shader, will only work for those specific vendors, yeah? Hope thats clear,   ;  HLSL will only work in DirectX.GLSL will only work in OpenGL.I'm not sure about asm shaders, if they use basic intructions they could probably be compiled by both API's without change.   ;  As Smit already pointed out, the difference is that they are specific to their API. You can edit both in RenderMonkey though. Yeah it's just an editor, you then still need to do the setup in your program if you want to use the shaders (might be complicated for multi-pass and with all those variables you may need to pass, but that's solved by your engine). I think Cg works with both DirectX and OpenGL, not sure how to set that up though.Usually you don't need anything special to compile them. You just call the API's functions, something like CompileShader(), LinkShaders(), whatever, passing the string containing the shader code. But you're using Ogre, so you need to use the Ogre API for the shaders. Check the documentation and API reference.   ;  One often forgtotten shading language is Sh. This shading language is used as a C++ library, meaning that you can directly embbed the shader code in your software. The result is, of course, runtime conditional construction and compilation of the shader - which can't be bad since it this conditional construction and compilation can be driven by the capabilities of the target user machine. Sh also ease the development of non graphical shadersAnother article about Sh.What would really be nice is a API-independent shader language specification. I didn't checked very well, but it seems that COLLADA FX claims to be such kind of language. It is an XML shader format, and is then used in conjunction with the COLLADA DOM library to output the read shader. Update: I gave a read to some COLLADA FX related documents, and it seems that it is built on the top of Cg.I failed to find other API-independant shaders - many of the material implementation I checked were based upon Cg.HTH,   ;Quote:Original post by f001errorThanks for your replies, but i'm a bit confused. Rendermonkey is just an editor right, like visual studio ? Yup.  It allows you to code your shaders in HLSL and GLSL.Quote:Now all those langauges, is there any real difference between them ? Will say HLSL work with an OpenGL render, or alteratively will GLSL work with DirectX. If not, I'll need to different write scripts for each render my game uses right ?HLSL only works with Direct3D and GLSL only works with OpenGL.  If you want only code your shaders once and use them cross-platform, Cg would be the way to go.  Also, Cg's syntax is essentially the same as HLSL.Quote: (I'm using OGRE3D btw). Which is the best one to use ? Also do you need the SDK's from each manufacturer to complie HLSL and GLSL programs, or are they just dumped into the GPU.I also use OGRE and program my shaders with RenderMonkey.  There's actually an OGRE RenderMonkey exporter (it's on the ogre site) that's very easy to use.  You set up your entire shader in RenderMonkey, hit the export button and it's ready to use in OGRE right away... no messing around with the .material files or anything.;Quote:Original post by GaryNasQuote:Original post by f001errorThanks for your replies, but i'm a bit confused. Rendermonkey is just an editor right, like visual studio ? Yup.  It allows you to code your shaders in HLSL and GLSL.Quote:Now all those langauges, is there any real difference between them ? Will say HLSL work with an OpenGL render, or alteratively will GLSL work with DirectX. If not, I'll need to different write scripts for each render my game uses right ?HLSL only works with Direct3D and GLSL only works with OpenGL.  If you want only code your shaders once and use them cross-platform, Cg would be the way to go.  Also, Cg's syntax is essentially the same as HLSL.Quote: (I'm using OGRE3D btw). Which is the best one to use ? Also do you need the SDK's from each manufacturer to complie HLSL and GLSL programs, or are they just dumped into the GPU.I also use OGRE and program my shaders with RenderMonkey.  There's actually an OGRE RenderMonkey exporter (it's on the ogre site) that's very easy to use.  You set up your entire shader in RenderMonkey, hit the export button and it's ready to use in OGRE right away... no messing around with the .material files or anything.Kewl, so RenderMonkey using Cg will give me cross platform shaders :) Is there any loss of performance in using Cg over HLSL or GLSL ?   