[noob] DX11 Shader Porting Problem

Hi all,

for the first time I’m trying to port a shader from shadertoys to vvvv.
As I’m not an expert in this field I just started comparing the code of different ported dx11 shaders to get a basic understanding…

the shader I am talking about is
https://www.shadertoy.com/view/MsSGWK#

I got stuck when I tried to find an equivalent for

vec4 ref = textureCube(iChannel0, normalize(reflect(rd, n)));
vec3 rfa = texture2D(iChannel1, (p+n).xz / 6.0).xyz * (8./d);

especially the textureCube part is really confusing to me.
I tried to replace it with texCUBE, but without any luck…

maybe someone can give me a hint in the right direction or even a probable solution?

thanks a lot

soriak

vec becomes float, as a rule of thumb.
you can have a look here for some other ports to get an orientation.

TextureCube filename <string uiname=“Texture Cube”;>;

will create a texture input pin, have a look at cubemap.fx (dx11) for further usage…

@ sebl

thanks, that’s exactly what i tried to do, the code snippet that I posted was the un-ported original… I replaced all the vec3’s and the other standard stuff, but the confusion starts when texCUBE asks me for a “sample Cube” instead of a Vector/float…

I assumed (by looking at the other shadertoy ports) that the “iChannel” variables work as colour inputs in vvvv.

variable declaration from the original code:

uniform samplerXX iChannel0..3;          // input channel. XX = 2D/Cube

@catweasel

thank you, that helped a lot! well, at least I thought so until i realised that the function call “texCUBE” still returns an error stating:
“intrinsic function doesn’t take two arguments.
possible intrinsic functions are
texCUBE(samplerCUBE,float3);”
etc.

after initializing with

TextureCube c0 <String uiname="Texture Cube";>;

and having the meso cube map connected to the pin
the following line still gives me the said error…

float4 ref = texCUBE(c0, normalize(reflect(rd, n)));

I fear I might be missing something that’s painfully obvious…

The file Cat mentioned has everything you need.

But basically you need to do two things, declare the (cube)texture, which you have done already, and then sample from it:

float4 myResult=c0.Sample(mySampler, uvw);

you’ll need to declare a sampler also (again see the cubetexture.fx file) and the uvw is coordinates for the cubemap lookup which in your case is the

normalize(reflect(rd, n)

nice, thank you!
I couldn’t find the texCUBE call in the cubetexture.fx and got confused.(so far this seems to happen a lot to me when it comes to shaders…) My bad. I’m gonna look through the file thoroughly and report back!

found the time to look at it again:
got it to work! thanks again!
now some other minor issues popped up, but i’m sure that’ll be doable!