Page 1 of 1

How much is Cg ingrained into SR? [not since ver 2.1]

PostPosted: 16 Jun 2013, 05:42
by Wuzzy
Stunt Rally uses a plugin of OGRE called “CgProgramManager”. This plugin is itself free software. But its only purpose is to interface the Cg Toolkit from NVIDIA which is a BLOB, a piece of non-free software, closed source, locked-down, propritiary, however you want to call that. So if you do not have this BLOB installed, the CgProgramManager is useless. :(

Now I want to ask: How much does Stunt Rally depend on Cg? Could Stunt Rally do without it? Could something replace it and how hard would that be? And especially: Could I build a working Stunt Rally without the NVIDIA Cg toolkit?

For those who don’t know: Cg is a shader language by NVIDIA. The problem with Cg is that AFAIK there is currently not any free software around which “speaks” Cg natively; the only useful tools come from NVIDIA and these are BLOBs, pieces of non-free … you get the idea. ;)

Re: How much is Cg ingrained into Stunt Rally?

PostPosted: 16 Jun 2013, 08:51
by CryHam
Yes. We already wanted to deal with this (and still do).
We are using shiny material generator which is awesome, main game materials are done with it.
But there are some shaders still written in cg. Just do a search for *.cg in data/
Main big part of them are all effects, all RTShaderLib shaders (no idea). Somebody had to rewrite them to shiny. This is difficult IMO. Rest are few my shaders which I can handle.

Re: How much is Cg ingrained into Stunt Rally?

PostPosted: 16 Jun 2013, 22:09
by Wuzzy
I am glad that you at least try to move away from Cg. :)

Re: How much is Cg ingrained into Stunt Rally?

PostPosted: 22 Jun 2013, 20:36
by scrawl
git master @ daf599d1018e224a7b8f10dca31575dd084c726f - bye bye CG. ;)

Re: How much is Cg ingrained into Stunt Rally?

PostPosted: 22 Jun 2013, 21:59
by charlie
scrawl {l Wrote}:git master @ daf599d1018e224a7b8f10dca31575dd084c726f - bye bye CG. ;)

*cheer* :D

Re: How much is Cg ingrained into Stunt Rally?

PostPosted: 23 Jun 2013, 03:47
by Wuzzy
I did not expect that Cg gets ditched so fast. Good work! I tested it, Stunt Rally now really compiles and without the Cg Toolkit. Thanks a lot. :)

But the commits read like as if Cg just got replaced by HLSL. HLSL is another propritiary shader language, this time it’s from Microsoft. HLSL is only useful if one has DirectX installed, which is propritiary software. For GNU/Linux users these shaders are completely worthless. So this decision seems a little bit strange to me. Funnily enough, the new code doesn’t seem to generate any hard dependency; I am still able to compile and run Stunt Rally without having any Microsoft software whatsoever installed. And I see shadows. This is a good thing.

So I want to ask some more questions, just for clarity:
  • After the dependencies on the OGRE plugin “CgProgramManager” and the Cg Toolkit have been removed, is Stunt Rally BLOB-free now?
  • Why does Stunt Rally work for me, altough I do not have anything installed which is DirectX-related?
  • And why (in contrast) did I need a propritiary software as long as the Cg shaders were inside?

Re: How much is Cg ingrained into Stunt Rally?

PostPosted: 23 Jun 2013, 07:23
by CryHam
This is how it works:
1. We are using OGRE, in OGRE you can choose which render system to use (based on OpenGL or DirectX)
2. On Linux OpenGL is used, on Windows DirectX
3. Windows comes with DirectX already installed, (the SR windows installer.exe installs a DirectX redistributable, which is just the most common thing, it includes dx compiler and d3dx9 (stuff from DirectX SDK))
4. You could choose GL on Windows too, some time ago (now it's broken) and it showed that DX gives about 15% more fps than GL (so it's not needed to fix it)
5. We have shaders, most of the crucial game shaders are written in shiny (.shader) which translates them to either hlsl or glsl (you need to use hlsl for DirectX, and glsl for OpenGL, see 2.). The rest is now written both in glsl and hlsl.

So, cg got replaced by glsl for GL and hlsl for DX (cg and hlsl syntax is I think compatible, we didn't change file extensions).
As for you questions:
1. I think yes. By BLOB you mean this ?
2. On Linux SR uses GL and glsl only (and completely nothing from Microsoft is needed).
3. Long time ago :D when cg was used you needed it to compile the cg shaders, but that's history.
Hope this clears a bit, I really don't know what do you mean, still after cg.

Q: How much is Cg ingrained into SR? A: Not at all anymore!

PostPosted: 23 Jun 2013, 11:00
by Wuzzy
Okay, thanks for the answers. :)

And before I forget: Good riddance, Cg. :D