Occasionally I’ll totally bake an object, including its lighting. What is the correct shader to use this? at the moment, I’m using a Lightmapped Diffuse with a simple 16x16 white texture as the lightmap. This doesn’t feel right.
I am aware I probably should have asked this 6 months ago before I started rolling products out the door
You say “Occasionally I’ll totally bake an object, including its lighting.” To me, this statement assumes that you are generating a diffuse map as well as a lightmap for your object.
Then you go on to say “I’m using a Lightmapped Diffuse with a simple 16x16 white texture as the lightmap.” This in my mind is contradictory to the previous statment where you said you generated a unique lightmap, as you are just sticking in a white texture for the lightmap.
Are you asking the question of “What shader should I use to get the effect of Fullbright?” Or are you going in another direction…
One other clarification. Lightmaps are multiplicative to the diffuse channel, meaning a white lightmap will bring about the exact diffuse map, while black (0) when multiplied by a pixel color, will yield black (0). A completeMap on the other hand is the diffuse map premultiplied by the lightmap. If you want this, render a completeMap or just take your lightmap and diffuse map into photoshop and multiply them with blending modes to come up with one final texture with baked in lighting.
Edit: Response to Poita : If you are using diffuse/diffuse fast, you’ll still need a dynamic light on the object to see it. Are you trying to static light an object?
My textures are pre-multiplied, the term ‘Baked’ typically would denote (especially in a realtime field) that all relevant maths passes (reflection/spec/shadow/illum) have all been calc’d onto a single pass, the diffuse.
Rendering off a multiplication pass or two (lighting/ambient occlusion) is well handled in Unity, what is not is the solve that Jessie provided. Simple, fast, raw, 100% luminance without wasteful maths.
Seems if you’re totally pre-calculating the lighting and have no run time contributions, you’ll want to put a “Lighting off” in that shader pass too. Save a few cycles.
the iphone has no pixel lighting and shadows, so no actually not.
There is lightmap lighting and vertex lighting and the later is something you avoid for static models due to the vertex density requirements to work “right”.
As for the question itself: If you don’t want lightmapping then you must bake it onto the base texture. But keep in mind that tiling underground textures are NOT possible then (ie the pixel density will drop drastically in most cases), as that requires seperate textures for lightmap and diffuse map.
this baking must be done in your app. You can not use texture atlas or anything alike. You must reduce the data to a single diffuse texture that contains the underground and lightmap data. This also can be done in photoshop for example if your app isn’t able to but then the lightmap generation must be forced to use the same UVs which commonly is a very bad decision (as UVs for the diffuse have to meet significantly different requirements than optimal uv layouts for lightmap as you see in the top left quadrant of your lm texture).
Unity can and will not do this for you unless you have a self developped editor script that does it all and export the result as a png to import and compress again.
question is why you would want it to be only one texture, cause you actually don’t gain much from it other than lost details on diffuse and lightmap (you can assume that you get 1/2 to 1/4 of the current lightmap precision and smoothness by the combination of both, at best)
The amount of saved texture memory is discussable and commonly not present as tiling textures can be much smaller than a massive diffuse + lightmap texture would be.
Lightmapping was actually developed as a way to save texture memory while getting significantly better atmospheres in games through more detailed lightmaps.
for example below texture for that area would need to be 512x512 if not even 1024x1024 to work out with usable details and I highly doubt thats all thats meant to be textured.
I’ve seen other people use that. I don’t use lights on the iPhone, so I figure that line is just clutter. Will it speed things up in both cases, if I have a light or not? Or is it even slower, considering that nowhere in the shader is lighting taken into account?
Yeah, I’m quite well versed on how to lightmap / bake various channels etc.
There are particular special-case scenarios where texture atlasing gains me nothing, so I might as-well completely flatten everything into a single texture. For large jobs I typically use Shake, but for smaller ones obviously I use Photoshop.
However as stated above, Unity did not appear to have ‘do absolutely no lighting and just show the texture as-is as fast as humanly possible’ shader
I would assume that the line basically sets an attribute for the buffer so its not affected. You potentially lose an ultra small amount of time but you would have to use the ogl es profiler to measure those over a longer amount of time or alike