Parcourir la source

ModelLibrary shaders allows for external uv transform shaders.

clementlandrin il y a 11 mois
Parent
commit
24f7f389d8
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6 2
      hrt/prefab/l3d/ModelLibrary.hx

+ 6 - 2
hrt/prefab/l3d/ModelLibrary.hx

@@ -174,14 +174,18 @@ class ModelLibShader extends hxsl.Shader {
 		}
 		}
 
 
 		function __init__vertex() {
 		function __init__vertex() {
-			calculatedUV = clamp(input2.uv.fract(), libraryParams.y, 1.0 - libraryParams.y);
-			calculatedUV = calculatedUV * uvTransform.zw + uvTransform.xy;
+			calculatedUV = input2.uv;
 			previousTransformedPosition = transformedPosition;
 			previousTransformedPosition = transformedPosition;
 			if( hasNormal )
 			if( hasNormal )
 				transformedTangent = vec4(input2.tangent * global.modelView.mat3(),input2.tangent.dot(input2.tangent) > 0.5 ? 1. : -1.);
 				transformedTangent = vec4(input2.tangent * global.modelView.mat3(),input2.tangent.dot(input2.tangent) > 0.5 ? 1. : -1.);
 			mipLevel = pow(saturate((projectedPosition.z - mipStart) / (mipEnd - mipStart)), mipPower) * mipNumber;
 			mipLevel = pow(saturate((projectedPosition.z - mipStart) / (mipEnd - mipStart)), mipPower) * mipNumber;
 		}
 		}
 
 
+		function fragment() {
+			calculatedUV = clamp(calculatedUV.fract(), libraryParams.y, 1.0 - libraryParams.y);
+			calculatedUV = calculatedUV * uvTransform.zw + uvTransform.xy;
+		}
+
 		function __init__fragment() {
 		function __init__fragment() {
 			pixelColor = singleTexture ? texture.getLod(calculatedUV, 0.0) : textures.getLod(vec3(calculatedUV, libraryParams.x), 0.0);
 			pixelColor = singleTexture ? texture.getLod(calculatedUV, 0.0) : textures.getLod(vec3(calculatedUV, libraryParams.x), 0.0);
 			if( hasNormal ) {
 			if( hasNormal ) {