Cg, GLSL, and OpenGL3

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 38

Cg, GLSL, and OpenGL3

Post by Herb »

So, I'm starting to write some pretty involved shaders. I was hoping to use Cg for portability with DirectX and OpenGL, but I heard Cg was no longer being developed by nvidia on their site here. So, what are Ogre devs planning on doing for both open source projects and commercial applications? I heard through some other ogre posts that OpenGL3 support with Ogre should be superior performance on-going compared to DirectX. This makes me think of just bagging Cg and writing everything in GLSL. Any thoughts from the community?
User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 38

Re: Cg, GLSL, and OpenGL3

Post by Herb »

Was hoping for some discussion on this topic...as I can't be the first person to wrestle with it. I guess I was a bit annoyed with hearing the Cg project was abandoned, and not sure on a direction for my new project that I was targeting as cross platform. Thinking about it a bit more my options seem to be:
  • 1. Write in Cg anyways, but might run into unsupported features and will have more issues with that as time goes on
  • 2. Write it in GLSL, but lose DirectX support. I hear OpenGL support (performance-wise) still isn't as good as DirectX on Windows
  • 3. Write it in HLSL, but lose Linux / Mac support. But maybe I could "convert" it to GLSL with what scrawl just posted here... not sure how well that would work
Sounds like OpenGL libraries (which aren't updated well with Windows by default), are typically updated when someone installs their video card drivers. So, maybe GLSL would just be the way to go. As I look for good shader reference material most seem to focus on HLSL :roll: Anyways, anyone with some thoughts, I'd welcome them. I'd stop my rambling now :wink:
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 51

Re: Cg, GLSL, and OpenGL3

Post by madmarx »

I still use it because I don't need the most advanced shaders.
The portability is really useful for me snice I teach, and the students might have problem one day with direct3D or opengl on their systems.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Cg, GLSL, and OpenGL3

Post by areay »

Ah, that's bad news re:Nvidia stopping support. People on these forums have been prophesying its doom for a while though. Take a look at this similar query thread http://www.ogre3d.org/forums/viewtopic.php?f=2&t=80638

The good news is that Cg is almost identical to HLSL so you just (ha just!) need to create GLSL versions of all your shaders and then maintain them too... I think this is what they call shader hell, I shall be joining you :cry:
TheSHEEEP
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 972
Joined: Mon Jun 02, 2008 6:52 pm
Location: Berlin
x 65

Re: Cg, GLSL, and OpenGL3

Post by TheSHEEEP »

Or you write OpenGL from the get-go, as that will allow the same shaders on all platforms (except Windows Phone, and probably slightly modified versions for GL ES if you need other mobile).

That is what we do with our project (desktop only, linux + windows, mac later) and we're pretty happy with it.
My site! - Have a look :)
Also on Twitter - extra fluffy
User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 38

Re: Cg, GLSL, and OpenGL3

Post by Herb »

Okay, sounds like GLSL might be the way to go... Is it fair to say most of the OpenGL drivers on Windows are fairly up-to-date now? Since it appears that OpenGL drivers tend to get updated when you install your video card drivers? I know in the past that was the big issue with OpenGL on the Windows platform.
Tiggilyboo
Gnoblar
Posts: 6
Joined: Sun Jan 05, 2014 4:12 am

Re: Cg, GLSL, and OpenGL3

Post by Tiggilyboo »

I recommend using Shiny, able to write a script once, and have it parse into GLSL/HLSL/CG.
Check it out https://github.com/scrawl/shiny

Quick and easy to setup! :D
NotCamelCase
Greenskin
Posts: 140
Joined: Sun Feb 03, 2013 6:32 pm
x 8

Re: Cg, GLSL, and OpenGL3

Post by NotCamelCase »

Here is a short but nice post on the problem with different approaches. My money is on #4 :D
Check out my projects: https://github.com/NotCamelCase
Post Reply