GLSL/HLSL/Cg?

Started by
3 comments, last by JorenJoestar 16 years ago
Hi guys...I need a hint. Working on my engine (Hydra, www.badfoolprototype.com) I'm developing the shader system, but a great question is: is it better to develop shaders either in GLSL and HLSL and then use it or use CgFX SDK and fxcomposer? Cg is good also on ATI cards??? Thanks to everybody!
---------------------------------------http://badfoolprototype.blogspot.com/
Advertisement
Hey. Just read through some pages on your site and it seems that you want things to be cross platform and graphics API independent(right?). If so, the best bet would be Cg since it can be used with both DirectX and OpenGL. This would be the easiest since you don't want to write your shaders in both HLSL and GLSL.

As for Cg working well on ATI cards, I have no idea since I have an nVidia card (hopefully others can give you info on that).
Well...about cg code that works on ATI I have my doubts...I've done a simple shader that works differently on ATI and NVidia cards.
I was thinking of using only the assembly code...so I can compile HLSL, GLSL and Cg and the result is the same. Our editor will let you create or import the shaders in every language, but it will use only the assembly.

Is this a good approach?
---------------------------------------http://badfoolprototype.blogspot.com/
Quote:Original post by JorenJoestar
Well...about cg code that works on ATI I have my doubts...I've done a simple shader that works differently on ATI and NVidia cards.
This is true no matter what language you use. You may even get different results between driver versions on the same card, and you will definitely have problems moving between platforms - it is basically a crap-shoot.
Quote:I was thinking of using only the assembly code...so I can compile HLSL, GLSL and Cg and the result is the same. Our editor will let you create or import the shaders in every language, but it will use only the assembly.
What assembly do you use? Different cards use different assembly, and different drivers produce different assemblies. Also, while HLSL is compiled to assembly beforehand, GLSL is compiled at runtime.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Well I've compiled the shaders with:

ARBvp1.0
vs_2_0

for vertex shader and for pixel shader:

ARBfp1.0
ps_2_0

The strange thing is that it works perfectly under directx and opengl under windows and linux, then moving to nvidia cards it is bugged...

It's a simple point-light per vertex...until i moved to nvidia worked flawlessly!

So the question arouse: it is safe to use compiled shaders (like this one) for multiplatform/api engine?

Thanks guys!
---------------------------------------http://badfoolprototype.blogspot.com/

This topic is closed to new replies.

Advertisement