Multiple Lights [HLSL][Direct3D9]

Started by
13 comments, last by leet bix 14 years, 12 months ago
Personally I use 3 different techniques in one effect file. And then I have different effect files. For example one for normal mapping, another one for normal/parallax mapping and so on. In my opinion it makes it easier to structure.
Advertisement
Hi,

Quote:So I have say 3 different effects, Directional light, point light and spot light, should I have 3 different effect files, or 3 different techniques within a single effect file?


Whatever you want :)
* You can write a .fxh file and declare your shader variables/data types in it, then write seperate .fx files (for each light equation/type) that use this .fxh file with #include lines.

* Or, you can write a single .fx file, seperate shaders (for each light equation/type) and seperate techniques in it (maybe one technique, seperate "passes").

* Or, you can write a single .fx file, single technique and single shader in it. How can you manage your code with light type? You can use "if" statemens:
...if (light_type == LIGHT_DIR){...}if (light_type == LIGHT_SPOT){...}if (light_type == LIGHT_POINT){...}


Hope this helps.
There's no "hard", and "the impossible" takes just a little time.
I was thinking more along the lines of what is fastest, it's cheaper to change techniques rather than effects isn't it?
I would suppose you are right. That's what I think at least, as you still can use all the constants you uploaded.
That's what I was thinking, also, you may have the same vertex shader for all of them and you just compile that in each of the techniques, then, things like the matrices only need to be passed in regardless of how many lights or differnet types of lights are being used.

This topic is closed to new replies.

Advertisement