This is a shader defined by unityfunction,I try to convert it to babylon
inline float4 TriplanarSampling26( sampler2D topTexMap, float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float3 index )
{
float3 projNormal = ( pow( abs( worldNormal ), falloff ) );
projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001;
float3 nsign = sign( worldNormal );
half4 xNorm; half4 yNorm; half4 zNorm;
xNorm = tex2Dlod( topTexMap, float4(tiling * worldPos.zy * float2( nsign.x, 1.0 ), 0, 0) );
yNorm = tex2Dlod( topTexMap, float4(tiling * worldPos.xz * float2( nsign.y, 1.0 ), 0, 0) );
zNorm = tex2Dlod( topTexMap, float4(tiling * worldPos.xy * float2( -nsign.z, 1.0 ), 0, 0) );
return xNorm * projNormal.x + yNorm * projNormal.y + zNorm * projNormal.z;
}
I convert float to vec,But I have encountered many problems
My questions:
Question1.
vec3 projNormal = ( pow( abs( worldNormal ), falloff ) );
ERROR:
BJS - [17:27:50]: Error: VERTEX SHADER ERROR: 0:17: ‘pow’ : no matching overloaded function found
ERROR: 0:17: ‘=’ : dimension mismatch
ERROR: 0:17: ‘=’ : cannot convert from ‘const mediump float’ to ‘highp 3-component vector of float’
ERROR: 0:20: ‘half4’ : undeclared identifier
ERROR: 0:20: ‘xNorm’ : syntax error
i changed “falloff” to vec3(falloff),Is this correct?
Question2:
half4 xNorm; half4 yNorm; half4 zNorm;
ERROR:
BJS - [17:32:06]: Error: VERTEX SHADER ERROR: 0:20: ‘half4’ : undeclared identifier
ERROR: 0:20: ‘xNorm’ : syntax error
i changed “half4” to vec4,Is this correct?
Question3:
xNorm = tex2Dlod( topTexMap, vec4(tiling * worldPos.zy * vec2( nsign.x, 1.0 ), 0, 0) );
ERROR:
BJS - [17:37:27]: Error: VERTEX SHADER ERROR: 0:23: ‘tex2Dlod’ : no matching overloaded function found
ERROR: 0:23: ‘=’ : dimension mismatch
ERROR: 0:23: ‘assign’ : cannot convert from ‘const mediump float’ to ‘highp 4-component vector of float’
ERROR: 0:24: ‘tex2Dlod’ : no matching overloaded function found
ERROR: 0:24: ‘=’ : dimension mismatch
ERROR: 0:24: ‘assign’ : cannot convert from ‘const mediump float’ to ‘highp 4-component vector of float’
ERROR: 0:25: ‘tex2Dlod’ : no matching overloaded function found
ERROR: 0:25: ‘=’ : dimension mismatch
ERROR: 0:25: ‘assign’ : cannot convert from ‘const mediump float’ to ‘highp 4-component vector of float’
Which method is used to convert tex2Dlod to babylon?