How to render the illumination to a texture for Papervision3D with 3D Studio MAX

February 21st 2007

I'll declare myself Mr.Tutorial!

For the ones that doesn't have too much time and need to understand what's going on, this tutorial explains how to do this:



(This tutorial isn't just for Papervision3D, you can use it with any other 3D engine).

The point is that when you approach a realtime 3Dengine the best way to achieve good results is to think about how to use the resources you have. Papervision3D still doesn't have illumination, but it can render polygons with textures. So, why don't we render the illumination to the texture with our 3D package? This is exactly what I thought when I did this, this and this.

I'm afraid I've no idea of how to do this thing with any other package, but at least you will get the idea.

Ok, let's start...

Open 3D Studio MAX and all that, I believe the Render to Texture feature is there since the version 5 or 6... (I'm using 8).

Then we create a Torus and a Plane.



And we do an scene similar to this one:



The under the Lights tab we select the Skylight... er.. light, and with check the Cast shadows checkbox. The rays per sample parameter is the quality, if your machine is slow, put it to 5 or 10 just for testing, I usually do the tests with 5, and then when I go to do the render to texture I put it up to 30.



I'm don't thing the position of the light really matters, this is not one of those lights that you need to focus on something, just put it anywhere.



Half of the work done! If we do a Render right now, It should look like this:



Now, sometimes the 3D object we want to render the texture from is quite complex, so we need to Unwrap the mesh to a plane so we make things easier to the render to texture thing. (You'll understand what I mean in a sec). So, under the Modifiers tab, we select the Unwrap UVW from the Modifier List. And then we click on Edit.



A new window will appear with the mesh on a plane in wireframe. First we click on the 3rd option of the Selection Modes, and then We go to Mapping/Flatten Mapping.



On the new window that will appear we put the Spacing to 0.0 and we click OK, this will explode your mesh to the best (not always) way so the Render to Texture can put as much information as possible into the texture.



The end result should look something similar to this:



We close the window, and then with the Torus object stil selected we go to Rendering/Render To Texture.



On the new window, we scroll down to the Output part and we click on Add... to add a new texture you want to bake. This will prompt another window where we have to select CompleteMap.



If we scroll down that panel a bit, we will see the options for the final texture. If you want to save the texture in a different path, well... feel free. I usually do the renders to 1024, and in case isn't it can be reduced then I reduce them to 512 with Photoshop.

As the last thing, If you don't want MAX to change the texture of the Torus with the backed one, I recommend you to check the Render To Files only checkbox.



We click on Render and after we'll end up with a texture similar to this:



And that's all, I'm afraid I won't go into the part of doing the code with Papervision3D for loading all this, but I'm sure you know how to use this texture now ;)

Hope this is useful for someone

8 comments written so far...

Hey Ricardo, on the "Complete Map" selection, why do you do that? I had been using Diffused map and that seemed to work, but I'd like to know for sure which is better
February 21st 2007
John Grden
I don't know if Diffused map also applies the texture If you had a texture in the material. I don't know, I guess I do it just in case :) I guess Complete will work in any case and Diffuse may not work always.
February 21st 2007
mr.doob
Makes sense! thanks Doob
February 21st 2007
John Grden
erm, I'm quite sure the slots does not work that way.
Target map slot should be set to the first free unused slot ,...i.e the Self Illumination one.

That leaves the base texture intact at diffuse slot, and then setup for you the SelfIllumination slot to Bitmap, with the CompleteMapXXXXX.tga.

The bad news are, that, you will not be able to raster the two textures in papervision, cause:

2nd pass with some blending needed (speed penalty)
Additional UV texture coords, are specified in another channel (for the selfIllumination slot) being used along the object during the 2nd pass. (importer plugin + format programming)
February 21st 2007
JaK
Jak, we're talking of rendering all what you see on the MAX render into a ONE SINGLE texture. Forget about slots, forget about multipass. One single texture with the shadows and texture applied. This is NOT a lightmap.
February 21st 2007
mr.doob
Hi Ricardo, good work!! I tried to follow your steps, but when I create the Skylight I am not able to check "Cast Shadows" because it appear disable to select..I am using 3d Max 7. Do you know why It could be?
Thanks
February 26th 2007
Oliver
Hey Oliver,
I've no idea what's going on there :? It should be check-able.
February 26th 2007
mr.doob
John Grden, "diffused map" sounds so wrong.
Normally a "diffuse map" refers to a "texture-only" layer of the render process, without lighting, shadows, specular reflections, etc..
A "complete map" opposed to this is, indeed, a complete-all-layers/effects-included map.
As for working with pv3d, here is the deal:
-bake complete-map if You won't light Your scene.
-bake diffuse-only if You will generate indirect/direct illumination in You scene of pv3d, or simply don't want shadows on it.

But, since three years passed already, i'm sure You got all this straight in the meantime.
cheers.
January 5th 2010
dbam

Have your say!

Name:

Website:

Comment:

Some of the projects that I worked on.



Some of the HTML5 and Actionscript experiments I've done.