I’m having a lot of fun porting some Shadertoy shaders to Urho. However, one thing that I run in to quite a bit is that a shader from Shadertoy might have some code like this:
float pn(in vec3 x) {
vec3 p = floor(x), f = fract(x);
f *= f*(3.-f-f);
vec2 uv = (p.xy+vec2(37.,17.)*p.z) + f.xy,
rg = texture2D( iChannel0, (uv+.5)/256., -100.).yx;
return 2.4*mix(rg.x, rg.y, f.z)-1.;
}
This is a helper function that computes some kind of noise. It sits outside of either VS() or PS(), to put it into Urho terms. The issue is here:
rg = texture2D( iChannel0,....)
Where the code samples the texture called “iChannel0”. Now, my understanding is that in Urho, we only have access to certain Uniforms (i.e. vTexCoord, cElapsedTimePS,etc). In particular, we can only access textures that are held in the sampler uniforms, i.e. cDiffMap, cNormalMap, etc.
So, sampling cDiffMap from insider PS() certainly works. However, my question is: how can I sample the texture from outside PS() or VS() like in the code above?