Skip to main content
10 events
when toggle format what by license comment
Jun 12, 2013 at 22:55 history tweeted twitter.com/#!/StackGameDev/status/344951009044480000
Jun 12, 2013 at 17:28 answer added Sean Middleditch timeline score: 9
Jun 12, 2013 at 17:26 comment added DampeS8N Not adding this as an answer because this is only a hunch. But it would probably be best to swap shaders if what effect being applied isn't determined by the pixel/vertex itself. (Should this be a ghost or should it be in deep shadow?) Whereas if you need the pixel/vertex to decide the effect, that should be in one shader. (If I am a bright color I should be white, but if I am a dark color I should be black) But it all depends on what your shaders need to do, so benchmarking is best.
Jun 12, 2013 at 17:11 comment added Sean Middleditch The technique of making one shader with many behaviors is commonly referred to as an "uber shader," which might help you find additional information via Google.
Jun 12, 2013 at 17:05 history edited House CC BY-SA 3.0
deleted 2 characters in body; edited title
Jun 12, 2013 at 17:03 comment added zacharmarz That's not exactly true. GPU is not CPU. GPU is working in parallel. A lot of threads (I think 16-32) are working with the same instruction in the same time. And if it evaluates the same value, it also continues the same way (in you switch). But if you have a lot of "case" branches, it will still be slow - a lot of conditions have to be evaluated.
Jun 12, 2013 at 16:49 comment added Maximus Minimus Vertex shader is run per-vertex. Take an object with 1,000 vertexes - that means your switch needs to be called 1,000 times - versus just one shader change.
Jun 12, 2013 at 16:40 comment added Fredrik Boston Westman hmm you got a point there, didnt think about that it has to do it every pixel. But lets forget about the pixel shader then, how about the vertex shader (and i belive there is a geometry shader? srry im kinda new). Are they called on a per pixel or a per object basis?
Jun 12, 2013 at 16:36 comment added Nathan Reed Well, think about this: the switch() has to be evaluated every time the shader runs, i.e. for every pixel drawn. If you keep your shaders separate, there is no extra work per pixel. But don't take my word for it...why not code up both versions and measure the performance?
Jun 12, 2013 at 16:29 history asked Fredrik Boston Westman CC BY-SA 3.0