I can’t seem to figure out how to sample a texture in HLSL code via the material editor’s
In the images below, I’m attempting to create a simple “pass-thru” shader.
Notice the VERY simple HLSL code here:
But for whatever reason, it spits out these errors:
I’ve even tried several variations of the code, such as
return tex2D( Tex, UV.xy ); but I always get the same error whenever I try to make use of the
tex2D intrinsic function. Am I missing something here, or is this a bug?
What happens if you use a
TextureSampleParameter2D instead of a
The same error. Also tried
MakeFloat4… All of which results in the same error.
And this is happening in a fresh, empty project.
Well, shoot. You’ve got me stumped.
Figured it out! Sure,
tex2D doesn’t work… but
Texture2DSample (with a
Texture Object node) does.
return Texture2DSample(Tex, TexSampler, UV);
Of course, the downside here is that (AFAIK) you can’t actually generate a texture to pass in.
But you could possibly get around this by using a
Texture Object Parameter node instead, creating a material instance, and changing the parameter in a blueprint.