0 registered members (),
16,232
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Double sided material
[Re: Slin]
#378967
07/28/11 12:37
07/28/11 12:37
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
It makes sense in this case, if you are going use same shader both single and double sided. they could add an "ALTERNATIVE" flag, that uses the render states that are startihng with altarnate_
3333333333
|
|
|
Re: Double sided material
[Re: Slin]
#378978
07/28/11 13:38
07/28/11 13:38
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
@Slin, you could have both techniques in the same .fx file and set different techniques in different materials (although that's not exactly convenient, either). The online manual doesn't seem to have it, but look up "technique" in your manual.
I agree that it'd be nice to have means of setting render states outside the fx file as long as the technique itself doesn't set those states. DOUBLE_SIDED is one of those that just makes sense.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Double sided material
[Re: Slin]
#378981
07/28/11 14:03
07/28/11 14:03
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
otherwise I would always need two different shaders for double and single sided stuff That is the way it is - regarding most shader permutation issues. I have the same problems here, like object shaders with have to support some stuff if a certain flag is set or not. My solution is for now and forever: - mask out the optional shader parts with #define's
- implement a structure that holds all shader permutations
- write a generic shader compiler function, that can get a char* for the fx file and a string as define-list parameter and put it together (define list before shader text) and compile it
- write a special function, that loads the structure with teh shaders through different calls for the shader compiler to generate all needed permutations
- write a function, that returns a MATERIAL* and gets an entity or soem arguments or whatever, which selects the appropriate shader
This way you generate all necessary shaders, whereas each shader has zero overhead, because unnecessary stuff has been "compiled out". The function then encapsulates arbitrary logic for what shader to use in which circumstance. This way, you can e.g. redefine flag1 as doublesided material and then select the double-sided permutation of your e.g. object shader. The downside is that you have to maintain several things and that shader loading time increases by the amount of permutations, but the benefits are extremely optimized shaders and dynamically loadable shaders (you could bake in constants, useful for unrolling arbitrary loops, which amount is defined during runtime, like blur samples in DOF shaders or so...).
|
|
|
Re: Double sided material
[Re: HeelX]
#378988
07/28/11 14:43
07/28/11 14:43
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
That is the way it is - regarding most shader permutation issues. The point is, that a render state is no shader permutation as it has nothing to do with the shader.
|
|
|
Re: Double sided material
[Re: Slin]
#378989
07/28/11 14:45
07/28/11 14:45
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
That is the way it is - regarding most shader permutation issues. The point is, that a render state is no shader permutation as it has nothing to do with the shader. Yeah, but as for the moment you don't have a flag for that and JCL refuses to add that.
|
|
|
|