-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Noisy lightmaps #10
Comments
Hi, What do you write into the alpha channels in your own surface fragment shaders? (should be 1.0 for front faces) Cheers :), |
My code is based on the example, so the shaders are the same. And I can't find anywhere that I'm clearing the framebuffer or changing anything before drawing. My call to lmCreate() looks like this:
Then I'm calling lmSetTargetLightmap(), then lmSetGeometry(), then the lmBegin()/lmEnd() loop. The full source is here: https://github.com/braddabug/thegame/tree/master/Tools/LightmapTool It's got to be some little thing I'm doing wrong. I checked with Valgrind on Linux and it didn't report anything. OpenGL doesn't complain about anything either. |
Hi braddabug,
thanks for supplying code that I can use to reproduce the issue :).
I'll see if I can get this compiled and running tomorrow, because I
didn't see anything obviously wrong by quickly reading through the code.
Btw.: Did you check the polygon winding on your loaded mesh(es)?
Kind regards,
Andreas
|
Hey :) lm_context *ctx = lmCreate( It will be slower and there's still some minor noise on some wall parts. |
Thanks! Now that I think about it that makes perfect sense. The tiny point light will eventually become a directional "sun" light. Maybe it'd be best to investigate representing the entire sky as an HDR floating-point cubemap, that way aliasing becomes less of an issue since the cubemap can easily be filtered/smoothed. I think. |
You could ray trace the directional sun light using Embree. Use the lightmapper rasterizer to get the worldspace position of each luxel, then trace a ray in the direction of the sun to see if it's occluded. For smoother shadows, take multiple samples with jittered sampling positions and average them. Then run the lightmapper to get bounce lighting. |
If you want to use this lib for indirect lighting, you could also render your scene with the usual direct scene lighting during baking (a static shadow map, materials, point/directional/spotlights, etc.) |
I think that will work. I modified my code to do a initial pass where I shoot a ray from each texel to the light, and that calculates pretty nice direct lighting. Then I feed that in to the emissive texture and start the indirect lighting passes. It looks quite a bit nicer. Practically no noise! I did have to modify lightmapper.h to get things like the lightmap texel position (world coords and texel coords) and normal since the contents of lm_context are hidden. I just added this function:
EDIT: I tweaked the code a little bit. I wanted the hemisphere side index, but I guess I was getting the hemisphere index instead. |
I'm having a weird problem that I can't figure out. You can see a screenshot and the generated lightmap here: https://imgur.com/a/2NqIT
It's like some of the samples are just wrong (usually black instead of grayish, but sometimes white), as if depending on the hemisphere orientation the light is either visible or not visible, but that's wild speculation. I tried turning off interpolation to render all the hemispheres, but that didn't help.
The text was updated successfully, but these errors were encountered: