HLSL shader & lighting

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
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

HLSL shader & lighting

Post by genesys »

Hey folks!

I've got a problem... I'm searching the easiest way to light my models that use HLSL shaders.

When I load a HLSL shader for a model, the shading model swaps to constant, means that there is nomore D3DSHADE_GOURAUD shading or any other shading on it.

Of course I can easily program phong or gouraud shading into the HLSL shader itself - but this comes with a big discomfort.
When I calculate the light dependant shading parts in the shader itself, i must KNOW how many lightsources there are in the scene and how they're named, because irrlicht must give the variables that store the light positions or light directions to the shader. So everytime i change the lighting in the scene i must change the shadercode as well - additionally i think it is faster to use D3DSHADE_GOURAUD shading instead of calculating the shadin in the HLSL shader...

so i'd like to use the HLSL shader output as texturecolor, which is then shaded by a irrlicht standardmaterial . . . . or i want to multiply D3DSHADE_GOURAUD shading with the output values of my HLSL shaders . . . or whatever could solve my problem . . .


Thx for the help!
Guest

Post by Guest »

interesting point

the way i would do it is to cheat

i would compile the shader with EMT_solid

and change the emt solid code in the engine code and add this to it

D3DSHADE_GOURAUD

recompile the engine and stuff
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

that was me

btw im sure it would work since the irrlicht materails are added at the end so the shaders wont overwrite the pixel colors of the calculated lighting
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

Post by genesys »

But does EMT_SOLID not contain D3DSHADE_GOURAUD already in the irrlicht flags?
Electron_

Post by Electron_ »

just pass the shader an 8 member array as a uniform parameter
Jan_
Posts: 16
Joined: Wed Sep 28, 2005 11:39 am
Location: Germany, Chemnitz, Bgst.

Post by Jan_ »

You can max. have 8 Lights (without shaders)...
make a array of 8 lights.
Post Reply