Nvidia’s CG Toolkit

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Nvidia’s CG Toolkit

Post by sirherrbatka »

Since registration at the forum is apparently not possible atm (?), I am writing this here in hope to be heard by the developers.

I read you are going to depend on Nvidia’s CG Toolkit. That is extremely unfortunate in various ways:
1. It will make it impossible to include OpenMW in any distribution that has a only-Free-Software policy, since CG is proprietary.
2. OpenMW will be restricted to platforms supported by Nvidia. One nice thing about open source is portability: While you are at the moment only targeting Windows, Mac OS and Linux, the game will also run on *BSD (I even created an OpenBSD port with little effort). Depending on CG will lock out these operating systems completely.

It contradicts the goal of creating an ‘open’ Morrowind implementation by relying on proprietary technology. So please, please, please, try to use another language (GLSL?) for shader support.
We had this comment from pascal and since it's important matter I decided to start topic now.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Nvidia’s CG Toolkit

Post by Zini »

Pretty much out of question. It would mean that we would have to write all shaders twice (once in GSLS and once in HLSL). Or drop DirectX support. Neither looks like a viable option.
User avatar
psi29a
Posts: 5361
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Nvidia’s CG Toolkit

Post by psi29a »

I agree with Zini, it would just hobble development. If someone wants to take the time to support *BSD, they should sign up here and get to work. :)

It is a shame that Nvidia does not release the toolkit for *BSD.

@Zini: Why is keeping directX support important?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Nvidia’s CG Toolkit

Post by Zini »

Quality of OpenGL drivers varies. A lot. People using Linux for high-end graphics purpose are probably smart enough to pick vendors/cards that have decent drivers. Obviously Windows user have limited motivation to do the same.
User avatar
WeirdSexy
Posts: 611
Joined: 15 Sep 2011, 18:50
Location: USA

Re: Nvidia’s CG Toolkit

Post by WeirdSexy »

So you guys are using Nvidia's CG Toolkit?

I don't really know what it does, but CG is a shader language like GSLS and HLSL? By using CG, it allows you to write the shaders once and have support for both OpenGL and Direct3d?

How exactly does this Nvidia tech talk to the hardware?
When you compile the CG shader code it translates it into both Direct3d and openGL machine code or something? Is there a performance hit in using it as opposed to writing the shaders directly in GSLS or HLSL? How does it make running on a platform where OpenGL support would otherwise be questionable any better?

I'm sure I'm completely missing something, but the general idea is that OpenGL support varies across platforms w/ different hardware so you can't rely on that, and Direct3d is only on windows, so you can't rely on that. Correct?

Sorry for the all the questions, I don't expect anyone to take the time to answer them heh. I just wasn't aware this issue even existed and don't understand all of it.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Nvidia’s CG Toolkit

Post by Zini »

I don't really know what it does, but CG is a shader language like GSLS and HLSL? By using CG, it allows you to write the shaders once and have support for both OpenGL and Direct3d?
Exactly.
How exactly does this Nvidia tech talk to the hardware?
When you compile the CG shader code it translates it into both Direct3d and openGL machine code or something?
Don't know. Don't care. It works, therefore the internals are of little interest to me.
Is there a performance hit in using it as opposed to writing the shaders directly in GSLS or HLSL?
Normally, that is not the case.
How does it make running on a platform where OpenGL support would otherwise be questionable any better?
When you have DirectX available, you can use that instead.
I'm sure I'm completely missing something, but the general idea is that OpenGL support varies across platforms w/ different hardware so you can't rely on that, and Direct3d is only on windows, so you can't rely on that. Correct?
For Windows you can't rely on OpenGL, because the support varies depending on the hardware vendor. ATI for example was known to produce junk OpenGL driver for a long time. Apparently it got a bit better, but I still wouldn't trust it.

For Linux/OS X, DirectX is not available, so you have to use OpenGL. But if you buy a Linux box and intend to use it for high end graphics, you usually make sure, to choose graphics hardware that comes with good OpenGL drivers.
User avatar
WeirdSexy
Posts: 611
Joined: 15 Sep 2011, 18:50
Location: USA

Re: Nvidia’s CG Toolkit

Post by WeirdSexy »

Zini, thanks for the reply.

I have an ATI card, the driver support for under linux has been iffy in the past, but yes it has gotten better. I've played several 3d games under archlinux with good results. I never knew there were OpenGL issues with Nvidia or ATI under windows (I'm assuming we are not talking about people with integrated graphics from other chipset manufacturers, don't know how many of them will be playing openmw).

Nvidia's page doesn't give much information, I'm going to do some digging elsewhere to find out more about how cg works. Sounds interesting.
User avatar
pvdk
Posts: 528
Joined: 12 Aug 2011, 16:34

Re: Nvidia’s CG Toolkit

Post by pvdk »

There's hope for the people running only-Free-software systems, as Nvidia released the Cg compiler code under a non-restrictive open-source licence back in 2002. I don't know if this code is actually useful but in the long run when people decide to write an open-source Cg shader plugin it might help. Again, I don't know how shader support works exactly, if it doesn't make sense please disregard it.

EDIT: Question: how hard would it be to include both HLSL and GLSL code in OpenMW, as I understand Cg basically compiles the Cg shader code into the API-specific language and then provides a wrapper around it. You can manually compile the shaders with the cg compiler, so there is no need to write all the HLSL/GLSL code by hand. Wouldn't that make it possible to write the code in Cg and then compile it to both HLSL and GLSL and use that code in OpenMW instead?

EDIT 2: Here's an example of the Moon_FP shader in sky.cpp converted to a GLSL shader using cgc.
corristo
Posts: 495
Joined: 12 Aug 2011, 08:29

Re: Nvidia’s CG Toolkit

Post by corristo »

Isn't Ogre internally relying on CG? For example for terrain material generator shaders?
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Nvidia’s CG Toolkit

Post by ezzetabi »

I am confused by the matter. If you use only free software you cannot play Morrowind in the first place. And you cannot play an eventually modified OpenMW with the removed offending pieces because the Morrowind data files are not free (nor libre, nor gratis).

So, the request is only for free (libre) Total Conversion? It exists at least one? Even most mods are not free (libre). (Off topic: this last point always bothered me. planet elder scroll should refuse non free stuff!)

About DirectX; I am not sure why support Windows at all... All the support of the Morrowind community is for windows-only already! There is plenty of choice of Windows users.
For example, the graphics extender is written in C# and works altering GDI32.dll.GdiEntry1 that is not in Wine.
Post Reply