- Home /
Light map glowing edges
I've been creating my lightmaps in Cheetah3d @ 1024 x 1024. I've been incorporating them in Unity using the legacy Lightmap shader set to diffuse. The overall quality of the lightmap is jagged, and on edges the highlights seem oversaturated to the point of glowing. Would bumping up to 2048 x 2048 help the resolution and can unity handle that size? Would a different setting for the lightmap in Unity be preferable? And does getting Pro make life easier than using the free version. Tune in next week.....
Answer by skovacs1 · Dec 09, 2010 at 06:00 PM
That's a fair number of questions in one go. Try to stay focused.
Unity imports textures using its own texture import and compression settings. You may want to check that your textures' max sizes are actually set to 1024 in Unity and that your compression settings are appropriate as this may help with your jaggies. Unity supports textures up to a resolution of 4096x4096. Additionally, you may or may not opt to set your textures to be imported as textures or lightmaps, but for all intents and purposes here, that should only change the compression settings and a few available options.
When you say you create your lightmaps in anything other than Unity, it is quite likely that this other application may use different settings or mapping methods for the lightmapping than Unity does. Please ensure that your settings are being correctly copied into Unity.
The legacy diffuse lighmap shader looks like this:
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Color;
half4 lm = tex2D (_LightMap, IN.uv2_LightMap);
o.Emission = lm.rgb*o.Albedo.rgb;
o.Alpha = lm.a * _Color.a;
It multiplies your color and main texture to get a diffuse color. It takes this result and multiplies it by your lightmap to get the emission. I don't know what Cheetah 3D does with its lightmaps, but as it is conceivably different than the above, you may either have to adjust the lightmap (in an image editor maybe?) or adjust the shader Unity is using to more closely reflect the one in Cheetah 3D. Also, since this uses the secondary texture uv coordinates of your mesh, make sure that those are correct and that is what your lightmap is made for.
Do you have any lights in your Unity scene that might be hitting your lightmapped objects? If they are already lit by the lightmap, this does not preclude them from other lighting and that may be leading to oversaturation. To correct this, you will have to set your Unity lights to cull the lightmapped objects' layers or customize the shader to be exluded from lighting.
Pro can make life easier depending on what you are doing, but within the context of this question, it shouldn't have any real bearing. See here for what Pro offers.
Yeah I admit the way I have been doing this in C3d is a bit of a hack.What I am doing is making a B&W baked texture on the UV2 channel and applying that as a light map. The max sizes in Unity and C3d are 1024. I have no lights from Unity. Rather than a shader made of colors, I have to use a jpeg that is the same color. Other wise the light maps won't be object independent. Would bumping up resolution in both apps help at all? The reason i'm half-assing the learning curve, is the time factor. Unity and 3D graphics in general is such a deep study, that I can only learn what I need to get the job
Also is there a preferable file format for textures that Unity prefers. I know I ask a lot of questions. Some of you more experienced users could probably start up an online chat help and make $ holding us newbies hands thru this.
Oh and by Pro making life easier, I mean by doing certain processes for the user that he would have otherwise had to do manually in the free version. Like doing a bevel 3d look with channels in photoshop ins$$anonymous$$d of doing the same thing with a plug-in. The plug in automates the process.
The texture should present itself the same in both apps. If it looks jaggy in C3d, you may consider bumping up the res. A shader made of colours? What does that mean? Object-independent lightmapping should really only be affected by your uv2 coordinates. Unity doesn't "prefer" anything over another all that much in my experience since it re-compresses so work with a format of your preference. I recommend a format that is cross-platform though. Built-in, there aren't any particular Pro-only productivity tools to speak of that I know, but the ability to use plug-ins makes it possible.