Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm creating a procedural terrain system for Unity. And I'm looking for ways to efficiently cast self-shadows on it. If it wasn't procedural, I could simply bake a lightmap using Beast. But, I can't because the terrain mesh is created at runtime. What kind of methods can be done for this, I'm sure it has been done before. If possible, I'm looking for a solution that works for non-pro.

I was thinking that maybe some kind of onetime ray-tracing method might be a solution.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

There isn't a way to bake lightmaps at runtime using Beast (Unity's lightmap engine). Beast only works in the editor. However, you can run editor functions from the command line using -executeMethod so if your procedural level was XML you could send it to a server, run an editor method similar to this (javascript):

static void PerformBuild () {
    Lightmapping.Bake()
}

I didn't compile this yet, so it might not be all the code neccesary. Here are a few links that I used as a reference:

http://docs.unity3d.com/Documentation/ScriptReference/Lightmapping.html http://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html http://docs.unity3d.com/Documentation/Components/gui-ExtendingEditor.html

share|improve this answer
    
That's an interesting idea. Thanks! –  Dan the Man Jan 21 at 11:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.