I'm new to unity work and having a problem with a scene I am setting up. I can't seem to get a good result for lightmaps + specular. The camera view is similar to an RTS view and I need the specular/normal maps to work at all distances in combination with my GI/lightmapping solution. I currently have the scene set up running deferred rendering with directional light maps. The shadow areas are getting all kinds of weird specular artifacts and it looks totally broken. Is there an easy way to set this up? Additionally, I would be happy to limit the specular effects to 1 primary (sun) + 1 nearby light source.
Replies
Options are to turn on dual forward lightmapping (blends between lightmap for far and dynamic lighting for near shadows). For an RTS, that's probably not too helpful.
Or to use RNM lightmaps, which should let you get specular highlights from the lights you baked the lightmaps with - not sure if it lets you stick dynamic lights on top. Although you could hack that in with a shader I think.
That said, it is possible to hack together a shader that'll do a lightmap pass then add passes for dynamic lights on top. Might have one somewhere but won't be able to post it up until tomorrow.
It's a bit harder to do with the deferred pipeline, though. It's more locked down in how it handles things. You won't get coloured spec, which might be the cause of the white oddities?
Also not 100% sure how those other options tie into the deferred pipeline.
and image summary of what is happening:
Third shader on this page'll let you visualise UV2 coords;
http://docs.unity3d.com/Documentation/Components/SL-VertexProgramInputs.html
I will test out that shader tomorrow morning.
I did some looking around today and couldn't find any current examples of people using directional lightmaps. I am wondering how easy this is to reproduce.
Here is an image of the problem and the fix:
If you set Normals to Import and Tangents to Calculate, it will create vertex splits in the tangents in the same place it would create smoothing splits if it were auto-calculating the normals using the Smoothing Angle value. Even though the normals are set to import and it shouldn't be calculating it's own normals. Which means you end up with your tangent normal maps showing some weird errors and you can't edit the Smoothing Angle setting unless Normals are set to Calculate, so the cause isn't obvious.
Normals - Calculate
Smoothing Angle - 60 (Can't edit this if normals are set to import)
Normals - Import
Tangents - Calculate
And you'll need to re-bake the lightmap.
https://fogbugz.unity3d.com/default.asp?472207_4q31e3dl8a60gqoc