How it works...
We start by accessing the noise texture, and store it's value in the variable noise. The variable scale will store a value that is either zero or one. We use the floor function to set it to zero if the value of noise is less than Threshold and to one otherwise.
Next, we access the cube map to get the reflected color and apply a gamma correction.
We compute rustColor by mixing MaterialColor with a dark color (nearly black) using the noise texture as a scale. This should give some additional variation in the rust color.
Finally, we use scale to mix the cubeMapColor with rustColor and apply the result to the fragment. Since the value of scale will be either zero or one, we will get a sharp transition between the reflected color ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access