Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,574 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
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 Offline
Senior Expert
Quad  Offline
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: Quad] #378968
07/28/11 12:57
07/28/11 12:57
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
No, that would be ugly and probably also not possible without a lot of work, as I am sure that the fx files are parsed directly using directx, where you then can only get the variables and techniques from and choose the technique you want to use from within the fx file.
What I mean is just a material flag like DOUBLE_SIDED or whatever.
On the other hand, there may already are all bits in use and I would like to see a better alternative for setting render states from outside the fx file, as flags would allow to combine the different cullmodes for example, which of course makes no sense.

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
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

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
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: Slin
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 Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Quote:
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
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: Slin
Quote:
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.

Re: Double sided material [Re: HeelX] #378990
07/28/11 14:48
07/28/11 14:48
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
I could set it myself in a material event, that isn´t really a big deal...
And I already have that define stuff as solution for shaders already working of course. Including loading each shader only once and then copying it to the different materials...

Re: Double sided material [Re: Slin] #378998
07/28/11 16:27
07/28/11 16:27
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Then why don't you put a define in the technique for the cull mode?

Re: Double sided material [Re: HeelX] #379000
07/28/11 16:36
07/28/11 16:36
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
That would produce another shader, which I don´t really need.
I anyways just wrote that a material flag for double sided rendering would make sense in my opinion.
I don´t need it at the moment and would find some workaround if I needed it, but then a flag would also be very handy.

Re: Double sided material [Re: Slin] #379007
07/28/11 17:43
07/28/11 17:43
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
shadeC already has this, just uncomment this:

// #define DOUBLEPOLY

and youre good to go, i only mentioned this for the other default shaders, i dont really need this, shadeC also does this with every aspect of its .fx files, from enabling normalmapping to number of lights, or did you mean in realtime? because this method still results in various fx files with different settings.


@QUAD: you cant really say that once someone starts asking for this stuff then they know it because honestly i think applying a shader is one of the first things a newb tries to do in an attempt to see how pretty he can make a scene look and personally even i would find it annoying to have to write that into default shaders

Page 2 of 2 1 2

Moderated by  aztec, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1