ands / lightmapper

A C/C++ single-file library for drop-in lightmap baking. Just use your existing OpenGL renderer to bounce light!
1.41k stars 133 forks source link

Run entirely offline? #2

Closed AndrewRayCode closed 8 years ago

AndrewRayCode commented 8 years ago

I'm exploring this project as a potential offline lightmapper for a WebGL level editor. I'm looking through the source code now but I'm new to C. How easy would it be to make this run entirely offline / in the background?

ands commented 8 years ago

I'm not really up-to-date regarding WebGL stuff. So I can't really tell you if it is possible to port the library to WebGL. I would assume that it should be as long as floating point texture and framebuffer formats are supported. I'm not sure what you mean by offline/in the background. I don't think there is a concept of threads in js (at least in browsers)? So you would probably have to interleave rendering with your level editor somehow. This should be doable. Note that you would also need to generate coordinates for a texture atlas at some point. That is not in the scope of this library though.

If you want to reimplement/port the technique used in this library, I'd recommend reading about precomputed lighting in these blog posts: http://the-witness.net/news/2010/03/graphics-tech-precomputed-lighting/ http://the-witness.net/news/2010/03/graphics-tech-lighting-comparison/ http://the-witness.net/news/2010/09/hemicube-rendering-and-integration/ https://knarkowicz.wordpress.com/2014/07/20/lightmapping-in-anomaly-2-mobile/

AndrewRayCode commented 8 years ago

Sorry, I can see how the question was ambiguous. I just want to run this compiled program without popping up the gui window, and to just use it as a command line tool, so I can pass it a .obj file of my choosing and have it spit out the lightmap

ands commented 8 years ago

Sorry! :) Operating systems often don't allow creating an OpenGL context without a window or similar as far as I know. It is possible to hide that window though. In the case of GLFW you can just set a hint before creating the window as explained here: http://www.glfw.org/docs/latest/context_guide.html#context_offscreen

The process of light mapping happens on an offscreen buffer anyway. So, you can just not render anything to the default framebuffer.

karimnaaji commented 8 years ago

Have you heard of OS Mesa? (http://mesa3d.org/osmesa.html). There could probably be a port of this library to it, and it would allow offscreen rendering without the need of creating a window context, which could make this command line only.