Skip to main content
11 events
when toggle format what by license comment
Dec 4, 2013 at 21:26 comment added Nathan Reed @cubrman I'm pretty sure those shader arrays are just syntactic sugar for writing out the techniques explicitly.
Dec 4, 2013 at 8:59 comment added cubrman Ok, at least I know it's the way to go :). One more question: shader arrays, are they as efficient? I mean this: Technique...{... PixelShader = PSArray[SomeParameter];} where PSArray={compile ps_3_0 GoLeft(), compile ps_3_0 GoRight(),};
Dec 4, 2013 at 8:38 comment added Nathan Reed @cubrman Yes, that exponential explosion of techniques is annoying. At my last job we had a system to automatically generate the techniques, given the list of parameters. We only generated the combinations that were actually used by the game (they were selected by artists when creating materials and objects). It helped keep things under control.
Dec 4, 2013 at 8:16 vote accept cubrman
Dec 4, 2013 at 8:16 comment added cubrman I must set your answer as the right one, as even concept3d has agreed with it. As I mentioned in the question, my humble tests showed that it indeed generates different compiled shaders and I have changed my shader code to use this feature already. However, I am still struggling. I now have one big MAIN function that accepts many a uniform parameter and a number of techniques that call MAIN with various combinations of these parameters. The problem is, whenever I need to add another bool parameter, my technique count essentially doubles :). I wonder if there is a way around it?
Dec 1, 2013 at 4:59 comment added concept3d yes I noticed that after I re-read the question. And I think it's is lame that GLSL doesn't have this feature and I have been using #if for a while now and can't say it's cleaner.
Nov 30, 2013 at 23:51 comment added Nathan Reed @concept3d I don't think anyone here is talking about setting uniforms at runtime. If you look at the OP's code, each technique is passing a different, compile-time constant value for the uniform parameter. That causes the compiler to generate two copies of the code, each optimized for its own value of the uniform parameter. It's just like using #ifs, but with nicer syntax.
Nov 30, 2013 at 21:33 comment added concept3d which sounds more like branch prediction to me.
Nov 30, 2013 at 21:25 comment added concept3d but what I want to ask is, dones't the front end compiler have some overhead itself? what I mean is that you pass uniforms after the compilation at least this is the case with openGL? so if that was the case wouldn't it need to kick in the optimization after determining the uniforms value?
Nov 30, 2013 at 20:45 history edited Nathan Reed CC BY-SA 3.0
added 63 characters in body
Nov 30, 2013 at 20:35 history answered Nathan Reed CC BY-SA 3.0