Sign in to follow this  
Alessandro

Painting pixels on 3D object

Recommended Posts

I already use glReadPixels to get pixel information on a certain 3D object on screen. I'd like to ask if, in order to paint pixels on such object (so that, to be more clear, I can use the mouse as a brush), I'd use glDrawPixels and if there are better solution than this.

Share this post


Link to post
Share on other sites
It is very hard to give a single answer to this, since painting on objects can be done in many different ways.

1. Do you want the painted details to be painted on the objects directly?
2. Do you have a static scene and just want to paint on a texture in screen space and apply it to the scene?
3. Do you want to make decals and have them as separate objects?

If case one then you could paint to a unique texture for each object and apply it using the same uv mapping while rendering, or paint to a second uv mapping.


To do the real painting you can use compute shaders or you can set the object texture as render target and render a brush shaped image.

glDrawPixel and glReadPixels are very slow operations, it is much better to do as above if you want paint in realtime.

Share this post


Link to post
Share on other sites
Hi Kristoffer, thanks for the answer. Yes my case would be #1. I guess as you suggested, the best way to do it actually using a shader to paint pixels on the object, and than I can have a separate routine to render to texture when painting is done.
About the GLSL shader, I think I would just need to pass mouse coordinates and set the fragment color to that specific pixel. I'm totally new to GLSL, guess I'll have to start studying those...

Share this post


Link to post
Share on other sites

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