GLSL is only supported by OpenGL 2.0 and HLSL is only supported by DirectX. If you plan to use both, you will have to write shaders in both languages and code the proper backend as well (code to upload uniforms, matrices, textures, vertex attributes, etc.)
Cg might be a better option for you here. Cg has a concept of "profiles". You write your code in Cg, then you instruct the compiler to produce assembly code for a particular profile. But this is when it becomes complicated: Both DX and OpenGL have very different profiles AND both nVidia and ATI have different profiles as well. Working with Cg can quickly become your video-card compatibility enemy, especially if you use relatively advanced features such as conditional branching, texture lookups in loops, etc.
In the perfect world, we'd all be using GLSL.
Simple,
elegant,
free access to the entire OpenGL state machine so far less uniforms are required.
Implemented in the driver
Fully cross-plateform.
Hallelujah.
Dominic
-----Original Message-----
From: owner-3dgames(at)Softimage.COM [mailto:owner-3dgames(at)Softimage.COM] On Behalf Of Guy Rabiller
Sent: October 20, 2006 12:36 PM
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
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe 3dgames