Re: High Level Shading & Gaming Industry

Date : Wed, 25 Oct 2006 09:23:04 -0500
To : 3DGames(at)Softimage.COM
From : "Andi \"Debug\" Ireland" <debug(at)neverborn.net>
Subject : Re: High Level Shading & Gaming Industry
Hi again Guy

I will focus on the what i perceive to be your best choice then

Cg for DirectX* is also somewhat different to implement in code than Cg for OpenGL and can add to development time but said and done this was the way i went on another project and it was not a memorably sore experience it worked pretty good after all the weird API differences where ironed out as the Cg library exposes a different API for each driver.

The Cg library works in some fashion on Mesa, OpenGL & DirectX although note that it is a work in progress even Cg bleeding edge builds do not cover every single feature available support is being continually added, that in mind if you do not need any weird obscure non-standard power in your shaders Cg is probably the way to go.

SM 3.0 and GLSL profiles have only just been added to the current beta builds of Cg the previous version covered up to SM 2.x and ARB_ and NV_ extensions

So you will probably need to be on the bleeding edge builds of Cg which as i am sure you are aware can have drawbacks in bugs and breaking changes

Hope this helps you.

Andi "Debug" Ireland


Guy Rabiller wrote:

Hi Andi,

thanks for sharing your experience, it is very helpfull yes.

What I have in mind is more an open framework able to "host" several APIs rather than to create an abstract level with different underneath implementations.

When you have a common renderer interface then it is quite a standard way to create several implementation of this interface according to the API ( through plugin dll for instance ). Then the assets ( compressed textures, high level shaders, etc..) have to find a way to go through the engine up to the driver.

I'm not looking to implement the less common denominator, but more a clean way to easily "switch" from one API to another if the need arise.
My concern about supporting Cg and HLSL or not is more for lessen the need to create multiple implementations of the same things, or more in "where do I start".


Cg is appealing because of the support of both DirectX and OpenGL. The engine I have in mind will not be only for games but also for previz and machinimas, so
OpenGL is mandatory in my case ( previz on linux for instance ). Ultimately the only real issue seems to be regarding gaming consoles, and from your and Wessam point of view it seems to be best practice to handle this as a "port" to those console if the need arise.


Out of curiosity, do you know if there are still companies selling games for PC platforms using OpenGL only ?

--
guy rabiller | 3d technical director (at) LaMaison




Andi "Debug" Ireland a écrit :
Hi Guy... LTNS

I have been writing a game engine for over 2 years now, and worked on NeL ( www.nevrax.org ) for over 4 years improving the engine for Nevrax for educational purposes.

I have taken up the insane task of platform independent code in my engine personally I went with an abstract shader system on top of an abstract API driver system that tries to support everything each API and thus each language can achieve at the core with a profile system similar to Cg, since it is an engine it itself supports Cg, and the API dependent high languages and assembler versions.

It is horrific I can assure you, the only reason I went this way was self education the convoluted ambiguous mess you end up with providing support for so many shader types is more like torture than fun.

I agree with what was said earlier commercial games either are made for one target platform thus one shader language then they do a port if it succeeds or have multiple teams each working on a different target platforms, sometimes they have an engine with abstracted drivers and all teams improve the engine code base and their platform drivers.

Here Occam's razor is in full effect the simple solution is in my eyes the best solution pick an API and either High level or low level shading languages for that API and platform.

If you want an interesting conversation with lots of fun people in the Indie games industry I recommend #flipcode on irc.enterthegame.net I hang out there often and they are sure to have some valid input on your question

Hope this ramble helps

Andi "Debug" Ireland


Wessam Bahnassi wrote:
Honestly, all this multi-platform thing is totally dependent on the
company's policy. I think casual games have more tendency to support
multiple platforms because their problems are usually easily-manageable. But
larger titles concentrate on the market with the biggest numbers, and they
ship to other platforms as well if the title becomes a top-seller.


