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?
expose
(expose)
July 20, 2016, 11:36am
2
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 )
be sure to set up your custom node like this and set the output to float 3
expose
(expose)
July 20, 2016, 11:38am
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;
expose
(expose)
July 20, 2016, 11:39am
4
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.
expose
(expose)
July 25, 2016, 8:35am
7
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)
Deathrey
(DeathreyCG)
July 25, 2016, 10:27am
8
If that is HLSL, you should use it as follows:
blur += Tex.Sample(TexSampler, UV);
Reference
1 Like
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…
expose
(expose)
July 27, 2016, 8:01am
13
well the texture in the code must have the same name in input . that s all
Deathrey
(DeathreyCG)
July 27, 2016, 4:39pm
14
It does not need to be Tex. Any name will do.
now we use 4.12.5, I tryed 4.11.0, was the same problem.
Deathrey
(DeathreyCG)
July 28, 2016, 10:08am
19
if your texture object name is “test”, corresponding sampler name will be “testSampler”
expose
(expose)
July 28, 2016, 2:46pm
20
so you can mark it has aswered now