-
Notifications
You must be signed in to change notification settings - Fork 250
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
Naive AO is ready for a first look! #96
Conversation
Ongoing things that we'll have to deal with:
|
Please refrain looking at this too deeply before next week. I might try to make some memory efficiency improvements before Monday, since frankly right now this is pretty alarming. I think the gist of the problem is in how I handle the texel points that the algorithm casts rays from. Currently at a high level the stage raytraces like this:
I think a big part of the problem is in the There may also be some space efficiency problems in storing the triangles using |
This is exciting news! Can you please:
|
Cool, thanks @likangning93! |
I don't know that it is needed, but this could be of interest: http://jcgt.org/published/0002/01/05/
Also add
These could also be 565 projects. |
…t as it is computed
So with the |
I think something is wrong with how |
The problem with the milk truck model is that its UVs aren't normalized, they're much bigger and get normalized in the shader using a hardcoded scaling parameter. The AO code currently does a pixel march over each triangle's AABB in UV space, so if the UV coordinates aren't normalized the march is 1) wrong and 2) seems to find far more "pixels" than it should. I'll throw an error for now if the pixel march code detects non-normalized UVs. |
@likangning93 You should be able to normalize them pretty easily if that makes sense. |
@lasalvavida I should have been more specific about what I meant by normalized. The model's UV coordinates are in a space from (small)-(big) by (small)-(big), but I would have to look in the shader to figure out how to map back to 0-1 x 0-1. Here's a picture of the vertex shader: I'm guessing this is a precision thing? |
As discussed offline, it looks like the milk truck model you have has oct-encoded normals. You should be able to grab a clean model from here. |
Thanks Rob! |
Can we also add a stage to un-encode oct-encoded normals? |
I can certainly decode the normal data easily enough, but un-modifying the shader is a pretty complex problem. |
Ah, right, I would not bother now since we have control of the pipeline and can just oct-encode after AO. |
Some changes I need to make along with the first round of comments:
|
|
||
function addNodeToSoup(parameters, node) { | ||
var transform = node.extras._pipeline.flatTransform; | ||
var mesheIDs = node.meshes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: should probably be meshIDs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, changed in NodeHelpers.js
… to run over only primitives in the scene. also small changes for efficiency
Updated! I think this is actually ready for a deeper look now. |
ao_scene : ao_scene, | ||
ao_rayDepth : ao_rayDepth, | ||
ao_resolution : ao_resolution, | ||
ao_samples : ao_samples, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps pack all the AO properties into an object. Also this makes it less verbose in gltfPipeline
.
Pretty minor comments here, I like the organization of the AO stage, it was easy to follow. As you already noted in your comments, it would be good to handle the case of creating ao textures even if no diffuse textures are present. Great start here! |
…ormed by inverse transpose
Updated! |
}; | ||
bakeAmbientOcclusion(gltfWithExtras, aoOptions); | ||
} | ||
bakeAmbientOcclusion(gltfWithExtras, options.aoOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a little clearer and more in-line with the other stages if we check if we can run the ao stage before going into the function.
if (defined(options.aoOptions) && options.aoOptions.runAO) {
bakeAmbientOcclusion(gltfWithExtras, options.aoOptions);
}
And possibly just remove runAO
altogether. As long as the ao options exist, it should be able to run the stage. This would require some edits in gltf-pipeline.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that makes sense... no idea why someone would have aoOptions but then not run the AO.
Updated! |
All good to me. Are there any other items on the checklist you plan on finishing before this is ready? They can all be separate PRs if you prefer. In terms of the ao workflow, we should have a dedicated ao branch and all ao-related pull requests would go into that branch. When ao is "done", we'll merge the ao branch into master. So once this is ready, can you close this PR, create an |
Last notes before closing:
|
moved to #102 |
Run:
node ./bin/gltf-pipeline.js ./specs/data/ambientOcclusion/cube_over_ground.gltf --ao_diffuse=true --ao_samples=128 --ao_rayDepth=1.0 --ao_resolution=64 -o hello_AO.gltf
This takes a couple seconds on my machine, but it's a really small model.
This version of naiveAO outputs a gltf with a separate image for each primitive and adds materials and textures as needed. It won't work with models that don't have any diffuse-textured materials, though, since it tries to find reference materials and textures to clone.
Tasks for this PR
Tasks for upcoming PRs
Cartesian3