Undeclared identifier 'TexSampler'

float3 blur = Texture2DSample(Tex, TexSampler, UV);

for (int i = 0; i < r; i++)
{

blur += Texture2DSample(Tex, TexSampler, UV + float2(i * dist, 0));
blur += Texture2DSample(Tex, TexSampler, UV - float2(i * dist, 0));

}

for (int j = 0; j < r; j++)
{

blur += Texture2DSample(Tex, TexSampler, UV + float2(0, j * dist));
blur += Texture2DSample(Tex, TexSampler, UV - float2(0, j * dist));

}

blur /= 2*(2*r)+1;
return blur;

this is example in documentation, but i got this “undeclared identifier ‘TexSampler’”, why?

be sure you have a valid Tex input on your custom node. be aware that inputs are case sensitive.
you ll find a working blur in the comment of your answer (seems the forum didn"t like the first time i posted it :slight_smile: )
be sure to set up your custom node like this and set the output to float 3

///crossblur def with uv corrected
//// needed inputs : Tex (for texture, UV , s (for samples), dist (for blur distance)
float3 blur = Texture2DSample(Tex, TexSampler, UV);

//float uvratio=screenuv.x/UV.x;
float xdist= dist/100;
//float tempo=(xdist/uvratio)/2;
//UV=(UV/float2(1+xdist*uvratio,1+xdist*uvratio))+float2(tempo,tempo);

//float4 blur =  SceneTextureLookup(UV, 14, true);


s= clamp (s,0,12);
s=round(s);

int loop=2*s;
loop ++;
float incr=float(xdist/s);





//sampler UV for x axis and y axis

float2 UVX, UVY, UVZ ,UVIZ;
float init=(-1)*(xdist);





UVX=UV + float2(init,0);
UVY=UV + float2(0,init);
UVZ=UV + float2(init,init);
UVIZ=UV + float2(init,-init);



for (int i = 0; i <loop; i++)
	{
  	blur +=  Texture2DSample(Tex, TexSampler, UVX);
	blur +=  Texture2DSample(Tex, TexSampler, UVY);
	blur +=  Texture2DSample(Tex, TexSampler, UVZ);
	blur +=  Texture2DSample(Tex, TexSampler, UVIZ);
	UVX.x += incr;
	UVY.y += incr;
	UVZ += float2 (incr,incr);
	UVIZ += float2 (incr,-incr);

	}

blur /= 1+(((2*s)+1)*4);
return blur;

you ll find other blurs here :FREE custom nodes non kernel blurs - Community Content, Tools and Tutorials - Unreal Engine Forums

In fact, I want to sample the texture,in custom node. but i tryed ‘tex2D and Texture2DSample’, its all not working.

In fact, I want to sample the texture,in custom node. but i tryed ‘tex2D and Texture2DSample’, its all not working.

pretty wierd issue there. did you tried the code i gave you? it’s using a texsampler too and works here on 4.12.5. verify that your inputs on the node have the correct spelling (it s case sensitive)

If that is HLSL, you should use it as follows:

blur += Tex.Sample(TexSampler, UV);

Reference

thank you! i know why.

the texture variable name must be ‘Tex’, this is very strange in design.

thank you ! i can use it, but the texture variable name still must be ‘Tex’.

Hmm I’m having the same problem. Renaming it to ‘Tex’ didn’t help either.

What version are you using? We’re currently on 4.12.5…

well the texture in the code must have the same name in input . that s all :slight_smile:

It does not need to be Tex. Any name will do.

look ths!

look picture! downstairs

now we use 4.12.5, I tryed 4.11.0, was the same problem.

look picture! downstairs

if your texture object name is “test”, corresponding sampler name will be “testSampler”

so you can mark it has aswered now :slight_smile: