- vertex lighting
- shadow baking
Each has up and downsides. Upside of lightmaping is that you can apply normal/bumo maps, finer shadows and so on.
However lightmapping regularly fails on curves and small details.
That's when we use vertex lighting that prefers curves to flat surfaces.
Downside to vertex lighting is that you can' bump or normal map a model if it's vertex lit.
Well you can but the results are uncontrollable.
But what when vertex lighting fails, and it can fail and break.
Shadowbaking offers a quick and easy solution. Build a model, unwrap it, set up some lights in max/blender and then render the shadows into a single image you can later on edit and apply to your diffuse map.
fairly simple process once you get a hang of it and you get much better looking shadows.
Downside is, you have to write a shader that will completely eliminate lightmaps.
Since you're using your own baked lightmap the one generated by the compiled is just getting in the way.
So what if you really want to apply a normal/bump map to your model, you can't cause there is no lightmap.
And if there is no lightmap then a normal map is useless, it doesn't do anything.
Recently i made a crappy looking model of a bathtub. Probably cause of my poor way of building vertex lighting broke and the shadows looked horrible.
So the only thing i could do is shadow bake it. So i did.
But i really wanted to apply a normal map to it. It doesn't really needs it, i just have this normal map fetish.
So i had to figure out a way to lightmap this model but remove lightmaps entirely in the same time.
The solution is very simple. Just one line in the shader i overlooked for a long time.
This line can turn up the brightness of a lightmap. cause of the way lightmaps are blended onto a surface if a lightmap is white, it wont show.
But it exists.
Shader is very simple and gets the job done.
Code: Select all
blendfunc gl_one gl_zero
If you get black polygons this shader wont work on them. Simple math, RGB value for black is 0 0 0. Zero multiplied with any given number returns a zero.
So to fix this all i had to do is add _minlight 5 to the world spawn.
Minlight is something mappers avoid, but a value this low wont affect the map in any way, but it will remove all pitch black lightmaps and up their RGB value enough for this shader to work.
So there it is, shadow baked and lightmapped in the same time.
I used the shadow image from shadow baking and added it to the alpha channel, just to tone down it;s effect a little in the shadows.
Alpha is intentionally brighter than it should be so the effect is easier to spot.
Here's another quick test, everything seems to work fine.