Is texture2D allowed in a *vertex* shader?

Are WebGL vertex shaders allowed to read textures?

Yes and no.

I have certainly gotten vertex shader textures to work just fine on many different driver/browser/hardware/OS combinations.

…but…

The WebGL specification says that you can query WebGL to see how many vertex textures are supported - and the answer can legally be (and often is) zero…in which case you don’t have vertex textures and you have to figure another way around the problem.

MUCH worse than that is that I have an older WinXP laptop with an nVidia 6100 GO chip in it which reports that one vertex texture is available…but when I use it, the driver seems to fall back to running the vertex shader in the CPU - which takes my frame rate down from 20Hz to about 1Hz!

So if you want both portability and speed - you’re kinda screwed right now.

I wound up rewriting my code to avoid vertex textures altogether…but YMMV.

– Steve

Thanks for the response!

The same shader worked on a desktop application (same hw/driver/os), so I knew that it was either a webgl or browser limitation. It turned out to be a bug with Chrome, as Firefox 4 worked perfectly. Filed a bug here: 65340 - chromium - An open-source project to help move the web forward. - Monorail

Do you, by chance, know what gl call will return the number of vertex textures supported?

  n = gl.getParameter(MAX_VERTEX_TEXTURE_IMAGE_UNITS);

Thanks!