Comments (8)
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.
from lightmapper.
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:
void lmTexelInfo(lm_context* ctx, float* outWorldPos, float* outDirection, int* outTexelCoord, int* hemisphereSideIndex)
{
if (outWorldPos)
{
outWorldPos[0] = ctx->meshPosition.sample.position.x;
outWorldPos[1] = ctx->meshPosition.sample.position.y;
outWorldPos[2] = ctx->meshPosition.sample.position.z;
}
if (outDirection)
{
outDirection[0] = ctx->meshPosition.sample.direction.x;
outDirection[1] = ctx->meshPosition.sample.direction.y;
outDirection[2] = ctx->meshPosition.sample.direction.z;
}
if (outTexelCoord)
{
outTexelCoord[0] = ctx->meshPosition.rasterizer.x;
outTexelCoord[1] = ctx->meshPosition.rasterizer.y;
}
if (hemisphereSideIndex)
{
hemisphereSideIndex[0] = ctx->meshPosition.hemisphere.side;
}
}
EDIT: I tweaked the code a little bit. I wanted the hemisphere side index, but I guess I was getting the hemisphere index instead.
from lightmapper.
Hi,
What do you write into the alpha channels in your own surface fragment shaders? (should be 1.0 for front faces)
Do you maybe clear the framebuffer on your own? Or change the target framebuffer/viewport/scissor rect?
Do you modify the matrices before multiplying them with the vertex positions?
What are your lmCreate parameters and api call order?
Cheers :),
Andreas
from lightmapper.
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:
lm_context *ctx = lmCreate(
64, // hemisphere resolution (power of two, max=512)
0.01f, 200.0f, // zNear, zFar of hemisphere cameras
0, 0, 0, // background color (white for ambient occlusion)
0, 0.00f); // lightmap interpolation threshold (small differences are interpolated rather than sampled)
// check debug_interpolation.tga for an overview of sampled (red) vs interpolated (green) pixels.
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.
from lightmapper.
from lightmapper.
Hey :)
First I thought that the noise looked very random, but after building and running your tool I quickly realized that you are using a very tiny light source. So, the noise is just a very severe undersampling artifact.
I actually got ok-ish results when increasing the hemisphere rendering resolution. Try these parameters:
lm_context *ctx = lmCreate(
512, // hemisphere resolution (power of two, max=512)
0.01f, 200.0f, // zNear, zFar of hemisphere cameras
ambientRed, ambientGreen, ambientBlue, // background color (white for ambient occlusion)
3, 0.01f);
It will be slower and there's still some minor noise on some wall parts.
You can easily get rid of noise artifacts (and thus improve performance, because you don't need such a high hemisphere rendering resolution) by using larger light sources, if applicable.
Here's a shot with two bounces:
from lightmapper.
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.
from lightmapper.
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.)
from lightmapper.
Related Issues (20)
- Assert fail on boundary check HOT 5
- hemispheres float texture always NaN if glDisable( GL_BLEND ); not issued beforehand HOT 4
- Shadow baking HOT 3
- License HOT 3
- Any further documentation ? HOT 10
- Baking a thickness texture HOT 2
- readme.md: uvatlas is now on Github HOT 1
- Duplicate Normalize line in the lightmapper code
- TrianglePacker is nessary?
- Can I decide which lightmap gets baked? HOT 2
- Lightmapper generates weird grey-ish margin? HOT 1
- About Spherical Harmonics
- Radiosity Normal Mapping?
- Normals get transformed twice
- Slow?
- Proper obj format HOT 5
- Lighting setup guide HOT 4
- Normal oriented HOT 2
- Small request for help - lightmapper in Qt HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightmapper.