@moppin_ Quick note: "If" statements are very slow in GLSL. Not a big deal for simple stuff like this, but keep it in mind for the future
-
-
Replying to @AmazingThew
@moppin_ There are tons of clever tricks you can use to get around using ifs. Mostly by abusing step() and mix() (they're basically free)1 reply 0 retweets 1 like -
Replying to @AmazingThew
@moppin_ For example, can replace your if block with: fragColor = mix(texColor, bg, step(0.0, texColor.g - max(texColor.r, texColor.b)));1 reply 0 retweets 1 like -
Replying to @AmazingThew
@moppin_ Mix() blends between two values based on a variable between 0 and 1. Step() returns 0 or 1 based on a threshold value1 reply 0 retweets 1 like -
Replying to @AmazingThew
@moppin_ Can clarify further if that snippet doesn't make sense. Again, not rly necessary here, but good to keep in mind for heavier shaders1 reply 0 retweets 1 like -
Replying to @AmazingThew
@AmazingThew Whoa thank you for such a detailed explanation!! :O Ok I'll avoid using ifs!1 reply 0 retweets 0 likes -
Replying to @moppin_
@AmazingThew don't fully understand what's going on with mix and step but will read up around the function! :) thank you so much!2 replies 0 retweets 0 likes -
Replying to @moppin_
@moppin_@AmazingThew Mix is just lerp. Step is basically return y > x;1 reply 0 retweets 1 like -
Replying to @floatvoid
@floatvoid@moppin_ Yeah. Here's the simplest visual explanation I can think of: https://www.shadertoy.com/view/Mtj3Wy1 reply 0 retweets 2 likes -
Replying to @AmazingThew
@AmazingThew@moppin_ Change the last line to this http://pastebin.com/nWy8mE9e1 reply 0 retweets 2 likes
@floatvoid @AmazingThew Oh whoa thanks much you guys, I understand it now! :D
-
-
Replying to @moppin_
@AmazingThew I'm curious though, what does "uv" stand for?1 reply 0 retweets 0 likes -
Replying to @moppin_
@moppin_@AmazingThew It's just xy, for texture. They chose uv cause xy was taken. (i think)1 reply 0 retweets 1 like - 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.