The multiplication of left*bottom will be similar to the logical AND. Each result will return 1.0 (white) or 0.0 (black).įloat left = step(0.1,st.x) // Similar to ( X greater than 0.1 )įloat bottom = step(0.1,st.y) // Similar to ( Y greater than 0.1 ) Vec2 st = gl_FragCoord.xy/u_resolution.xy Now that we have a better idea of how this will work, let’s replace the if statement with step(), and instead of using 10x10 let’s use normalized values between 0.0 and 1.0: uniform vec2 u_resolution if ( (X GREATER THAN 1) AND (Y GREATER THAN 1) ) The principles to do this are remarkably similar to how we think of the grid paper scenario. Let's start by sketching pseudocode that uses if statements over the spatial field. How can we use this to draw a centered square in the middle of our billboard? In previous chapters we mapped x and y to the red and green color channels, and we learned how to use the narrow two dimensional territory between 0.0 and 1.0. Each little square knows its position, like the coordinates of a chess board. How does this relate to shaders? Each little square of our grid paper is a thread (a pixel). You'd paint everything except the first and last rows and the first and last column, right? The paper size is 10x10 and the square is supposed to be 8x8. Imagine we have grid paper like we used in math classes and our homework is to draw a square. You are up for this challenge! In this chapter you'll learn how to draw simple shapes in a parallel procedural way. You have practiced your shaping equations over and over. Finally! We have been building skills for this moment! You have learned most of the GLSL foundations, types and functions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |