From 03c4458bdcc6821a3047f93b729d412e274ab9af Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 20 May 2024 13:22:55 -0500 Subject: #1392 GLTF Upload (#1394) * #1392 WIP -- Functional texture upload, stubbed out .bin upload. * #1392 GLTF Upload WIP -- Emulates successful upload Successfully uploads texture Emulates successful .gltf and .bin upload by injecting into local asset cache. Emulates rez from inventory by setting sculpt ID of selected object Currently fails in tinygltf parsing due to missing .bin * Add missing notification * Build fix * #1392 Add boost::json .gltf reading support. * #1392 boost::json GLTF writing prototype * Create gltf/README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * #1392 Add ability to render directly from LL::GLTF::Material * Fix for mac build * Mac build fix * #1392 AssetType and Inventory Type plumbing * #1392 More sane error handling and scheduling of uploads. * #1392 Actually attempt to upload glbin * Mac build fix, upload nudge * Mac build fix * Fix glTF asset uploads to server * Mac build fix (inline not static) * More consistent inline * Add glm, mac nudge. * #1392 For consistency with spec, start using glm over glh:: and LLFoo * Another attempt at placating Mac builds * Another Mac nudge * Mac build take 23 * #1392 Prune LLMatrix4a from GLTF namespace. * #1392 Fix for orientation being off (glm::quat is wxyz, not xyzw) * #1392 WIP -- Actually send the sculpt type and id, nudge readme and alpha rendering * #1392 Working download! * #1394 Add support for GLTFEnabled SimulatorFeature * #1392 Review feedback --------- Co-authored-by: Pepper Linden <3782201+rohvani@users.noreply.github.com> --- indra/newview/gltf/primitive.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/gltf/primitive.h') diff --git a/indra/newview/gltf/primitive.h b/indra/newview/gltf/primitive.h index 07e8e7deb2..18aadce808 100644 --- a/indra/newview/gltf/primitive.h +++ b/indra/newview/gltf/primitive.h @@ -28,12 +28,14 @@ #include "llvertexbuffer.h" #include "llvolumeoctree.h" +#include "boost/json.hpp" // LL GLTF Implementation namespace LL { namespace GLTF { + using Value = boost::json::value; class Asset; constexpr U32 ATTRIBUTE_MASK = @@ -66,10 +68,10 @@ namespace LL std::vector mOctreeTriangles; S32 mMaterial = -1; - U32 mMode = TINYGLTF_MODE_TRIANGLES; // default to triangles + S32 mMode = TINYGLTF_MODE_TRIANGLES; // default to triangles U32 mGLMode = LLRender::TRIANGLES; S32 mIndices = -1; - std::unordered_map mAttributes; + std::unordered_map mAttributes; // create octree based on vertex buffer // must be called before buffer is unmapped and after buffer is populated with good data @@ -85,6 +87,8 @@ namespace LL LLVector4a* tangent = NULL // return the surface tangent at the intersection point ); + void serialize(boost::json::object& obj) const; + const Primitive& operator=(const Value& src); const Primitive& operator=(const tinygltf::Primitive& src); void allocateGLResources(Asset& asset); -- cgit v1.2.3 From 2f4120038429c6aff865f153f708ceefb60d67f4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 May 2024 09:45:40 -0500 Subject: Remove tinygltf dependency from LL::GLTF (#1541) * #1535 Image loading/saving support in boost::json driven GLTF parser * #1536 GLB Support in boost::json drvien GLTF parser --- indra/newview/gltf/primitive.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'indra/newview/gltf/primitive.h') diff --git a/indra/newview/gltf/primitive.h b/indra/newview/gltf/primitive.h index 18aadce808..9914ff3b08 100644 --- a/indra/newview/gltf/primitive.h +++ b/indra/newview/gltf/primitive.h @@ -48,6 +48,17 @@ namespace LL class Primitive { public: + enum class Mode : U8 + { + POINTS, + LINES, + LINE_LOOP, + LINE_STRIP, + TRIANGLES, + TRIANGLE_STRIP, + TRIANGLE_FAN + }; + ~Primitive(); // GPU copy of mesh data @@ -66,10 +77,10 @@ namespace LL // raycast acceleration structure LLPointer mOctree; std::vector mOctreeTriangles; - + S32 mMaterial = -1; - S32 mMode = TINYGLTF_MODE_TRIANGLES; // default to triangles - U32 mGLMode = LLRender::TRIANGLES; + Mode mMode = Mode::TRIANGLES; // default to triangles + LLRender::eGeomModes mGLMode = LLRender::TRIANGLES; // for use with LLRender S32 mIndices = -1; std::unordered_map mAttributes; @@ -77,7 +88,7 @@ namespace LL // must be called before buffer is unmapped and after buffer is populated with good data void createOctree(); - //get the LLVolumeTriangle that intersects with the given line segment at the point + //get the LLVolumeTriangle that intersects with the given line segment at the point //closest to start. Moves end to the point of intersection. Returns nullptr if no intersection. //Line segment must be in the same coordinate frame as this Primitive const LLVolumeTriangle* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, @@ -86,12 +97,11 @@ namespace LL LLVector4a* normal = NULL, // return the surface normal at the intersection point LLVector4a* tangent = NULL // return the surface tangent at the intersection point ); - + void serialize(boost::json::object& obj) const; const Primitive& operator=(const Value& src); - const Primitive& operator=(const tinygltf::Primitive& src); - void allocateGLResources(Asset& asset); + bool prep(Asset& asset); }; } } -- cgit v1.2.3 From 227e9be06832515fd10eb496d4a2a4528d1ebd92 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 10 Jun 2024 10:43:38 -0500 Subject: #1654 generate normals and tangents according to gltf specification (#1662) * Disable unloading of objects in background. * Add unlit GLTF shader variant --- indra/newview/gltf/primitive.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'indra/newview/gltf/primitive.h') diff --git a/indra/newview/gltf/primitive.h b/indra/newview/gltf/primitive.h index 9914ff3b08..f9d7c63c65 100644 --- a/indra/newview/gltf/primitive.h +++ b/indra/newview/gltf/primitive.h @@ -38,13 +38,6 @@ namespace LL using Value = boost::json::value; class Asset; - constexpr U32 ATTRIBUTE_MASK = - LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_NORMAL | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_TANGENT | - LLVertexBuffer::MAP_COLOR; - class Primitive { public: @@ -64,12 +57,12 @@ namespace LL // GPU copy of mesh data LLPointer mVertexBuffer; - // CPU copy of mesh data + // CPU copy of mesh data, keep these as LLVector types for compatibility with raycasting code std::vector mTexCoords; std::vector mNormals; std::vector mTangents; std::vector mPositions; - std::vector mJoints; + std::vector mJoints; std::vector mWeights; std::vector mColors; std::vector mIndexArray; @@ -82,6 +75,10 @@ namespace LL Mode mMode = Mode::TRIANGLES; // default to triangles LLRender::eGeomModes mGLMode = LLRender::TRIANGLES; // for use with LLRender S32 mIndices = -1; + + // shader variant according to LLGLSLShader::GLTFVariant flags + U8 mShaderVariant = 0; + std::unordered_map mAttributes; // create octree based on vertex buffer -- cgit v1.2.3 From f40fbdf4ad27a547e30781cd44cd6847d68d3300 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 11 Jun 2024 17:10:13 -0500 Subject: #1718 Add GLTF support for multiple texcoords (#1720) * Fix for GLTF MeshPrimitiveModes test --- indra/newview/gltf/primitive.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/gltf/primitive.h') diff --git a/indra/newview/gltf/primitive.h b/indra/newview/gltf/primitive.h index f9d7c63c65..7cc05cf831 100644 --- a/indra/newview/gltf/primitive.h +++ b/indra/newview/gltf/primitive.h @@ -58,7 +58,8 @@ namespace LL LLPointer mVertexBuffer; // CPU copy of mesh data, keep these as LLVector types for compatibility with raycasting code - std::vector mTexCoords; + std::vector mTexCoords0; + std::vector mTexCoords1; std::vector mNormals; std::vector mTangents; std::vector mPositions; -- cgit v1.2.3 From 80ea30af1a8b38360f71c29cc45872c4399dab0d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 21 Jun 2024 13:13:08 -0500 Subject: #1769 gltf optimization pass (#1816) #1814 and #1517 Fix mirror update rate and occlusion culling --- indra/newview/gltf/primitive.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/newview/gltf/primitive.h') diff --git a/indra/newview/gltf/primitive.h b/indra/newview/gltf/primitive.h index 7cc05cf831..304eb26432 100644 --- a/indra/newview/gltf/primitive.h +++ b/indra/newview/gltf/primitive.h @@ -54,10 +54,7 @@ namespace LL ~Primitive(); - // GPU copy of mesh data - LLPointer mVertexBuffer; - - // CPU copy of mesh data, keep these as LLVector types for compatibility with raycasting code + // CPU copy of mesh data std::vector mTexCoords0; std::vector mTexCoords1; std::vector mNormals; @@ -80,6 +77,17 @@ namespace LL // shader variant according to LLGLSLShader::GLTFVariant flags U8 mShaderVariant = 0; + // vertex attribute mask + U32 mAttributeMask = 0; + + // backpointer to vertex buffer (owned by Asset) + LLPointer mVertexBuffer; + U32 mVertexOffset = 0; + U32 mIndexOffset = 0; + + U32 getVertexCount() const { return (U32) mPositions.size(); } + U32 getIndexCount() const { return (U32) mIndexArray.size(); } + std::unordered_map mAttributes; // create octree based on vertex buffer @@ -100,6 +108,11 @@ namespace LL const Primitive& operator=(const Value& src); bool prep(Asset& asset); + + // upload geometry to given vertex buffer + // asserts that buffer is bound + // asserts that buffer is valid for this primitive + void upload(LLVertexBuffer* buffer); }; } } -- cgit v1.2.3