3D Paint

Painting directly on a 3D model? It’s possible and easy to accomplish!

After a little chat with a colleague (Peter Bindels) about texturing we had an idea about some kind of 3D picking and painting. Quickly the question arises:  How can I directly paint on a 3D model with pixel precision? Conclusion: render the 3D model to an off screen render target with a gradient texture where r (red) represents the x-axis and g (green) represents the y-axis.

How to…

So I made a little test in my 3D engine to see if it works. I try to explain how it works.

I first render my 3D model to an off screen render target with a special made shader (it can also be a texture o don’t worry). This shader (or texture) has a horizontal gradient from 0 to 1 on the red channel, representing the texture coordinates on the x-axis. The y-axis is represented by a vertical gradient from 0 to 1. If you render a model with this it should look like this:

Colors representing 2D texture coordinats

Colors representing 2D texture coordinates

Texture coordinates are not fit onto the model, that explains the line in the middle. You can clearly see that black is point 0,0 and yellow is 1,1 on our texture we want to paint on.

Now when you move your mouse over the screen just trace the x and y back to the render target. When the pixel is retrieved you have the red and green as x and y in your texture. When I tried to draw a circle with a cross in it strait on the model, it looks like this:

Painting direcly on a 3D model

Painting directly on a 3D model

However the technique I used to grab a pixel from the render target is very slow. So I don’t want to continue unless I get a decent 60 frames per second.

Update:  with a workaround I got it working at +60 fps!

One thought on “3D Paint

  1. Pingback: 3D Paint, a movie - NecroSOFT

Leave a Reply

Your email address will not be published. Required fields are marked *