-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add support for custom glTF vertex attributes. #5370
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
Merged
alice-i-cecile
merged 30 commits into
bevyengine:main
from
komadori:gltf-custom-attributes
Apr 24, 2023
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
fcebe9a
Add support for custom glTF vertex attributes.
komadori fda7b43
Fix AddCustomVertexAttributeExt.
komadori 40088ca
Remove 'glTF' from warning strings since logger prints context.
komadori e56173a
Fix formatting.
komadori b0df749
Fix clippy doc lint.
komadori ebe7c5b
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori a0aeb43
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 99d97eb
Explicitly derive Resource trait for GltfConfiguration.
komadori a5c2beb
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 26c0d55
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 855b4df
Replace configuration resource with plugin settings.
komadori 370214f
Fix signature of add_custom_vertex_attribute().
komadori fde3461
Add example using a custom glTF vertex attribute.
komadori 322a122
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 645bd62
Update example pages.
komadori 0e41c30
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 0527579
Add explanitory comments to custom_gltf_2d example.
komadori def0fa0
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori a3dd678
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 1a61d05
Fix use of deprecated method add_startup_system().
komadori 8ebb525
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori 262244e
Refactor glTF attribute marshalling into a separate module.
komadori 7a7f149
Tidy up attribute conversion error handling.
komadori e037078
Tighten attrs module code.
komadori 1fc64df
Change barycentric model from glb to non-binary glTF format.
komadori 8c02a4b
Rename bevy_gltf::attrs module to vertex_attributes.
komadori 3ed7225
Rename custom_gltf_2d example to custom_gltf_vertex_attribute.
komadori 94179e3
Merge branch 'main' of github.com:komadori/bevy into gltf-custom-attr…
komadori e30d883
Fix rustfmt.
komadori 92f65ed
Update examples.
komadori File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"accessors": [ | ||
{ | ||
"bufferView": 0, | ||
"byteOffset": 0, | ||
"count": 4, | ||
"componentType": 5126, | ||
"type": "VEC3", | ||
"min": [ | ||
-1.0, | ||
-1.0, | ||
0.0 | ||
], | ||
"max": [ | ||
1.0, | ||
1.0, | ||
0.0 | ||
] | ||
}, | ||
{ | ||
"bufferView": 0, | ||
"byteOffset": 12, | ||
"count": 4, | ||
"componentType": 5126, | ||
"type": "VEC4" | ||
}, | ||
{ | ||
"bufferView": 0, | ||
"byteOffset": 28, | ||
"count": 4, | ||
"componentType": 5126, | ||
"type": "VEC3" | ||
}, | ||
{ | ||
"bufferView": 1, | ||
"byteOffset": 0, | ||
"count": 6, | ||
"componentType": 5123, | ||
"type": "SCALAR" | ||
} | ||
], | ||
"asset": { | ||
"version": "2.0" | ||
}, | ||
"buffers": [ | ||
{ | ||
"byteLength": 172, | ||
"uri": "data:application/gltf-buffer;base64,AACAvwAAgL8AAAAAAACAPwAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAgD8AAIC/AAAAAAAAAD8AAAA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIC/AACAPwAAAAAAAAA/AAAAPwAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAgD8AAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAAAAAAQACAAIAAQADAA==" | ||
} | ||
], | ||
"bufferViews": [ | ||
{ | ||
"buffer": 0, | ||
"byteLength": 160, | ||
"byteOffset": 0, | ||
"byteStride": 40, | ||
"target": 34962 | ||
}, | ||
{ | ||
"buffer": 0, | ||
"byteLength": 12, | ||
"byteOffset": 160, | ||
"target": 34962 | ||
} | ||
], | ||
"meshes": [ | ||
{ | ||
"primitives": [ | ||
{ | ||
"attributes": { | ||
"POSITION": 0, | ||
"COLOR_0": 1, | ||
"__BARYCENTRIC": 2 | ||
}, | ||
"indices": 3 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#import bevy_sprite::mesh2d_view_bindings | ||
#import bevy_sprite::mesh2d_bindings | ||
#import bevy_sprite::mesh2d_functions | ||
|
||
struct Vertex { | ||
@location(0) position: vec3<f32>, | ||
@location(1) color: vec4<f32>, | ||
@location(2) barycentric: vec3<f32>, | ||
}; | ||
|
||
struct VertexOutput { | ||
@builtin(position) clip_position: vec4<f32>, | ||
@location(0) color: vec4<f32>, | ||
@location(1) barycentric: vec3<f32>, | ||
}; | ||
|
||
@vertex | ||
fn vertex(vertex: Vertex) -> VertexOutput { | ||
var out: VertexOutput; | ||
out.clip_position = mesh2d_position_local_to_clip(mesh.model, vec4<f32>(vertex.position, 1.0)); | ||
out.color = vertex.color; | ||
out.barycentric = vertex.barycentric; | ||
return out; | ||
} | ||
|
||
struct FragmentInput { | ||
@location(0) color: vec4<f32>, | ||
@location(1) barycentric: vec3<f32>, | ||
}; | ||
|
||
@fragment | ||
fn fragment(input: FragmentInput) -> @location(0) vec4<f32> { | ||
let d = min(input.barycentric.x, min(input.barycentric.y, input.barycentric.z)); | ||
let t = 0.05 * (0.85 + sin(5.0 * globals.time)); | ||
return mix(vec4(1.0,1.0,1.0,1.0), input.color, smoothstep(t, t+0.01, d)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.