ShaderDojo

Problems Discussion Profile

Colored Diagonal Gradient

Collapse

In this task, you will create a diagonal gradient that transitions from red in the bottom-left corner to blue in the top-right corner. The fragment shader currently displays a solid red color, but your goal is to modify it to create this diagonal gradient.

To achieve this, you’ll need to use both the x and y coordinates of each pixel (normalized to a range of 0.0 to 1.0) to calculate the interpolation factor. The mix() function will help you blend between red and blue based on this factor.

By the end, the screen should display a smooth gradient where the bottom-left corner is completely red, the top-right corner is completely blue, and the middle transitions smoothly between the two.

Fetching Status...

×