Reputation: 5162
I have drawn a square using webgl. I want to make the square checkered board. So What I need to do is I need to discard some 10*10 pixels alternately from the square. How can I use
gl_FragCoord.x and gl_FragCoord.x
To achieve this? Or is there any easy idea?
Upvotes: 0
Views: 201
Reputation: 3364
WARNING: untested.
You could do math on the fragment shader to create the checker board pattern. First do integer division of x and y by 10 and you get the tile coordinates, lets call it i and j. Then add i and j together. If the result of that is odd, discard the fragments, else if even, keep the fragments.
Upvotes: 1