Unable to sample custom texture inside custom expression

Hello,

I am unable to sample textures inside a “Custom” node. I get an error saying cannot implicitly convert ‘Texture2D’ to ‘sampler2D’. I have attached a screenshot of my setup below.

My custom expression code:

float4 myTexture = tex2D(In, Texcoord);
return myTexture;

Hello HypnoticShark,

Unfortunately, You can’t sample a texture from within a custom expression. This is a known limitation that we currently do not support. But, I have raised awareness about this issue and expect it to be fixed in a future release.

~Sam

I see. Well I guess this documentation page needs to be updated in that case. https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Custom/index.html

Thanks!

Hi.

I found a temporary solution as explained here :

when analysing hlsl code, It seems that the CustomTexture node generate a Texture2D, but Custom node wait a sampler2D as argument function…

I would request a fix for custom node (and/or custom texture) and a real window to edit code instead of a single line text box.

thanks.

Thats awesome! thanks fredakilla and yes I agree with the real window to edit code thing.

It is officially supported since about 4.7:

Tex.Sample(TexSampler,UV);

(if your texture pin is named Tex)

References:

However it did not work for me, I had to use this:

 Tex.SampleLevel(TexSampler, UV, 0);

References:

1 Like