PDA

View Full Version : Box texture mapping


enigma
04-10-2008, 06:31 AM
Hi!
Anyone know a "box" texture mapping representation?
If I have a model, how can I implement this method?
For example:
1) I make 6 images of the model (front, back, left, right, top, bottom). This image must made in orthographic mode?
2) With this 6 images, how can I implement the box texture mapping?
Thanks!

mmakrzem
04-11-2008, 05:07 AM
Have a look at VMK19 and VMK24 on my website. These will show you how to texture an object (19), and how to apply a texture onto a box (24)

enigma
04-11-2008, 08:49 AM
Have a look at VMK19 and VMK24 on my website. These will show you how to texture an object (19), and how to apply a texture onto a box (24)
No, I don't want apply a texture onto a box.
I report a paper description:

We have implemented two schemes for representing the surface texture data. The
first is a “box” scheme that represents the surface textures using 6 orthographic (nonperspective)
“canonical” views of the model (top view, front view etc). For each triangle
we texture map using the “best” view for that triangle. This is the canonical view with
the highest texture resolution out of all views in which the triangle is completely visible
(no occlusion). The benefits of this approach are that it is very simple and the 2D texture
coordinates can be calculated implicitly from the 3D vertex data.

I hope to being more clear!
Thanks!

mmakrzem
04-11-2008, 09:17 AM
ahh I see. What you need to do, if go through ever face of your model. At each face determine which of the six "box" planes this face is facing. Then project all points from the face onto your box plane. where the points land on your orthogonal plane gives you the UV coordinate for that face.

Repeat over your entire model and then render!

enigma
04-12-2008, 02:30 AM
ahh I see. What you need to do, if go through ever face of your model. At each face determine which of the six "box" planes this face is facing. Then project all points from the face onto your box plane. where the points land on your orthogonal plane gives you the UV coordinate for that face.

Repeat over your entire model and then render!
Ok, but we can see this step by step? :)
1) I must make the six images of my model. This images must be taken in orthographic mode, it's correct? What paramaters of orthographic mode I must use? It's correct save those images in a texture, by reading the frame buffer?
2) Now I have the six images (front, back, top, bottom, lef right).
I go throught ever triangle (face) of my model, and I must determine which of the six "box" planes this triangle is facing. I must use the normals?
Then I project my triangle points on my box plane, otherwise on my camera plane, it's correct? With this projection I obtain new 2D points, this are the UV coordinate, and I can have the acces to the texture.
Thanks!!! ;)

Goz
04-13-2008, 02:10 PM
TBH it sounds like cubic environment mapping. Usually when you do that sort on env mapping you'd use the normal to calcualte a reflction into the cube. With the method suggested there couldn't you just use the normal directly (ie not perform the reflection calculation) to look up the texture in the cube?

enigma
04-14-2008, 07:24 AM
TBH it sounds like cubic environment mapping. Usually when you do that sort on env mapping you'd use the normal to calcualte a reflction into the cube. With the method suggested there couldn't you just use the normal directly (ie not perform the reflection calculation) to look up the texture in the cube?
How I must use the normals?

Goz
04-14-2008, 07:42 AM
Well instead of passing a reflection vector into your texCube call (assuming HLSL) you pass the world space normal in.

If i'm understand the problem properly. A link to the actual paper migt be handy.

enigma
04-14-2008, 07:51 AM
The paper is this:
http://www.bmva.ac.uk/bmvc/2002/papers/49/full_49.pdf
See "Texture representation" (1.3)

enigma
04-14-2008, 11:19 PM
Hi!
I'm trying to implement the method advised by mmakrzem!
But I've some problems with the generation of the texture data.
My windows is 1024,768, and by default I use gluPerspective() function.
I use glReadPixels() function to read the frame buffer and save them in to an image.
The paper say to use the orthographic mode for the texture generation.
I can use glOrtho() function, but with parameters?
Help me please!
Thanks!

enigma
04-15-2008, 01:01 AM
I've tried a simple example.
My model is a cube of unitary lenght, and it's positioned at the center of the scene (0, 0, 0).
I use the orthographic projection with this parameters:

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

This is the screen: (the windows dimension is 512x512)
http://img525.imageshack.us/img525/4479/38966250is0.th.png (http://img525.imageshack.us/my.php?image=38966250is0.png)
Then I applied the method advised by mmakrzem. I've projected each point and I used new point coordinate for texture mapping.
I've added to the precedent image eight green points, four at the square corners and four at the image corners.
This is the screen:
http://img215.imageshack.us/img215/7659/22834950dv4.th.png (http://img215.imageshack.us/my.php?image=22834950dv4.png)
Sorry for the color of the square.
The mapping looks not correctly. Where is the problem? (In the texture generation?)
Thanks!

enigma
04-15-2008, 09:15 AM
I've solved the past problem in this manner: I project each vertex and then if this new vertex is less then zero I set them to zero and if the vertex is greater then one I set them to one.
Probably is wrong!
I've tried with a new model, a cylinder of lenght, width and depth two.
My windows is 512x512.
This is the correct rendering of the model, no texture, only light.
http://img151.imageshack.us/img151/4823/29985673mf4.th.png (http://img151.imageshack.us/my.php?image=29985673mf4.png)
This is the texture created using the orthographic projection set to (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0).
http://img175.imageshack.us/img175/6602/26932309gl3.th.png (http://img175.imageshack.us/my.php?image=26932309gl3.png)
It's correct?
And this is a model textured, using the precedent image.
http://img135.imageshack.us/img135/403/65143147wy4.th.png (http://img135.imageshack.us/my.php?image=65143147wy4.png)
It's wrong... :(:(
Where is the problem? Or... where are the problems?
Thanks!

Goz
04-18-2008, 04:00 AM
Well you "could" use that texture to texture the cylinder correctly but its a bit specific to the task.

Look up environment mapping. You can easily add lights to the correct places in a cubic environment map and then just us that env map directly on your object. Its really a simple way of doing lighting with textures.

If you want to get more complicated you can fill a flat 2D texture with lighting data and then use simple spherical env mapping to light an object too ... This method is far more complex than generating a cubic environment mapping with your lighting data in it.

I'd strongly recommend looking into how normalisation cubemaps work and then see if you can display the normal data from a normalisation cubemap. Then to do lighting that way you can replace the normals with lights. This will give you a good idea on how to set up environment map based lighting.

Give this a try first because in my mind you need to learn the basics before diving into something like you are trying. I, for example, still don't have any idea what you are trying to do. The method you described earlier require cube mapping and yet you are workig with a simple 2D texture.

Good luck.