Jump to content
  • Advertisement
Sign in to follow this  
Vinniee

Which shading language to use?

This topic is 4142 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, We all know that shaders are very important if you want to have some good graphics on screen. I really want to learn a shader language because they are so important. But which shader language should I use? I have the book 'The CG Tutorial', should I just read that or is HLSL ( developed by Microsoft ) better? Greetings, Vinnie.

Share this post


Link to post
Share on other sites
Advertisement
Learn either one... they're pretty similar, so having learned one, the other will be easy to figure out.

May also depend on what API you are programming to... DirectX? I think you have to use HLSL. OpenGL, I believe, uses Cg... though I don't know offhand if that is set in stone.

Share this post


Link to post
Share on other sites
Thanks for the quick reply dude!

I am using DirectX yes, but I know that CG and HLSL both work with DirectX.

So I can do the same with both? Can I also use the geometry shader with CG?

Share this post


Link to post
Share on other sites
Quote:
Original post by mossmoss
May also depend on what API you are programming to... DirectX? I think you have to use HLSL. OpenGL, I believe, uses Cg... though I don't know offhand if that is set in stone.


DirectX supports HLSL and in particular the Shader Models, OpenGL supports GLSL and Cg is an intermediate language, based on the original HLSL language. Cg compiles to any of the above (and more). They are pretty much equal in power, but handwritten platform-dependent shader code could (at this stage) outperform Cg output.

Quote:
Original post by mossmoss
Can I also use the geometry shader with CG?


Not yet.

Share this post


Link to post
Share on other sites
Quote:
Original post by Todo
Quote:
Original post by mossmoss
May also depend on what API you are programming to... DirectX? I think you have to use HLSL. OpenGL, I believe, uses Cg... though I don't know offhand if that is set in stone.


DirectX supports HLSL and in particular the Shader Models, OpenGL supports GLSL and Cg is an intermediate language, based on the original HLSL language. Cg compiles to any of the above (and more). They are pretty much equal in power, but handwritten platform-dependent shader code could (at this stage) outperform Cg output.

Quote:
Original post by mossmoss
Can I also use the geometry shader with CG?


Not yet.


Do you think that it should be smarter for me to learn HLSL instead of CG?

Share this post


Link to post
Share on other sites
HLSL and CG are pretty much identical (indeed the foreword of the CG Tutorial says this). GLSL is a bit different but the concepts are all the same. The important thing about shaders is understanding what they're actually doing and how you can use them to produce the effects you want, understanding that is language independent. So read your book, learn CG, then flick through the DX docs to see how HLSL works. You'll find the language very similar (if not identical, I think there's only a few small differences).

Share this post


Link to post
Share on other sites
Great!
I already began reading the CG Tutorial to be honest. It is a great book in my opinion, I will continue reading it. Thanks all =D!

Share this post


Link to post
Share on other sites
So how do I compile my HLSL and CG shaders and how do I load them into my game?
Can I compile my shaders in Visual Studio?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!