Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / More info on FX system

Author
Message
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 29th Jul 2003 05:31
I had tried U5, I like the new FX system. It makes shader programming a whole lot easier. But I don't know where can I find more info about this? The syntax looks quite simillar to the low level shader commands and Cg shader. I am wondering whether those syntax in the .FX file are proprietary language to DBpro, or it is somewhat smillar to the DirectX HLSL and NVidia FX files? If it is that case, then maybe I can look thru MSDN help or NVidia developer website. I just wanna learn more about how to write those .FX files!
Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 29th Jul 2003 07:23
.fx is actually DirectX HLSL
.cg is nVidia Cg/CgFX

all you need is the DirectX help file, on the syntax.
its a pretty simple language - but you need to understand C first.
i'll show you an example.

asm


.fx


both are just very basic Wave routines for ocean style water ... the FX you have to do alot by hand because it doesn't have the premade instructions of the asm.

however you can get around this with the command
asm = ps_1_1{ tex0 t0; tex1 t1; mov t1,t0; }

it's a pretty simple affair really

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 29th Jul 2003 07:38
Hmm... the second code snippers look like Cg to me. But I think the difference is that in HLSL, you can declare the world and projection matrices and even lights direction inside the .FX files itself, whereas Cg need these matrices to be passed from external language via parameters.

Am I right about this?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 29th Jul 2003 07:43
Cg works slightly differently... not enough to notice, but enough for it to bugger up your code if not done right.
yeah HLSL you can declare everything within the code itself, makes it really a self inclusive format - but personally i find it extremely confusing to know howto use it.

i prefer to use Cg, unforunately it isn't supported ... maybe next update eh

Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 29th Jul 2003 12:43
@Bulleyes

"Hmm... the second code snippers look like Cg to me."

That would be because Cg and HLSL are near identical.

" But I think the difference is that in HLSL, you can declare the world and projection matrices and even lights direction inside the .FX files itself, whereas Cg need these matrices to be passed from external language via parameters.

Am I right about this?"

No, not quite. The difference between Cg and HLSL is that Cg supports the fixed data type; a data type exculsive to Nvidia GPUs. Other than that they are fully compatiable.
http://developer.nvidia.com/object/cg_faq.html
Quote: "Who maintains the Cg Language Specification?
NVIDIA maintains the Cg Language Specification and will continue to work with Microsoft to maintain compatibility with the DirectX High Level Shading Language (HLSL).

"

Quote: "How does it compare to Microsoft HLSL?
The Cg Language Specification is compatible with Microsoft's High Level Shading Language. Cg shaders follow the standard set by Microsoft's latest D3DX Effects format and are also fullycompatible with Microsoft's HLSL.

"

You can declare constants in a Cg shader if you want too.

