I have a custom vertex factory in which I want to sample from a texture ( I get the texture from a material so the texture is a UTexture object ).
I have a class derived from FVertexFactoryShaderParameters and in the SetMesh overriden function I want to bind this texture. I can get the FShaderResourceParameter from the shader but I need a FShaderResourceViewRHIParamRef to actually bind the texture for use ( I theoretically need to bind a sampler but I hope it works like in DX11 and can reuse whatever sampler was set up previously ).
Given a UTexture* TexOut :
FRHITextureReference* TextureRef = TexOut->TextureReference.TextureReferenceRHI;
FRHITexture* RHITex = TextureRef->GetReferencedTexture();
FRHITexture2D* RHITex2D = RHITex->GetTexture2D();
if ( RHITex2D )
{
FShaderResourceViewRHIParamRef SRVRHIRef = RHICreateShaderResourceView( RHITex2D, 0 );
auto Sampler = TStaticSamplerState<SF_Bilinear>::GetRHI();
}