Realistically, even if a title is to be launched on targets that use D3D and
OGL, it's hard to share shaders across platforms mainly because of the huge
hardware differences. Advanced features vary a lot between platforms, and it
would be a shame to lose all that for a common-denominator solution that
allows you to write a shader once and reuse on multiple platforms. From a 3D
engine design POV, it's much better to abstract shaders into a higher-level
interface that allows artists specify a "material" for an object rather than
directly specify shader-code. The engineers would then be free to implement
the material in the most optimized way for each platform. In that sense, you
might actually end up mixing Cg and HLSL and GLSL or even a
company-proprietary language for a single project. And personally I wouldn't
consider that a bad design...


Does this answer your question? :)
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
--
In|Structurez Arabic Gamedev Community
www.instructurez.com

-----Original Message-----
From: owner-3dgames(at)Softimage.COM [mailto:owner-3dgames(at)Softimage.COM] On
Behalf Of Guy Rabiller
Sent: Friday, October 20, 2006 9:36 AM
To: 3DGames(at)Softimage.COM
Subject: Re: High Level Shading & Gaming Industry



Thanks for your input Wessam.


> ../.. Cross-platform support? For what? Linux? FreeBSD? > These are not OSs that gamers use ../..

What about the Mac ?


But, lets say that both support for DirectX and OpenGL is needed. From your <personal>opinion</personal> would it be preferable to only support Cg or only HLSL/GLSL ?

--
guy rabiller | 3d technical director (at) LaMaison



Wessam Bahnassi a écrit :
HLSL is well-integrated within the DirectX SDK and is very easy to use
and
integrate out of the box. If the game (or even the whole company) is not
going to use OpenGL, then why bother with Cg? And thanks to the Xbox,
your
HLSL code can be easily ported to Xbox and 360, whereas Cg doesn't
compile
for these targets...

<personal opinion>
Well, asking about whether to choose Cg or HLSL is similar to asking
whether
to use OpenGL or Direct3D. As you know, most PC game titles today use
Direct3D as a 3D API.

Now, from a 3D Engine developer point-of-view, it's a big waste of time
to
support both D3D and OGL. Cross-platform support? For what? Linux?
FreeBSD?
These are not OSs that gamers use. But Xbox, and Xbox360 (which are D3D-
only
based) are widely distributed. PS2 and PS3 do not use OGL as their
graphics
API so the engine will still have to support these in a different code
path
anyways whether it supports OGL or not...
</personal opinion>

Performance-wise, one might argue that Cg delivers better performance on
nVidia hardware because the compiler knows exactly what's running
beneath
it. This fact will mostly change with D3D10 now as the compilation of
HLSL
will be moved to the driver itself, which means nVidia ca provide the
same
optimization capabilities as they do with the Cg compiler (unless if
they
intentionally don't want to :)

Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
--
In|Structurez Arabic Gamedev Community
www.instructurez.com


-----Original Message-----
From: owner-3dgames(at)Softimage.COM [mailto:owner-3dgames(at)Softimage.COM]
On
Behalf Of Guy Rabiller
Sent: Friday, October 20, 2006 3:22 AM
To: 3DGames(at)Softimage.COM
Subject: High Level Shading & Gaming Industry

Hi,

I'm trying to gather usefull informations about high level shading
habits and usages in the gaming industry.

So far, and afaik, there are HLSL, GLSL & Cg among the most used high
level shading languages available.


I've seen that most engines are trying to support all of these, some
only support one.

The kind of questions I have in mind is for instance:

What the point of supporting HLSL & GLSL if Cg is able to handle both
OpenGL and DirectX ?


Do you think it would be reasonable to only support Cg ? Are there any
strong reasons why an engine should support Cg and HLSL for instance ?


I'm thinking about one: Gaming Console ( especialy XBox for instance
where HLSL is mandatory, afaik ).

But outside the gaming console world, would there be any reason at all
?
Performance may be ?

What are your thoughts/informations about this matter ?

Thanks in advance for any hint.

--
guy rabiller | 3d technical director (at) LaMaison



---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe 3dgames





---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe 3dgames


Search the 3D Games List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.