Download

Use UV in custom vertex shader

Im creating custom mesh component. I made vertex factory class and custom VertexFactory.ush. Also im writing custom data into UV channel (UV7) and trying to read this data inside VertexFactory.ush something like this




float4 CalcWorldPositionAnim(FVertexFactoryInput Input, float4x4 InstanceTransform, uint PrimitiveId, FVertexFactoryIntermediates Intermediates)
{
       FMaterialVertexParameters matParams = GetMaterialVertexParameters(Input,Intermediates,Input.Position,Intermediates.TangentToLocal);
       FVertexFactoryInterpolantsVSToPS params = VertexFactoryGetInterpolantsVSToPS(Input,Intermediates,matParams);
       FMaterialPixelParameters finaParams = GetMaterialPixelParameters(params,Input.Position);
      
       float4 textcoords = float4(0,0,0,0);
#if NUM_TEX_COORD_INTERPOLATORS
       textcoords =params.TexCoords(NUM_TEX_COORD_INTERPOLATORS+1)/2];
#endif

       return AnimDeformMesh(Input,PrimitiveId,InstanceTransform,textcoords); }


I tried to use VertexFactoryGetInterpolantsVSToPS or GetMaterialVertexParameters to get UVs. Also i can’t realy inderstand how NUM_TEX_COORD_INTERPOLATORS is set and another defines belong to INTERPOLATORS.