Hi. I’m trying to import a projected grid technique (for water/ocaen) made with Unity into Flax. There is no problem in the code part, but in the shader part, I need to assign the relevant matrix to the Vertex Output. Why can’t I do this?
Here is the relevant part:
v2f vert(appdata_base v)
{
float2 uv = v.texcoord.xy;
//Interpolate between frustums world space projection points. p is in world space.
float4 p = lerp(lerp(_Interpolation[0], _Interpolation[1], uv.x), lerp(_Interpolation[3], _Interpolation[2], uv.x), uv.y);
p = p / p.w;
v2f OUT;
OUT.pos = mul(UNITY_MATRIX_VP, p);
OUT.worldPos = p;
return OUT;
}
Is there a workaround on this? I’m trying to output position offset using custom code but no success no matter what I do.
Things I’ve tried;
// CUSTOM CODE BOX
float2 uv=input.TexCoord.xy;
float4x4 Interpolation;
Interpolation[0]=Input0;
Interpolation[1]=Input1;
Interpolation[2]=Input2;
Interpolation[3]=Input3;
float4 worldpos=float4(input.WorldPosition.xyz,1);
float4 p =lerp(lerp(Interpolation[0],Interpolation[1], uv.x),lerp(Interpolation[3],Interpolation[2], uv.x),uv.y);
p = p / p.w;
//none of them work
float4 final=mul(worldpos,p);
float4 final2=mul(mul(worldpos,WorldMatrix),p);
float4 final3=mul(input.SvPosition,p);
float4 final4=mul(mul(input.SvPosition,WorldMatrix),p);
float4 final5=mul(WorldMatrix,p);
Output0 =final;
//Output0 =p;