Confusion - Shader Mess!
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!
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).
If it's DirectX only, use HLSL (the effect framework simplifies shaders a lot).
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.
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.
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).
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement