# Rendering 3d properties to bitmap

• 11-30-2007
DrSnuggles
Rendering 3d properties to bitmap
Hey, I'm not sure if anybody here has any experience wth working with 3d geometry but I have a thing I'd like to do and I'm trying to figure out the best way to do it...an example:

If I want to render out certain characteristics of an object to a bitmap, like surface normal as an example, what is the best way go about that? Do I step through each pixel in the bitmap and determine which face the pixel lies within in the objects uv coordinates then calculate the barycentric coordinates for that point and then get that position in 3d space from those coordinates(relative to the face)?...or is there a more efficient way? Determining in which face each pixel lies can get quite time consuming like that.

:)
• 11-30-2007
VirtualAce
I'm not sure I understand you. If you want a normal map there are tried and true methods for generating them.

Since surface normals should fall in the range 0.0f to 1.0f you could write this to the bitmap at each pixel

Red - 255.0f * normal[vertex_num].x;
Green = 255.0f * normal[vertex_num].y;
Blue = 255.0f * normal[vertex_num].z;
Alpha = 0.0f;
• 12-01-2007
DrSnuggles
Hey Bubba, yes but that will not fill in the parts between the vertices. I need to find a good way to tell where each pixel lies on the 3d surface.

I'm thinking of checking an area in the bitmap that is a rectangle around each face and check if the face contains the pixel and if it does get the positon of the pixel relative to the face. That relative place will then also be relative to the face in 3d space.

I do not actually need to create a normalmap, I rather want to create a map that displays how concave or convex a surface is.
• 12-01-2007
VirtualAce
You cannot do that without doing some nifty uv wnrapping algorithms. You are trying to put a 3D object onto a 2D plane which is exactly what happens when you unwrap a model.

Good luck with that.
• 12-01-2007
DrSnuggles
Hey Bubba, the object already has uv mapping applied so I need not worry about that. The code for determining concavity/convexity is also already written. Anyway I have got something basically working now which is reasonably fast. Now I just need to get it to draw smoothly across edges and stuff.:)
• 12-03-2007
DrSnuggles
For those interested, I managed to complete this tool now (so proud:))
Here is an image showing the generated map and the map applied to the model after some editing in photoshop.

http://www.cmlcreative.com/Images/cavitytest.jpg

cheers
• 12-03-2007
DrSnuggles
Wow, that is pretty awsome. Congratulations on your great invention!

(nobody else said it:))