Lightmap questions. From 3ds Max to Unity.

Hey people.

I’m doing a small “game” experience in Unity where I have built some large rooms in 3Ds Max 2009, rendered to texture with VRay 1.50 SP2 and exported as FBX (the FBX 2009 plugin still crashes) to Unity. People who are using Mental Ray or other rendering solution is welcome to reply to.

I have a some Max Unity questions you might be able to help me with. Sorry for the length of this post and excessive use of the word Lightmap.

1. I want the floors and walls to have tiled Diffuse map in UV 1 and non-tiled Lightmap in UV 2. Right now I have tiled the Diffuse under placement inside Unity but is it a better way to do it? Tile it in Max already?

2. What settings in Render to Texture is best if one want to achieve the results I’m looking for, diffuse and lightmap. I have tested VrayCompleteMap on both with a VrayOverrideMtl when making the lightmap and sometimes the lightmap comes through way to dark in Unity. Would VrayLightMap make any difference in the end or is there is a ideal element to use?

3. What shader solution in Unity is the best for lightmaps? There is a few but I guess you need to have lights in the Unity scene to make some of them work properly (I have none)?. For example doesn’t Bump work without lights?

4. The Unity Manual says that I should combine meshes for best performance. I don’t really understand what that means here. Does a FBX file count as a mesh? Or do I have to do the combining in my 3D application?

5. Is it possible to use the Detailed Texture shader together with a lightmap?

6. I have been hearing a bit about Atlas Mapping and wondering if it’s a good idea to use it for my lightmaps. I only have 4 large rooms with some nooks and crannies, and some fairly detailed windows and lights. Basically not a ton of objects but a few large surfaces and quite a lot of smaller ones.

7. For some reason I get a material error on FBX export and have to re-add the materials in Unity. It’s not a big issue but would be nice if didn’t have to. I read somewhere that they have to be standard materials placed in diffuse and self-illumination, is this true?

As you probably understand from my questions, I want to transfer a realistic looking scene from Max the best possible way to Unity.

All help is much appreciated. Great if there was a detailed tutorial out there on this subject. I’ll post the project as soon as it’s further of the ground.

Thanks for reading all this and helping!
perfectheat

Hi perfectheat and welcome to Unity :slight_smile:

I’m going to move this topic to “External Tools” since the questions are specific to Max and VRay.

Just to get you started here are some previous threads on similar topics:

http://forum.unity3d.com/viewtopic.php?t=7588

http://forum.unity3d.com/viewtopic.php?t=14155

http://forum.unity3d.com/viewtopic.php?t=9704

http://forum.unity3d.com/viewtopic.php?t=15395

HTH,
Ethan

Hey and welcome…

If your fbx is out of date DONT export VRAY MATs or lights this fbx will crash unity. Have a bake geometry and export (instanced) geometry.

1.This is a matter of taste/workflow, I always tile my textures in max.
2.I use vray shadow map because I save the rendered pop up clone from render to texture. But if you wanna make a batch render, and save it on the HD you need to use Vray complete. (skip the main texture)
YES always use VRAY LIGHTS when rendering with vray.
Otherwise, would be like driving a Lamborghini, only in 1st.

Google for tutorials making lightmap with Vray if you arent familiar with Vray settings :wink:

