ands / lightmapper

A C/C++ single-file library for drop-in lightmap baking. Just use your existing OpenGL renderer to bounce light!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hemispheres float texture always NaN if glDisable( GL_BLEND ); not issued beforehand

ziocleto opened this issue · comments

commented

Hi,

I do not know if this project is still active but I'd like to suggest a fix for a no-show issue if lightmapper.h is included in an existing codebase that already sets few openGL states.

In particular if glEnable( GL_BLEND ); is active, every texel generated will result into a NaN.

Maybe you can force it in lmCreate, not sure though if you decide to defer the render, or maybe in renderscene, when you already force set the depth test.

Cheers,
Dado.

commented

Hey,

from my experience it is fairly common that OpenGL libraries expect OpenGL to be in pretty much its default state upon calls to the lib (unless stated otherwise).
I can add this as a comment to the library to avoid confusion though :)

Do you have a good architectural reason for handling state in the lib?
Fixing/resetting the whole OpenGL state machine on each call would be quite a bit more than just resetting GL_BLEND. I don't think this should be part of all the library calls. The user knows best what states were changed and need to be reverted.

Kind regards,
ands

commented

Yes I think you can see it both ways, from my experience exposing a functionality in a lib should work deterministically, and be state agnostic. I think best/standard practice is to save/restore openGL states to keep determinism.

In my case I have a PBR rendering pipeline doing normal work then if/when required I spawn up a lightmap calculation (btw great code yours I like a lot your GPU solution). Usually the state in which openGL stack is upon request is not very easy to guesstimate. We also use imGUI as backdrop debug tool and they too have save/restore states.

PS: I'm using thekla to generate mesh charting on the fly, do you use their generated uv's as your primary uv for the scene_t, vertex_t inputs in your example.c sample? I think I'm still missing a connection in there as the lightmaps won't be generated correctly yet.

Cheers,
Dado.

commented

I'll take another look at dear imgui and see if I can afford to do the same here :).

Yes, I used thekla_atlas to generate the uv set for the example.
If you want, you can open another issue and show me the problems that you get.

Best regards,
ands

commented

Thanks, I'm 100% sure it's something wrong in my code anyway, I might open another issue to ask you how to deal with multiple bounces once I dig deeper in the code. (We are replacing our old SH pipeline so we are evaluating few alternatives)

Cheers,
Dado.