ShaderDojo

Problems Discussion Profile

Smooth Diagonal Line

Collapse

In this task, you will create a smooth diagonal line that extends from the top-left corner to the bottom-right corner. Instead of using a sharp transition, you will use the smoothstep function to blend between black and white smoothly.

To achieve this, calculate the diagonal line using the x and y coordinates of each pixel (normalized to a range of 0.0 to 1.0). Use the difference between x and y to define the diagonal. Then, apply the smoothstep function with two threshold values to create a gradient that smoothly transitions from black to white across the diagonal line.

By the end, the screen should display a smooth black-to-white gradient along the diagonal line.

Fetching Status...

×