Light-map Illuminated by Real-time Light?

Hopefully this doesn’t sound as stupid as I feel for not knowing the answer:

Is it possible to have lightmaps that are only visible when realtime lights are used?

Envision a level…a castle lets say…completely lightmapped, but without any realtime lights. It simply looks textured with a base, dark ambient light level (e.g. nighttime); you can see the floors and walls are brick but no other shadow/bounce light detail is apparent. Introduce a torch and now the baked lightmap detail is visible.

This would allow light sources to be turned on/off and still maintain the quality of a lightmap.

This is not to be confused with realtime shadows, just simple illumation of the lightmap of an object.

Here’s my pseudo code attempt:

Final = (Light * Diffuse) + (Lightmap * Diffuse)

Thanks in advance!

-Steve

EDIT: I’m considering using this technique for an iOS game, else I would go with Beast-Lightmaps/Realtime mix.

If you write an own shader that handles the lightmap instead of using surface shaders, it should be possible.

Oh I know it’s possible, so perhaps I should’ve phrased my question differently:

Does anyone have insight as to where to begin looking to accomplish this? Does my pseudo-code make sense?

Unfortunately shaders aren’t my strong suit so I needed to ask, but I’ll keep researching regardless.

Thanks Dreamora!

-Steve

I’m trying to do a similar thing currently, but i’m getting a really strange problem with the unity_LightmapST when trying to use the lightmap inside a ForwardAdd Pass.

Meaning it changes the .xy and .zw of the unity_LightmapST when moving about in the scene, so if the camera is in a certain area, it looks correct, but moving it around screws up the whole lightmap read. I guess this has to do with the system that is supposed to switch Realtime-Shadowing with Lightmap-Shadowing based on Distance when using Unity Pro ?

But i’m on Unity Indie, and this is really a problem for this type of shader.

Is there maybe some secret #pragma or similar that disables this behaviour ?

You may want to consider this as a quick solution - just setting the main material color to black or its original color:

var objectsInRoom : Renderer[];

private var colorCache : Color[];

function Start () {
	for (i = 0; i < objectsInRoom.length; i++) {
		colorCache[i] = objectsInRoom[i].material.color;
	}
}



function LightSwicth (lightActivity : boolean) {
	for (i = 0; i < objectsInRoom.length; i++) {
		if (lightActivity) {
			objectsInRoom[i].material.color = colorCache[i];
		} else {
			objectsInRoom[i].material.color = Color.black;
		}
	}
}