Primitive Mode TRIANGLE_STRIP and TRIANGLE_FAN implementation, LINE_LOOP render fix #22
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.
According to these two issues;
LINE_LOOP
atteneder/glTFast#689These primitive modes are not implemented:
TRIANGLE_STRIP
TRIANGLE_FAN
And this primitive mode is not rendered correctly:
LINE_LOOP
TRIANGLE_STRIP
andTRIANGLE_FAN
implementationFirst of all, we need example assets for the two primitive mode implementations (
TRIANGLE_STRIP
,TRIANGLE_FAN
)We can find those assets from these two links;
First link includes a gltf file with all the primitive modes embedded in one file. Second one has seperate gltf files where each one is a different primitive mode.
In order to correctly implement these triangle primitive modes gltf-2.0 specification documentation of Khronos Group was used;
From this documentation these two formulas was used;
Triangle Strips
One triangle primitive is defined by each vertex and the two vertices that follow it, according to the equation:
Triangle Fans
Triangle primitives are defined around a shared common vertex, according to the equation:
Since it was necessary to create the indices from scratch this change was necessary;
before
after
In order to check if the results was correct gltf viewer of Khronos group was used;
Since I couldn't find any other example assets I used blender to generate them. These are the steps to do so;
TRIANGLE
to 5TRIANGLE_STRIP
or 6TRIANGLE_FAN
)I am not sure if using blender was correct way to check that but the original assets were correctly imported.
LINE_LOOP
render display fixAs stated in the issue it was needed to add one more index to the end of the original index list. In line 3661
Array.Copy
was used (I don't know if Job system was supposed to be used here too)Unity version 2022.3.38f1 was used in this PR