Jump to content

Correct way to sample from a texture array.


Pryme8
 Share

Recommended Posts

So what is the correct syntax to sample from a texture array?  The equivalent to: vec4 tile = texture2D(sampler, texCoord);

but for an Array not a single sampler2d.

I have tried : 
vec4 tile = texture3D(sampler, vec3(texCoord.xy, 0); 
and the webGL 2.0 version...
vec4 tile = texture(sampler, vec3(texCoord.xy, 0); 


But I keep dropping:
'texture' : no matching overloaded function found
ERROR: 0:37: '=' : dimension mismatch
ERROR: 0:37: '=' : cannot convert from 'const mediump float' to 'highp 4-component vector of float'

Link to comment
Share on other sites

Ok I can sample it just fine now, but it seems to drop an error reguardless:

vec4 tile = texture(layers[0], texCoord);

works, but drops the error:
[15:11:42]: Error: ERROR: 0:37: 'texture' : no matching overloaded function found
ERROR: 0:37: '=' : dimension mismatch
ERROR: 0:37: '=' : cannot convert from 'const mediump float' to 'highp 4-component vector of float'

Which is the same error as:
http://www.babylonjs-playground.com/#NJRT3#4

Which was an example @Deltakosh put together to test texture arrays.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...