GPU Efficient Texture Based Bezier Curve Evaluation - Sine and Cosine via Rational Curves
Back to Index
This shows sine and cosine calculated by using 1d (explicit) rational quadratic bezier splines. On the left is the results with bilinear interpolation, on the right is the results doing 4 pixel reads and doing the bilinear interpolation in the fragment shader. The curves only encode the first 90 degrees of each wave form, so the curve is flipped horizontally and veritically in other quadrants as appropriate to get the full wave form.
Green is cosine, Red is sine. The white lines are the actual sine / cosine values as computed by sin() and cos() in the fragment shader.
Since a rational bezier curve is just one bezier curve divided by another, and in this case, both sine and cosine use the same denominator (due to using the same weights), the denominator curve is encoded the the alpha channel, the numerator curve for sine is stored in the red channel and the numerator curve for cosine is stored in the green channel. The red and green curves have their control points pre-multiplied by the weights. The Blue channel is unused in this example.
If you have several rational curves that all use the same weight values, you are able to store 3 rational curves at once by storing their numerator in R,G,B and their denominator in A. If you want to use different weights, you can store 2 rational curves at once by storing their numerators in R,G and their denominaors in B,A.
Back to Index