As for the .fx file format, its just that, a file format. It is not HLSL. HLSL is a language for GPUs. The .fx file format is merely a conveinent container for HLSL and/or asm shaders. Specs on it can be found at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndxgen/html/directx9devfaq.asp
I hope this helps to clarify things.

Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 29th Jul 2003 14:07 Edited at: 29th Jul 2003 16:08
NVIDIA FX DO work - Lee has said this. (.FX files though, .cg files don't work I believe. CgFX is OK though)

According to Lee, the only significant difference between the two as far as his FX system was concerned, is that one requires transposed matrix data (SET EFFECT TRANSPOSE), the other does not. (Sorry, I'm not sure exactly what that means)

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 29th Jul 2003 15:30
Rob transposing is just copying the buffered data onto the projection surface ... essentially similar to the Sync command

Lee has also said that the globals are fixxed.
I'd have more faith in this, if when i tried a CgFX .cg on my GeForceFX machine that it actually ran it rather than crashing DirectX. (not that i thought it would work though)

CgFX & Cg are identical... all CgFX is, are the nv3x Extensions to the Cg language.
Although Cg is compatible (keyword here & in all the documentation) with HLSL's .fx format - they do have to be altered prior to use.

Cg has over 120 extra registered instructions than HLSL
CgFX has an addition 45 extra registered instructions and registers than Cg.

if you don't use the Cg/CgFX libraries when you run these then they just won't work - end of story.
ofcourse they'll work if you convert to asm .psh/.vsh/.nvv or hlsl .fx ... but they won't work natively.

and this is what seems to illude most people in they thing of Cg and CgFX. yes they are compatible, just like C is compatible in C++
but that is the keyword in all of this, they are not identical and if you start using the language specifics of Cg, then you MUST precompile it to a valid format for DirectX9 unless you use the Cg interface.

have fun trawling through documentation and feel free to argue against this ... but considering i've spent the past year and a half learning about Shaders and i've spent the past 4months developing an exclusively CgFX engine in DirectX9 i can tell you exactly what it is and is not capable of.

just try using the command dp3( ) ... in you .fx files and see how compatible it believes they are then.
my example has a dp4 remade because .fx DOES NOT support it - but .cg DOES!

compatibility doesn't ever mean "will work 100% of the time and identically" in software programming. i mean fgs we're talking about Microsoft and nVidia ... wake up people - these guys are hardly reknown for thier software compatibility.

Oryaaaaa
23
Years of Service
User Offline
Joined: 20th Mar 2003
Location: Aichi-ken, Japan
Posted: 30th Jul 2003 07:23
Hi.

...ATI RenderMonkey ...It can use at last now!

Although the study of a shader program is Japanese, it can be studied to the site most famous for Japan.
http://www.t-pot.com/

Although it is VC++, since it is DirectX HLSL, I think that you can understand with source.

cheer

DarkBasicProfessional is wonderful.
Oryaaaaa
23
Years of Service
User Offline
Joined: 20th Mar 2003
Location: Aichi-ken, Japan
Posted: 30th Jul 2003 07:28
Addition!

It is introduction of the site translated into English from Japanese.
http://www.excite.co.jp/world/text/
http://www.excite.co.jp/world/url/



DarkBasicProfessional is wonderful.
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 30th Jul 2003 13:05
@Raven

"Rob transposing is just copying the buffered data onto the projection surface ... essentially similar to the Sync command"

Wrong again, Raven. Transposing a matrix means to flip it diagonally like so:
Orginal Matrix:


Transposed Matrix:


"CgFX & Cg are identical... all CgFX is, are the nv3x Extensions to the Cg language."

I take it from your silence on the HLSL being identical to .FX issue you are tacitly admitting that I was right.

Anyway, when I first read this my jaw nearly dropped to the floor. Anyone, and I mean ANYONE who was even briefly familiar with CgFX and knew what it was could not possiably believe this.

CgFX is a file format for Cg shaders akin to the .fx file format for HLSL. In fact, they are identical.

Here is the very first paragraph of a document titled "CgFX_Overview" found in the Cg sdk:
Quote: "
WHAT IS CGFX?

CgFx is a powerful and versatile shader specification and interchange format. As a file format, it is identical(emphasis mine) to microsoft's .fx Effect format for Directx 9."

"Although Cg is compatible (keyword here & in all the documentation) with HLSL's .fx format - they do have to be altered prior to use."

Read the above quote.

"Cg has over 120 extra registered instructions than HLSL"

Yeah. Right. I'll believe that when I see it. Why don't you post one of these extra registered instructions. Or better yet, tell us what your source for all of this info is. Oh wait, I forgot. Backing up your outrageous claims with even a little bit of evidence isn't your "stlye."

"CgFX has an addition 45 extra registered instructions and registers than Cg"

CgFX isn't a programming language Raven. It can't have instructions and registers.

"if you don't use the Cg/CgFX libraries when you run these then they just won't work - end of story."

Yes, actually they will. Barring any use of the fixed data type, Cg is basically identical in terms of syntax to HLSL. Ergo, if you can use HLSL without the Cg/CgFX libraries then you can use Cg without them as well. Same applies for CgFX. (Note: what I mean when I say you can use them without the Cg/CgFX libraries I'm implying that you use the HLSL/.fx compiler instead.)

"ofcourse they'll work if you convert to asm .psh/.vsh/.nvv or hlsl .fx ... but they won't work natively."

All shaders have to be converted to asm eventually Raven. I thought we went through this before. And, what the hell do you mean by natively? You're not seriously suggesting that you can just throw a Cg text file at a GPU and it will understand it are you?

"and this is what seems to illude most people in they thing of Cg and CgFX. yes they are compatible, just like C is compatible in C++"

I still don't get why you started ranting on and on about CgFX when no one has even mentioned it yet. Is this just your lame attempt at drawing attention away from the fact that .fx and HLSL aren't the same and that you were wrong about that?

"but that is the keyword in all of this, they are not identical and if you start using the language specifics of Cg, then you MUST precompile it to a valid format for DirectX9 unless you use the Cg interface."

This one actually brought a simle to my face. You are, for once, completely correct and in line with what I've been saying all along.

"have fun trawling through documentation "

More like glancing through the documentation. It really isn't hard to disprove you Raven.

"and feel free to argue against this "



"... but considering i've spent the past year and a half learning about Shaders and i've spent the past 4months developing an exclusively CgFX engine in DirectX9 i can tell you exactly what it is and is not capable of."

Tell me, yes. Be correct, no. I'd suggest that you have a look again at the documentation. Oh, and 4 months is an awfully long time to spend just to get the limited advantage of using the fixed data type. The real advantage of Cg is in cross-platform compatiablity and if you are limiting yourself to DirectX 9 you may as well just save yourself the trouble and stick with HLSL/.fx.

"just try using the command dp3( ) ... in you .fx files and see how compatible it believes they are then.
my example has a dp4 remade because .fx DOES NOT support it - but .cg DOES!"

Sorry Raven but there is no such command in Cg or HLSL. There is a dot command which is in both languages and does what you want but there is no dp3/dp4(is that a typo?)() command. I think your getting your assembly confused with your Cg/HLSL.

"compatibility doesn't ever mean "will work 100% of the time and identically" in software programming."

Correct, though neither I, nor any one else in this thread have claimed such.

"i mean fgs we're talking about Microsoft and nVidia ... wake up people - these guys are hardly reknown for thier software compatibility."

True, but whether they are reknowned or not for their software compatiablity is irrevelevent to whether the software in question is actually compatiable or not. Microsoft and Nvidia have had products that were compatiable before.

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 31st Jul 2003 12:17
Thanks for your clear explanation, Neophyte!
Anyway, thanks to Raven too!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Oryaaaaa
23
Years of Service
User Offline
Joined: 20th Mar 2003
Location: Aichi-ken, Japan
Posted: 1st Aug 2003 11:54
It is opinion exchange about Cg=HLSL.
I translation mistake.

now

I bought "The Cg Tutorial for Japanese".

thanks

I am creating MS HTML HELP of DBPro. If it is completed, translation in other languages will become easy. Don't you participate in this project, either?

Login to post a reply

Server time is: 2026-07-23 13:42:46
Your offset time is: 2026-07-23 13:42:46