123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #pragma once
- #include <scenesrg_all.srgi>
- /*
- // Utilize the following PerDraw srg for instancing - currently not used yet.
- ShaderResourceGroup MeshletsInstanceRenderSrg : SRG_PerDraw
- {
- //! used object Id for instancing and matrix retrieval
- uint m_objectId;
- //! Returns the matrix for transforming points from Object Space to World Space.
- float4x4 GetWorldMatrix()
- {
- return SceneSrg::GetObjectToWorldMatrix(m_objectId);
- }
- //! Returns the inverse-transpose of the world matrix.
- //! Commonly used to transform normals while supporting non-uniform scale.
- float3x3 GetWorldMatrixInverseTranspose()
- {
- return SceneSrg::GetObjectToWorldInverseTransposeMatrix(m_objectId);
- }
- }
- */
- ShaderResourceGroup MeshletsObjectRenderSrg : SRG_PerObject
- {
- //--------------------------------------------------
- // This part should be moved outside the PerObject srg and used in the PerDraw
- // srg that represents the instance frequency.
- // object Id is used as an index for instancing and matrix retrieval in the
- // SceneSrg matrices arrays.
- uint m_objectId;
- //! Returns the matrix for transforming points from Object Space to World Space.
- float4x4 GetWorldMatrix()
- {
- return SceneSrg::GetObjectToWorldMatrix(m_objectId);
- }
- //! Returns the inverse-transpose of the world matrix.
- //! Commonly used to transform normals while supporting non-uniform scale.
- float3x3 GetWorldMatrixInverseTranspose()
- {
- return SceneSrg::GetObjectToWorldInverseTransposeMatrix(m_objectId);
- }
- //---------------------------------------------------
- // Vertex streams - currently we use Buffer<float> instead of the exact required
- // data type (float3 for example) because of alignment problem in Atom buffer
- // creation from a common pool.
- // [To Do] - change when supported to prevent offset calculation overhead.
- // Buffer<float3> m_positions;
- // Buffer<float3> m_normals;
- // Buffer<float4> m_tangents;
- // Buffer<float3> m_bitangents;
- Buffer<float> m_positions;
- Buffer<float> m_normals;
- Buffer<float4> m_tangents;
- Buffer<float> m_bitangents;
- Buffer<float2> m_uvs;
- float3 GetPosition(uint vertexIndex)
- {
- uint index = vertexIndex * 3;
- return float3(m_positions[index], m_positions[index+1], m_positions[index+2]);
- }
- float3 GetNormal(uint vertexIndex)
- {
- uint index = vertexIndex * 3;
- return float3(m_normals[index], m_normals[index+1], m_normals[index+2]);
- }
- float3 GetBiTangent(uint vertexIndex)
- {
- uint index = vertexIndex * 3;
- return float3(m_bitangents[index], m_bitangents[index+1], m_bitangents[index+2]);
- }
- // The last element of the tangents indicates face direction / winding
- float4 GetTangent(uint vertexIndex)
- {
- return m_tangents[vertexIndex];
- }
- float2 GetUV(uint vertexIndex)
- {
- return m_uvs[vertexIndex];
- }
- }
|