Discover and read the best of Twitter Threads about #shaderbasics

Most recents (2)

SHADER BASICS PART 5

HELPERS
Before I get to the shaping functions, SDFs and other cool stuff, I thought it'd be useful to first mention some helpful general-purpose methods that can be proven useful later.



#glsl #shaderbasics #shaders
MIN/MAX

These are fairly intuitive and common; they take 2 parameters and return the minimum or the maximum of the two respectively. They're useful for masking things in/out and blending them.
In this example, the left half of the screen (which has a uv.y less than 0.5) is colored with the UV gradient, however the right half has a solid value of 0.5 (since it's smaller than uv.x).
Read 12 tweets
SHADER BASICS PART 3

MIX (aka LERP)

In the previous thread, we mentioned how to take into account the pixels' coordinates to not just paint the screen with a solid color.



#shaderbasics #shaders
There are plenty of ways to take advantage of those coordinates but some of the main tools for that purpose are the "mix", "step" and "smoothstep" methods. Here I'll just cover "mix".
You might've already heard of this method, though in other environments outside of glsl, it goes by the name of "lerp", meaning linear interpolation.
Read 9 tweets

Related hashtags

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!