Some test with FX Shaders & Irrlicht

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Some test with FX Shaders & Irrlicht

Post by wizardofoz »

Hi all,

I wanted to do some stupid experiment with FX shaders made with FX Composer 2.5 and Irrlicht.

I succeded (through ID3DXEffect) to render some FX shaders with only a little bit of hack.

It is only a stupid example but it works without the need to modify Irrlicht source code:

Code: Select all

... create shader and choose technique...
m_VideoDriver->beginScene(true,true,SColor(255,255,255,0));
... update fx shader parameters ...
FXEffect->Begin(&numPasses,0);
FXEffect->BeginPass(0);
m_SceneManager->drawAll();
FXEffect->EndPass();
FXEffect->End();
m_VideoDriver->getDriver().endScene();
At the moment the only problem I have is that for textures I need this pointer IDirect3DBaseTexture9* from CD3D9Texture of Irrlicht but the interface ITexture obviously doesn't implement it.

There's some way to get that pointer without modify Irrlicht source code?

Thanks :)
Last edited by wizardofoz on Sun Feb 01, 2009 1:53 am, edited 3 times in total.
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Post by wizardofoz »

Here is a velvet.fx shader in Irrlicht:

Image

gooch.fx:

Image

textured blinn.fx

Image

These shaders comes from FX Composer 2.5 and they didn't need any type of modification to work with Irrlicht. With the power of "Semantic" keywords the parameters I had to pass for these shaders are all the same so I could load and show these shaders in 3 minutes..

This opens for me big possibilites: relatively easy multipass, soft shadows, postprocess... all managed by fx files with a little modified Irrlicht version..
Too bad that it's only for DirectX so no portable code...
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Post by wizardofoz »

This shader is made by me in 5 minutes with FXShaders plugin for 3DSMax that now is FREE even for commercial use for groups of not more two people.

On Irrlicht:
Image

It is a blinn shader + texture map + normal map + specular map.

It's all for now..good night!
geckoman
Posts: 143
Joined: Thu Nov 27, 2008 11:05 am
Location: Germany
Contact:

Post by geckoman »

Could you provide a demo-Project? PLEASE :D
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Post by wizardofoz »

Could you provide a demo-Project? PLEASE
I need to think better how to implement this and test it before having anything ready to be shown in a demo.

To use FX shaders effectively I will have to integrate them with source code of irrlicht.

Maybe I should create a new material like "EMT_FXSHADER" but there are many design decision to take:

1) Is drawAll() function sufficiently optimized to handle these shaders ( change of states...etc..) ? I think objects with same fx shader have to be sorted together in order to minimize FXShader->Begin() and FXShader->End() calls..

2) How could ID3DXEffectPool be implemented effectively in order to identify parameters that are going to be shared across all effects? This would automatize all common parameters like world,view,projection matrices, light positions, color diffuse etc....

3) What could be the best way to manage Techniques, Passes (for multi-pass rendering)....

4) If the creation of a new type of material (EMT_FXSHADER) "could" handle object rendering, how FX shaders could be implemented to use them for post-processing? (render targets..etc...)

I've to think a bit about this.. :wink:
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You can just use it like an HLSL shader, since FX is HLSL. To do multipass in Irrlicht just change the material and call ->drawAll() again :P :lol:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Post by wizardofoz »

You can just use it like an HLSL shader, since FX is HLSL
True, but FX format uses HLSL language + SAS script (semantic, per variable annotations, automatic state changes, passes and techniques..)
In order to use it like an HLSL shader wouldn't be necessary to clean out all this code or it would compile strightforward?

I'd like to have a direct pipeline FX Composer/ShaderFX -> Irrlicht that can take advantage from SAS script (automatic load of textures, choose the best supported technique, automatic passed parameters with semantics, sharing common parameters with effect pools...) :)

To do multipass in Irrlicht just change the material and call ->drawAll() again
True again, but this would be useful for a whole scene multi-pass and not for a per-object multi-pass. And using drawAll() multiple times wouldn't be a big waste of state changes and of passed matrices? :wink:

Instead of touching Irrlicht code I thought that I could write a module on top of Irrlicht (so it would be compatible with future versions of Irrlicht)
derivating from Irrlicht classes (ex. CFXMeshSceneNode, CFXSceneManager..) so it would be easy to switch from Irrlicht standard pipeline and FX based pipeline..
xsinick
Posts: 18
Joined: Fri Aug 10, 2007 12:05 am

You are Billiant!

Post by xsinick »

Dude alot of Programmer heads here don't see the use in what you are trying to do .
I for one Like this approach as it is more artist programmer friendly.

It make the engine usable from a visual stan point to have normal&spec maps (gears of war anyone?).

And have .fx working...

What a Dream, you are truly the WIZARD of OZ :)

Just Post the code you already have you'll be surprised how much help or ideas you'll get to optimize and streamline it.

If you need Models with maps for a better demo just PM or email me
nickmind@hotmail.com
Post Reply