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!

Hell Tech Game Engine

Hell Tech Game EngineA few weeks ago I decided it was time to drop the name of my engine. So I changed it from Necro3D to Hell Tech.  After a long discussion with Zhooibaal we finally came up with almost a thousand names for the engine. At the end Hell Tech was the one that made it through! So from this day forward, Necro3D 2 will be known as Hell Tech Game Engine and it’s editor will be called Hellbox (previously Sandbox).  Here is a screenshot of the new engine console and the logo that will probably change soon into something nicer.

From this day forward my games will be fueled by Hell Tech Game Engine.

Photoshop CS4 and alpha channel in targa: FAIL

I was trying to create a nice looking image with alpha and stuff. When I tried to save it as TGA Photoshop says it has no alpha channel. Well, I used Photoshop 7 before and that one simply saves the alpha channel the way it should be saved and doesn’t need any stupid operation to correct this issue. Why is it so hard to just save the alpha channel directly to an alpha channel? It could be done before, so why not now?

Anyway, saving an alpha channel in a Targa goes as follows:

Right click your layer thumb, click “select pixels”. Now with all pixels selected click in the “Select” menu on “Save Selection” and save it as alpha channel.  Then make sure “Alpha channels” is checked when saving your Targa. All done…