I am stil at searching for a way to have both, lightmaps and normalmaps in Unity Free 3.42 (or also 3.5 in case the patch for the more drawcalls issues is available). By default and using the default shaders this doesn`t work. It seems that you need your own selfmade shader for that. As stated in the manual: So i grabbed Strumpy`s shader editor, modified the bumped diffuse shader and enabled the dualforward surface shader directive there. Which can be done by one checkbox in the Settings / Color and Lighting Settings, called Forward Dual Lightmaps. Then i grabbed my level, have redone the lightmapping, using dual lightmaps and use dual in forward rendering, and have applied the shader. As a result the whole geometry turned darker. Lightmaps are hardly to see now, and bump effect is invisible. Useless result. I reduced the problem to one object. The near lightmap does look odd. Pure grey. This is not what i want. I search for a way to display bump and lightmap at the same time. When the near lightmap would be the same than the far lightmap then we would talking. But it doesn`t really help me when i can have either the lightmapping or the normalmapping. I`ve attached the reduced example, made in 3.42. Could somebody point me into the right direction here, please? Have i overlooked some settings? Is there a way to use lightmaps together with normalmaps in Unity free at all? HOW?
One step closer, but still not happy. I have copied the far lightmap and have replaced the near lightmap by that. Now i have lightmapping and normalmapping, which shows that the shader works. But the whole thing is much too bright. See screenshot. I cannot edit the lightmap because i haven`t found a software to do that. What software is able to open exr please? Blender was the only one i have that at least opens the exr. But Blender saves the exr file in blue then. No clue if it`s a bug or wrong settings. Exr is a odd format. Somebody an idea how to get this to work? What software do i need to modify the exr file? Or do i need to modify the shader? Halp
Okay, a few experiments later i have to say the method is at least working. Just the brightness is still an issue. I have to retweak the whole light setting of the scene for that. And to replace the Near lightmaps with the Far lightmaps after baking is also a bit cumbersome. The working bump mapping is an advantage though. So it`s worth the hassle What was funny is that in my level i have added a second point light. So i have two of them to light the scene now. One at Auto, one at Realtime Only. Which gives a good mix for the normalmapping versus brightness because the Realtime Only light doesn`t longer light the lightmapped geometry. Gives of course a fewer bump effect. In my experimental scene here though this doesn`t work. Dunno why. Here the brightness is the same for Point Lights, no matter how the light is set up. Anyways, Problem solved Now let`s have a look to create a diffuse bumped detail shader that works this way here ...
Bad news. I´ve made this example with 3.42. The by Strumpy created shader does not work in Unity 3.5 though. And i am planning to upgrade my project at one point. Which means this method here is no go with the current shader. What i get is a pink mesh and a bunch of warnings after conversion. See shot. The funny thing is that the shader code ends at line 116, and the debugger tells me about an error at line 190. And when i close and reopen the project then i get just this warning here: Code (csharp): Material doesn't have a texture property '_Normal' UnityEditor.DockArea:OnGUI() I know that the lighting engine has changed in 3.5. The question is, what especially has changed? I am lost with writing shader code, that`s why i use Strumpy`s shader editor. Has somebody an idea how to fix this issue? Or do i need to wait for a Strumpy Shader Editor version for 3.5?
It is possible to use beast lightmaps in combination with realtime lights, so there is no need for this quirky workaround with dual lightmaps. The following shader uses the lightmap directly and deactivates the Unity lightmap handling: Code (csharp): Shader "Custom\BumpedLightmapped" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _Dummy ("Dummy", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert nolightmap sampler2D _MainTex; sampler2D unity_Lightmap; float4 unity_LightmapST; sampler2D _Dummy; sampler2D _BumpMap; struct Input { float2 uv_MainTex; float2 uv2_Dummy; float2 uv_BumpMap; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D (_MainTex, IN.uv_MainTex); float2 lmuv = IN.uv2_Dummy.xy * unity_LightmapST.xy + unity_LightmapST.zw; o.Albedo = tex.rgb * DecodeLightmap( tex2D (unity_Lightmap, lmuv) ); o.Alpha = tex.a; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); } ENDCG } FallBack "Diffuse" } I don't know if there is any way to get a surface shader to supply lightmap UVs, therefore this workaround with a dummy texture. However, you still have to fiddle with your lighting setup as normal mapping requires some amount of realtime lighting.
Awesome. Now that would be nice to have. Unfortunately i do something wrong here it seems. No matter what i do, with or without generate lightmap UV´s, i get a result with not fitting lightmap. Dummy needs to stay clear, right? Could you please help me out here?
Hi Tiles, I have updated the shader to support lightmap atlas, see above. P.S. Yeah dummy has to stay clear with Tiling 1 and Offset 0 If you don't want to use realtime lights, you could use a cubemap to create a bumped effect. To create a cubemap for lighting purposes, use an inverted sphere with all the lighting applied and render your cubemap from inside(center) of this sphere.
Perfect. Now it works as thougth. Many thanks for your help and tips Regarding the cubemap idea, that would be another shader then, right? I think i am settled with the current method for now. But the cubemap idea is definitely stored.The only thing i may reinvestigate is if the quirky dual lightmap method may be better for performance. But that`s a thing to investigate when the by Strumpy created shader works in 3.5
This shader works great! Thanks BIG BUG! The problem is that there is no way to use it for terrain :"(
Why not use a two light setup? Bake the scene with a baked only light, then user a realtime only light that picks up the normal maps. Simple.
Is there any chance you could give some step-by-step instructions on making this work, please? Cheers, Malcolm