3.No bump doesnt work with out lights, its a pixel shader so it needs pixel light. (Aras? :wink:
See the doc. on shaders.
http://docwiki.unity3d.com/index.php?n=Main.shader-NormalBumpedDiffuse

  1. Last year, one way to get a mesh with 2 uvs into Unity was to use Multisub. material, dont its not good, performance wise.
    Just use your 2 uvs in max. Dont use more than one material id, per mesh.

  2. I have all my textures in unity project folder and then export, never have to drag a texture to the Diffuse
    Uv 2 wise: No you dont need to place them in the self- illumination slot in Max any longer :wink:

Hope it helped

Thanks for the help guys!

I have the FBX 2009 plugin but export as the latest 2006 as the 2009 crashes.

So there is no speed difference in the player? Great to know.

Okey so you use the VrayShadowMap element when rendering to texture. I misstyped the VrayLight element with VrayLightMap. I try to use Vray Lights in the scene as much as possible but there is no problem with standars if you turn on VrayShadow.

“because I save the rendered pop up clone from render to texture.” You save the popup instead of using the file? Why this process?

Hmm and here was I brewing up this smart scheme on how to tile one part of a mesh and not tile another section of faces.

Have attached a jpg of a test from Unity and an example diffuse texture. A B is one mesh that uses the same diffuse and lightmap. The idea was to tile one part of the texture map in two directions on surface A (+ other surfaces that make up the walls and ceiling of a room) but only tile the B surfaces in one direction.

But I guess I’m thinking to much and should just split it into two meshes.

C the floor will just be a tiled diffuse lightmap map on a plane.

X is an artifact I get when at a certain distance from the wall. Walk further away and grows to cover the whole width. Anyway to fix this? Can it have something to with my mesh and that I have deleted all faces one wont see. Is this a bad idea? For unity and when rendering to texture?

So you have the project folder on the windows drive as I have no access of the os x drive from max. :slight_smile:

Once again thanks for all the help!
perfectheat

Why?
I have my pc and Mac connected

Ahh sorry. Didn’t think as far as having two computers. I’m on a MacBook Pro with Bootcamp, so I only have access to the windows drive from OS X and not the other way around.

Just wanted to ask as you people are using max. What’s the quickest way you’ve found to get unity to assign lightmaps?

Diffuse materials are added automatically but lightmap shaders and materials have to be done manually. This is problematic for those of us with lots of hi res lightmaps rather than one big one (which equates to low res in the end). Do you have a script that you’d mind sharing or is there something you can do to the fbx in order for unity to recognise a lightmap?

Thanks for your time.

Been busy on two iphone projects but now I’m back in Unity.

Does anyone know the answer to my X question??

X is an artifact I get when at a certain distance from the wall. Walk further away and grows to cover the whole width. Anyway to fix this? Can it have something to with my mesh and that I have deleted all faces one wont see. Is this a bad idea? For unity and when rendering to texture?

Zante
I haven’t tried this myself but the easiest way would to have the max, fbx and textures in the same folder. Then transfer them all except the max to the assets folder. I’m not sure if that will work. Actually I don’t think it would help. Sorry.

Cheers everyone for all the help!
perfectheat

If this is the same kind of artifacting that I ran into, it may be due to bad UV seams. I had something similar happen to me a while back. During the lightmapping process, the automatic UVing made a mess of the seams on my model. In the Max viewport they looked fine, but in Unity, you’d get weird rendering errors like you pointed out at certain viewing angles. I fixed it by rebuilding some parts of the model and they ended up getting proper UVs. That’s probably not a whole lot of help, sorry :frowning:

I’m new to Unity but I know that this X problem is because of filtering and mip mapping. Common to 3D CG, not particular to Unity.

The thing is that when your are far from the surface, 1 “rendered pixel” may have many “texture pixels” - or texels. When the renderer is asked which color is the pixel, it averages the found texels into one color (and there are several techniques avaiable for this - the reason some haven’t seen it on MAX is that it probably wasn’t filtered at all for best performance ! but keep in mind that this would produce bad quality in a more contrastant texture - search for Moire Effect).

It’s important to note that it doesn’t happen just with distance, it happens whenever you have too many texels for few pixels.

In the X example, the problem is the angle of viewing. While the vertical is still a good trade between pixels and texels, the horizontal texels are squished. The black we see is from the texels surrounding the texture.

You can see that even before the critical X, the strip is already blackening under the painting.

Of course viewing restritions you can not pass to your user. So, the solution is to bake the lightmap (or produce any other texture) with a safety margin: paint 2 extra pixels (on the texture) bigger than the area you need. Expand it to 3 on diagonal UV seams.

That way, when the filter comes to action, it filters similar colors.

This is also the reason automatic unwraps leave some spacing by default.