Sign in to follow this  

Circle in fragment shader

This topic is 3736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can think of a couple ways you might be able to do it abusing texture coordinates and the mathematical properties of a circle. But they're not pretty.

The easy way is to render geometry that looks like a circle while a texture is the active render target. Fragment shaders aren't pixel-plotting devices, they're pixel (fragment) coloring devices. It's usually pretty difficult to do anything resembling traditional arbitrary drawing -- they're the endpoints of a highly parallelized stream processing system.

Share this post


Link to post
Share on other sites
switch to rendering to rexture, then
x^2 + y^2 = r^2 //pitagoras says so
isnt it simple ? :)
about squares with rounded corners: you can find source of some graphic library for c, but as i remind the algorithm is rather complex, though

Share this post


Link to post
Share on other sites
As I recall, I got it working once (but lost the code in a hard-drive corruption) and could get rounded squares with a tiny modification to my circle code. It was basically determining if the point was inside the circle/rounded square, shading with the fill color if so, and with alpha otherwise.

Share this post


Link to post
Share on other sites

This topic is 3736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this