Browse Source

fixed TBytes4 returning floats and requiring explicit ToInt

Nicolas Cannasse 4 years ago
parent
commit
875e101f93
4 changed files with 16 additions and 17 deletions
  1. 6 6
      h3d/shader/Skin.hx
  2. 9 9
      h3d/shader/SkinTangent.hx
  3. 1 1
      hxsl/Checker.hx
  4. 0 1
      hxsl/Flatten.hx

+ 6 - 6
h3d/shader/Skin.hx

@@ -15,13 +15,13 @@ class Skin extends SkinBase {
 
 		function vertex() {
 			transformedPosition =
-				(relativePosition * bonesMatrixes[input.indexes.x]) * input.weights.x +
-				(relativePosition * bonesMatrixes[input.indexes.y]) * input.weights.y +
-				(relativePosition * bonesMatrixes[input.indexes.z]) * input.weights.z;
+				(relativePosition * bonesMatrixes[int(input.indexes.x)]) * input.weights.x +
+				(relativePosition * bonesMatrixes[int(input.indexes.y)]) * input.weights.y +
+				(relativePosition * bonesMatrixes[int(input.indexes.z)]) * input.weights.z;
 			transformedNormal = normalize(
-				(input.normal * mat3(bonesMatrixes[input.indexes.x])) * input.weights.x +
-				(input.normal * mat3(bonesMatrixes[input.indexes.y])) * input.weights.y +
-				(input.normal * mat3(bonesMatrixes[input.indexes.z])) * input.weights.z);
+				(input.normal * mat3(bonesMatrixes[int(input.indexes.x)])) * input.weights.x +
+				(input.normal * mat3(bonesMatrixes[int(input.indexes.y)])) * input.weights.y +
+				(input.normal * mat3(bonesMatrixes[int(input.indexes.z)])) * input.weights.z);
 		}
 
 	};

+ 9 - 9
h3d/shader/SkinTangent.hx

@@ -16,17 +16,17 @@ class SkinTangent extends SkinBase {
 
 		function vertex() {
 			transformedPosition =
-				(relativePosition * bonesMatrixes[input.indexes.x]) * input.weights.x +
-				(relativePosition * bonesMatrixes[input.indexes.y]) * input.weights.y +
-				(relativePosition * bonesMatrixes[input.indexes.z]) * input.weights.z;
+				(relativePosition * bonesMatrixes[int(input.indexes.x)]) * input.weights.x +
+				(relativePosition * bonesMatrixes[int(input.indexes.y)]) * input.weights.y +
+				(relativePosition * bonesMatrixes[int(input.indexes.z)]) * input.weights.z;
 			transformedNormal = normalize(
-				(input.normal * mat3(bonesMatrixes[input.indexes.x])) * input.weights.x +
-				(input.normal * mat3(bonesMatrixes[input.indexes.y])) * input.weights.y +
-				(input.normal * mat3(bonesMatrixes[input.indexes.z])) * input.weights.z);
+				(input.normal * mat3(bonesMatrixes[int(input.indexes.x)])) * input.weights.x +
+				(input.normal * mat3(bonesMatrixes[int(input.indexes.y)])) * input.weights.y +
+				(input.normal * mat3(bonesMatrixes[int(input.indexes.z)])) * input.weights.z);
 			transformedTangent = vec4(normalize(
-				(input.tangent.xyz * mat3(bonesMatrixes[input.indexes.x])) * input.weights.x +
-				(input.tangent.xyz * mat3(bonesMatrixes[input.indexes.y])) * input.weights.y +
-				(input.tangent.xyz * mat3(bonesMatrixes[input.indexes.z])) * input.weights.z
+				(input.tangent.xyz * mat3(bonesMatrixes[int(input.indexes.x)])) * input.weights.x +
+				(input.tangent.xyz * mat3(bonesMatrixes[int(input.indexes.y)])) * input.weights.y +
+				(input.tangent.xyz * mat3(bonesMatrixes[int(input.indexes.z)])) * input.weights.z
 			), transformedTangent.w);
 		}
 

+ 1 - 1
hxsl/Checker.hx

@@ -939,7 +939,7 @@ class Checker {
 		case TInt: stype = VInt; 1;
 		case TBool: stype = VBool; 1;
 		case TVec(size, t): stype = t; size;
-		case TBytes(size): stype = VInt; size;
+		case TBytes(size): stype = VFloat; size;
 		default: stype = null; 0;
 		}
 		if( ncomps > 0 && f.length <= 4 ) {

+ 0 - 1
hxsl/Flatten.hx

@@ -122,7 +122,6 @@ class Flatten {
 					var stride = varSize(t, a.t);
 					if( stride == 0 || stride & 3 != 0 ) throw new Error("Dynamic access to an Array which size is not 4 components-aligned is not allowed", e.p);
 					stride >>= 2;
-					eindex.t = TFloat; // force
 					eindex = toInt(mapExpr(eindex));
 					access(a, t, vp, AOffset(a,stride, stride == 1 ? eindex : { e : TBinop(OpMult,eindex,mkInt(stride,vp)), t : TInt, p : vp }));
 				default: