[ANSWERED] Shader Tutorial Question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
EvilDavo
Posts: 17
Joined: Sun Sep 27, 2009 12:20 pm
Location: Australia

[ANSWERED] Shader Tutorial Question

Post by EvilDavo »

What is .hlsl?
I've searched for it on google, but everyone refers to a directx hlsl file as a .fx file.
So I thought, maybe it's just an .fx file renamed with the extension .hlsl.
Alas, no.
NVidia FX composer doesn't recognise it as a hlsl fx file even with a .fx extension.
Maybe the .hlsl extension was used for older dx shader files?

P.S. Irrlicht does support .fx files right?
Last edited by EvilDavo on Wed Jun 16, 2010 10:27 am, edited 1 time in total.
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

I think .fx is some kind of more complex format that defines things like passes and levels of detail... While HLSL is just the code for the shader. So while Irrlicht supports HLSL I doubt it supports .fx
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

False. Both .hlsl and .fx are just file extensions. The important part is what's inside the file (the shader program you wrote). Irrlicht examples put HLSL shaders in .hlsl files while lots of other things put them in .fx files, but they will get read into Irrlicht the same way. Pick whatever extension you want.

Referring to passes and such, other game engines and FX Composer requires you to add additional things to the file along with the shader program itself, such as "techniques," "passes," and which Shader Model to compile the shaders with. Irrlicht does this for you - you specify the SM to compile with in the code and it takes care of it for you (just look at the shader example). FX Composer also requires you to add some additional descriptive data to your shaders so it knows how to interpret them and what variables to automatically set.

So to answer your question, Irrlicht supports shaders contained in .hlsl, .fx, .wtf, .ftw, .anything, or any other file extension you want to come up with. It only cares about what is in the file, not its name or extension.
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

eh? If we use the definition of ".fx" at the bottom of this doc:
http://msdn.microsoft.com/en-us/library/ms810449
Effects can encapsulate rendering state as well as shaders written in asm or HLSL, including fall-back versions targeted at legacy hardware. A given Effect is generally stored in a single .fx or .fxl file and the file itself can contain multiple versions of the Effect called Techniques
Then it does contain techniques etc much like Ogre's material files. Of course we may rename the extension whatever we like, but it seems to me the common interpretation is that fx file contains more than just the HLSL.

...but maybe I'm getting this wrong, I've only ever used GLSL myself ;)
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Generally .fx files have technique and pass information as well. Just know that for Irrlicht's sake, it doesn't matter.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Post by ACE247 »

Cool, so what youre saying is that we could use .fx shaders in Irrlicht?
EvilDavo
Posts: 17
Joined: Sun Sep 27, 2009 12:20 pm
Location: Australia

Post by EvilDavo »

Thanks for the replies.
slavik262 answered my question very well.

With the extra info FX Composer requires, will it make the shader invalid for Irrlicht? - or will irrlicht successfully ignore them?

(I hope the latter)
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

In my experience so far, Irrlicht successfully compiles shaders even with all the FX Composer markup.
EvilDavo
Posts: 17
Joined: Sun Sep 27, 2009 12:20 pm
Location: Australia

Post by EvilDavo »

cool!
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

slavik262 wrote:In my experience so far, Irrlicht successfully compiles shaders even with all the FX Composer markup.
ohhh really :shock: didn't know that.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

I still just write most of my shaders in notepad because it's a pain to add all the markup in the first place though. :P
Post Reply