Skip to content
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

Improve outlining for solid geometry in glTFs #8776

Merged
merged 35 commits into from
Apr 28, 2020
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ae2bca1
WIP hacky outlines.
kring Apr 7, 2020
249d09b
Hacky proof of concept of outline rendering.
kring Apr 8, 2020
3cf02b5
Hacky but working outlines.
kring Apr 10, 2020
76b1d98
Outlines looking decent.
kring Apr 12, 2020
d51614c
Thicker lines, cleaner code.
kring Apr 13, 2020
69eedc0
Only copy vertices that can't be shared.
kring Apr 14, 2020
dcd47ac
Stick to ES5.
kring Apr 14, 2020
4262f6e
Cleanup.
kring Apr 14, 2020
b3a976f
Avoid redundant textures, cleanup.
kring Apr 15, 2020
36ec84f
Less assumptions about index layout.
kring Apr 15, 2020
2a68231
Generalize vertex buffer manipulation.
kring Apr 16, 2020
051c827
Merge remote-tracking branch 'origin/master' into fancy-outlines
kring Apr 16, 2020
ead5411
More cleanup.
kring Apr 16, 2020
d99e478
`@private` goes last.
kring Apr 19, 2020
a3c8432
Merge tag 'pre-prettier' into fancy-outlines
kring Apr 19, 2020
c63101d
Merge tag 'post-prettier' into fancy-outlines-merge
kring Apr 19, 2020
163eb8d
Merge remote-tracking branch 'origin/master' into fancy-outlines-merge
kring Apr 19, 2020
5ae15b4
Eslint
kring Apr 19, 2020
f2f8237
Cleanup.
kring Apr 19, 2020
8f62d7a
Only include outline-related shader code for primitives with an outline.
kring Apr 20, 2020
c855068
Put one more outline line inside a conditional.
kring Apr 20, 2020
f316ff2
Don't load outline texture if it's not needed.
kring Apr 20, 2020
890f0e0
Simplify outliner.
kring Apr 20, 2020
7b389fd
Don't need context to outline.
kring Apr 20, 2020
51cf940
Add outlining tests.
kring Apr 21, 2020
69ab0d8
Doc for GltfBuilder.
kring Apr 21, 2020
01408b1
Changes from review.
kring Apr 27, 2020
ef4c91b
Look up edges in a hash table instead of binary searching a sorted array
kring Apr 27, 2020
c5e8191
Add an ascii diagram.
kring Apr 27, 2020
86699bf
Update CHANGES.md.
kring Apr 27, 2020
722b139
Switch to 32-bit indices when we have more than 65536 vertices.
kring Apr 27, 2020
883c577
Fix incorrect comment.
kring Apr 27, 2020
b040e25
Add spec for index buffer enbiggening.
kring Apr 28, 2020
bda2c06
Fix typo in comment.
kring Apr 28, 2020
2722d81
Not all models have max specified on their index accessor.
kring Apr 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
@@ -3605,7 +3605,7 @@ function createUniformMaps(model, context) {
u.jointMatrixUniformName = uniforms.jointMatrixUniformName;
u.morphWeightsUniformName = uniforms.morphWeightsUniformName;

if (technique.attributes.a_outlineCoordinates) {
if (defined(technique.attributes.a_outlineCoordinates)) {
var outlineTexture = ModelOutlineLoader.createTexture(model, context);
u.uniformMap.u_outlineTexture = function () {
return outlineTexture;
15 changes: 10 additions & 5 deletions Source/Scene/ModelOutlineLoader.js
Original file line number Diff line number Diff line change
@@ -41,8 +41,12 @@ ModelOutlineLoader.outlinePrimitives = function (model) {
var gltf = model.gltf;

// Assumption: A single bufferView contains a single zero-indexed range of vertices.
// No trickery with using accessor byteOffsets to store multiple zero-based ranges of
// vertices in a single bufferView. Use separate bufferViews for that, you monster.
// No trickery with using large accessor byteOffsets to store multiple zero-based
// ranges of vertices in a single bufferView. Use separate bufferViews for that,
// you monster.
// Note that interleaved vertex attributes (e.g. position0, normal0, uv0,
// position1, normal1, uv1, ...) _are_ supported and should not be confused with
// the above.

var vertexNumberingScopes = [];

@@ -488,15 +492,16 @@ function updateBufferViewsWithNewVertices(model, bufferViews) {

var sourceData = loadResources.getBuffer(bufferView);
var byteStride = bufferView.byteStride || 4;
var newVerticesLength = newVertices.length;
var destData = new Uint8Array(
sourceData.byteLength + newVertices.length * byteStride
sourceData.byteLength + newVerticesLength * byteStride
);

// Copy the original vertices
destData.set(sourceData);

// Copy the vertices added for outlining
for (j = 0; j < newVertices.length; ++j) {
for (j = 0; j < newVerticesLength; ++j) {
var sourceIndex = newVertices[j] * byteStride;
var destIndex = sourceData.length + j * byteStride;
for (var k = 0; k < byteStride; ++k) {
@@ -525,7 +530,7 @@ function updateBufferViewsWithNewVertices(model, bufferViews) {
var accessors = vertexNumberingScope.accessors;
for (j = 0; j < accessors.length; ++j) {
var accessorId = accessors[j];
gltf.accessors[accessorId].count += newVertices.length;
gltf.accessors[accessorId].count += newVerticesLength;
}

if (!vertexNumberingScope.createdOutlines) {