Painting pixels on 3D object

Started by
1 comment, last by Alessandro 12 years, 2 months ago
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.
Advertisement
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.
Blekinge Institute of Technology
Twitter [twitter]devmoon[/twitter]
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon
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...

This topic is closed to new replies.

Advertisement