Sign in to follow this  
JorenJoestar

GLSL/HLSL/Cg?

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this