Hi, I'm trying to pass UV coordinates to my Shader program via the "setProgramConstantsFromVector" method and its failing miserably.
here's my vertexBuffer I'm uploading:
vertexData = Vector.<Number>([
Just a simple rectangle. Then I'm defining my uv coordinates like so:
program.uvs = 0.0;
program.uvs = 1.0;
then setting the correct buffer and sending the uv's as a constant as the "4th" register and drawing 2 triangles.
context.setVertexBufferAt(0, rect.vertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_2);
context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, modelMatrix, true);
context.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 4, program.uvs);
context.drawTriangles(rect.indexBuffer, 0, 2);
the simple shader code is below:
"m44 op, va0, vc0 \n" +
"mov v0, vc4 \n";
"tex oc, v0, fs0 <2d,clamp,nearest>";
what's happening is a single color is showing up. And I believe thats because the GPU isn't interpolating the UV's, how can I set a uv rect using a vertex constant which the gpu can use to interpolate?
Are you using Pixel Bender 3D in this? If so could you post the PB3D source you're using. If not, you might get better help on the Flash forums since they're more familiar with the Flash API.
According to the Flash docs here:
There should be at least four elements in the data vector. I am not sure that you have that.