From f59de9b55e3e52d6dc17b384d96092db3a0f20ef Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 30 May 2023 12:54:26 +0900 Subject: [PATCH] [Tizen] Let we use integer uniform for shader Since we cannot believe float to integer convertor, Let we use integer uniform value register without float conversion Change-Id: Idf740687b51b73a00db77eb4a784f0acef73f5df Signed-off-by: Eunki, Hong --- .../shaders/default-physically-based-shader.vert | 16 +++++++--------- dali-scene3d/public-api/loader/blend-shape-details.cpp | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert index 8ca91ea..d57d974 100644 --- a/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert +++ b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert @@ -46,14 +46,14 @@ uniform mat4 uProjection; #ifdef MORPH #define MAX_BLEND_SHAPE_NUMBER 128 -uniform float uNumberOfBlendShapes; ///< Total number of blend shapes loaded. +uniform int uNumberOfBlendShapes; ///< Total number of blend shapes loaded. uniform highp float uBlendShapeWeight[MAX_BLEND_SHAPE_NUMBER]; ///< The weight of each blend shape. #ifdef MORPH_VERSION_2_0 uniform highp float uBlendShapeUnnormalizeFactor; ///< Factor used to unnormalize the geometry of the blend shape. #else uniform highp float uBlendShapeUnnormalizeFactor[MAX_BLEND_SHAPE_NUMBER]; ///< Factor used to unnormalize the geometry of the blend shape. #endif -uniform highp float uBlendShapeComponentSize; ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them. +uniform highp int uBlendShapeComponentSize; ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them. #endif void main() @@ -66,10 +66,8 @@ void main() int width = textureSize( sBlendShapeGeometry, 0 ).x; highp int blendShapeBufferOffset = 0; - highp int blendShapeComponentSize = int(uBlendShapeComponentSize); - int numberOfBlendShapes = int(uNumberOfBlendShapes); - for( int index = 0; index < numberOfBlendShapes; ++index ) + for( int index = 0; index < uNumberOfBlendShapes; ++index ) { highp vec3 diff = vec3(0.0); highp int vertexId = 0; @@ -96,12 +94,12 @@ void main() position.xyz += diff; - blendShapeBufferOffset += blendShapeComponentSize; + blendShapeBufferOffset += uBlendShapeComponentSize; #endif #ifdef MORPH_NORMAL // Calculate the index to retrieve the normal from the texture. - vertexId = gl_VertexID + int(blendShapeBufferOffset); + vertexId = gl_VertexID + blendShapeBufferOffset; x = vertexId % width; y = vertexId / width; @@ -113,7 +111,7 @@ void main() normal += diff.xyz; - blendShapeBufferOffset += blendShapeComponentSize; + blendShapeBufferOffset += uBlendShapeComponentSize; #endif #ifdef MORPH_TANGENT @@ -130,7 +128,7 @@ void main() tangent += diff.xyz; - blendShapeBufferOffset += blendShapeComponentSize; + blendShapeBufferOffset += uBlendShapeComponentSize; #endif } diff --git a/dali-scene3d/public-api/loader/blend-shape-details.cpp b/dali-scene3d/public-api/loader/blend-shape-details.cpp index f854fa7..7c947f8 100644 --- a/dali-scene3d/public-api/loader/blend-shape-details.cpp +++ b/dali-scene3d/public-api/loader/blend-shape-details.cpp @@ -38,7 +38,7 @@ const char* BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight"); void BlendShapes::ConfigureProperties(const BlendShapeData& data, Renderer renderer) { - unsigned int index = 0u; + uint32_t index = 0u; char weightNameBuffer[32]; char unnormalizeFactorNameBuffer[64]; @@ -71,8 +71,8 @@ void BlendShapes::ConfigureProperties(const BlendShapeData& data, Renderer rende renderer.RegisterProperty(UNNORMALIZE_FACTOR, data.unnormalizeFactors[0u]); } - renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast(index))); - renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast(data.bufferOffset))); + renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast(index))); + renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast(data.bufferOffset))); // Create a read only property to preserve the components of the blend shape. renderer.RegisterProperty(COMPONENTS, data.components, Property::AccessMode::READ_ONLY); -- 2.7.4