• 0

Nvidia Cg Programming (DirectX or OpenGL)


Question

Okay then,

I'm learning to write Pixel Shaders (and possibly Vertex Shaders) v3.0 and I'm torn between two languages...basically which one is easier to learn?

Nvidia's Cg = Cross Platform (Windows, Mac, Linux), DX & OpenGL (But I want to stick to DX 9.0c) and Cross GPU (ATi & Nvidia).

HLSL = Microsofts version which I don't know much about.

I personally think that Nvidia's Cg is the best choice - and I've downloaded all the documentation from their developer website, but...I cannot find any very basic tutorials on how to use this. And because DirectX 9.0 can handle the Shader Model 3.0 - shall I stick to this or use OpenGL, you see I'm torn between them. DX has SM3.0 but I don't think OpenGL 1.4 has this support yet (and yet OpenGL is cross-platform which will please everyone).

I know this is asking a lot of questions (just shows how new I am to field of decisions).

1.) Cg or HLSL?

2.) DirectX or OpenGL?

Let's say your guys think Cg & OpenGL, are there some very basic beginner tutorials out there that can help me to learn shader writing. I want to write shaders for a university final degree project (basically, writing a mod and introducing Pixel Shader 3.0 into this mod for UT2004).

Any help would be greatly appreciated.

P.S.

My hardware: WinXP Pro SP2 / GeForce 6800 GT / AMD64 3500+

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

personally i think CG makes no sense. I've used it and it works, but why dont you use the bultin hlsls, DirectX has HLSL, and OpenGL now basically has a builtin Cg clone, glslang. Cg (in my opinion) has been rendered obselete (its purpose was to make c-like shader language, which both DX and OGL have natively now). It still works, but I personally wouldn't start a new project using it and definitely wouldn't start learning it. My personal choice would be OGL with GLSLlang since OGL is cross platorm and they dont change the API every week :pinch: these tutorials look good: http://www.clockworkcoders.com/oglsl/index.html

Link to comment
Share on other sites

  • 0

And also this is dependant on graphics cards.

DirectX 9.0 (SM3.0) = Nvidia GeForce 6800 Series ONLY

OpenGL 2.0 (SM3.0) = ATi Radeon X800 Series ONLY

I REALLY want the 6800 GT which would point to DirectX 9.0c & HLSL.

So confusing because of all the different opinions (which is to be expected).

Link to comment
Share on other sites

  • 0

First of all OGL does not use SM3.0, it works from a 9500 and up and you can do asm programs on a gf4. Second, no one is forcing you to use SM3.0 you can write directx shaders that work on a radeon 8500! You might want to check your facts. Third, the WHOLE POINT of a high-level shading language is that it not card dependent. For example, Cg, DirectX hlsl, and glSlang all work on my Radeon 9500 Pro with Catalyst 4.8 (new drivers are key for glSlang since its quite new). I dont know what fanboys you are getting your info from :blink: I may be assuming too much, but i think that since you havent decided whether you are going to use DX or OGL you are very far away from using shaders :whistle:

Edited by Goudaman
Link to comment
Share on other sites

  • 0

<DAMN EDIT THING IS BROKEN>

...

Since the Unreal engine, uses renderer plugin dlls in order to use SM3 you HAVE to use DX9.0c and you HAVE to write an entire Unreal rendering backend from scratch since the source is obviously not available. If you somehow find a way of introducing a mod into the rendering engine (almost impossible since unreal uses bytecode for non-core, modable functionality) then you have to think: If you are making a shader mod for UT2K4, it makes no sense to use OGL since UT is a Direct3D game and provides OGL for crossplatform and compatibility reasons (you dont get all the effects in OGL mode). Second you need to decide if you want to use D3D8 or 9...UT2k4 is a DX 8 game with a beta DX 9 render added in a patch so it looks like you would need to use either dx 8 (no sm3) or dx 9 (not 9.0c, you have to use the same version the engine uses, the apis are different so again no sm3 since UT came out before that existed). In fact, the above is just a guess from my knowledge gained from modding since you need to be an offical Unreal Engine liscensee to even access related info on the UDE Again, sorry to risk sounding like a troll, but have you actually thought this out? :pinch:

SHORT VERSION: My UT modding experience tells me this is impossible but i may be wrong since all the info is only for Unreal Engine licensees (which for all i know you may be). I would try half-life 1, i have seen user made rendering plugins (glow and stuff) and i think the source for the client rendering dll is available from collective.valve-erc.com

Edited by Goudaman
Link to comment
Share on other sites

  • 0

You misunderstood me. The only person who is forcing me to write SM3.0 is...me. I 'want' to learn it.

I've decided to go for DirectX 9 & HLSL, In preperation for XNA :)

Have I thought this out?

That's the whole point of this post, for me to learn from the experts (you guys). I can see where you're coming from and I now understand more than I did yesterday in this area (I've even saved your replies into a text file for future reference and learning). From what I have learnt this entire subject is very difficult, but my motivation is keeping me from quiting.

I'm going to start looking into those beta DX9 plugins you mentioned, I remember activating them a while back so I'll look into that too.

Thanks again.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.