1

I'm trying to use a sampler in a vertex shader on the iPhone. The documentation says that this is not supported on the PowerVR SGX. However, it seems that at least someone got it working in the simulator, although not without problems.

When I try to run this in the simulator (iOS 6), I get the following error message while compiling the shaders:

ERROR: Implementation limit of 0 active vertex shader samplers 
(e.g., maximum number of supported image units) exceeded, 
vertex shader uses 1 samplers

What changed since the other question got asked? Did they just add a (correct!) error message? Or is it maybe possible to use a sampler in the vertex shader now? fingerscrossed...

Community
  • 1
  • 1
hanno
  • 6,401
  • 8
  • 48
  • 80

1 Answers1

2

I had the exact same question, so I asked a couple of Apple's OpenGL ES engineers this at WWDC. According to them, the support for sampling from a texture within a vertex shader on certain devices in iOS 4.x was a bug, and this was removed in iOS 5.x.

It has never been officially supported, and this new error message is just describing why this fails. On iOS 5.x, and most devices running iOS 4.x, you'd just get a black screen if you tried this, with no warnings. All they've done is add some explanation for this behavior.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • Thanks! That's what I suspected. Looks like I'll have to do the lockup in the fragment shader, which works fine, but it would be so much faster in the vertex shader :-( – hanno Dec 12 '12 at 01:25
  • 1
    @hanno - You could be a little more creative about it and load your lookup information into an attribute, like I did here: http://stackoverflow.com/questions/10316708/ios-glsl-is-there-a-way-to-create-an-image-histogram-using-a-glsl-shader/10359305#10359305 . However, that might not work in your case. – Brad Larson Dec 12 '12 at 16:10
  • Thanks for the clever idea! That might actually work, but I'm a bit pessimistic that it will be much faster in my case (my case being a GPU based ray tracer to render opaque dust in the Milky Way). In case you're interested, this is how far I got: http://youtu.be/zh2SXx4vHpw – hanno Dec 12 '12 at 19:37
  • I just implemented your idea to render it to an off screen FBO and use the result as a texture lookup. It works and is quite a bit faster! Thanks again. – hanno Dec 13 '12 at 19:51
  • @hanno - It sounds like you're doing the raytracing in the fragment shader now, correct? Out of curiosity, why were you using the vertex shader for this originally? – Brad Larson Dec 13 '12 at 20:56
  • Correct. Because I'm using point sprites and one ray per point is all I need. Calculating one ray per fragment would just duplicate the work for points with a size larger than 1. – hanno Dec 13 '12 at 21:20