Confusion - Shader Mess!

Started by
4 comments, last by JorenJoestar 16 years, 3 months ago
Hi guys...I'm developing my own engine. I want to create something platform indipendent, and I'm stuck on decision about the shaders... HLSL/GLSL is not platform indipendent, so I have to choose Cg? Is it good? Is it supported? If yes, I have to create Cgs with FX Composer 2 and then use NVidia DirectX Sdk to use it on directx? And what if I decide to develop only in one direction - opengl OR directx? I have read that directx has effects (.fx) that makes use of shader very easy. And what about OpenGL??? Thank you in advice!
---------------------------------------http://badfoolprototype.blogspot.com/
Advertisement
You need to decide what API you're going to use before deciding what shader language to use.

If it's DirectX only, use HLSL (the effect framework simplifies shaders a lot).
NextWar: The Quest for Earth available now for Windows Phone 7.
GLSL is as platform independent as OpenGL, since it's part of OpenGL 2.0. You're talking about API independence, not platform independence. Cg can compile to both DirectX and OpenGL shader programs, so it works with either graphics API.

The Cg tools are like compilers. They compile your program to the low level language understood by the API you're using, just like a C compiler compiles a C program to the language understood by the hardware of the machine you are using.
HLSL is almost syntactically equivalent to Cg so one option is to use HLSL with Direct 3D and to use the equivalent shaders as Cg shaders in OpenGL.

ATI also has a tool which converts HLSL shaders to GLSL shaders so that is another route which allows you to avoid Cg altogether as long as you develop your shaders in HLSL.
If you are looking for platform independence, then choosing ONLY DirectX is not going to be very useful to you, since it only runs on Windows, but choosing only OpenGL is platform independent (in which case, you may as well use GLSL).

If you are planning on using both DirectX and OpenGL, then you need to provide shaders for both (or use a format, like you mentioned, which can be shared between both).
Thank you...this begin to be more understandable!

What do you suggest me to do for a demo?
I'm developing an engine and then a demo...this is something to be used as a presentation because I want to enter the game industry...so what is the best for you for a demo?

Thank you!
---------------------------------------http://badfoolprototype.blogspot.com/

This topic is closed to new replies.

Advertisement