I am a beginner in AGAL, I'm sure this is not complicated.
I have a vertex and fragment shader, for simply drawing a box with a texture without light effect, here is the code:
vertexAssembly.assemble( Context3DProgramType.VERTEX,
"m44 op, va0, vc0\n" + // pos to clipspace
"mov v0, va1" // copy uv
);
fragmentAssembly.assemble(Context3DProgramType.FRAGMENT,
"tex ft1, v0, fs0 <2d,linear,nomip>\n" +
"mov oc, ft1"
);
I also have AGAL code for a Box with no texture, just color, and with light effect, here is the code for the shaders:
private const VERTEX_SHADER_LIGHT:String =
"mov vt0, va0\n"+
"m44 op, vt0, vc0\n"+
"nrm vt1.xyz, va0.xyz\n"+
"mov vt1.w, va0.w\n"+
"mov v1, vt1\n" +
"mov v2, va1"
private const FRAGMENT_SHADER_LIGHT:String =
"dp3 ft1, fc2, v1 \n"+
"neg ft1, ft1 \n"+
"max ft1, ft1, fc0 \n"+
"mul ft2, fc4, ft1 \n"+
"mul ft2, ft2, fc3 \n"+
"add oc, ft2, fc1";
Question is, how do I combine the 2 codes, I want a box model with texture map, to show with light effect.
I did this:
private const VERTEX_SHADER_LIGHT:String =
"m44 op, va0, vc0\n" + // pos to clipspace
"mov v0, va1" // copy uv
//"mov vt0, va0\n"+
//"m44 op, vt0, vc0\n"+
"nrm vt1.xyz, va0.xyz\n"+
"mov vt1.w, va0.w\n"+
"mov v1, vt1\n" +
"mov v2, va1"
private const FRAGMENT_SHADER_LIGHT:String =
"tex ft1, v0, fs0 <2d,linear,nomip>\n" +
"mov oc, ft1 \n" +
"dp3 ft1, fc2, v1 \n"+
"neg ft1, ft1 \n"+
"max ft1, ft1, fc0 \n"+
"mul ft2, fc4, ft1 \n"+
"mul ft2, ft2, fc3 \n"+
"add oc, ft2, fc1";
but it gives me an error: "Error: Error #3632: AGAL linkage: Varying 1 is read in the fragment shader but not written to by the vertex shader. at flash.display3D::Program3D/upload() at Context3DExample/setupScene() at Context3DExample/contextCreated()"
I'm sure someone with experiance can solve this in 5 minutes. Thanks
Looks like you forgot to concatenate a string, i.e.
should be
Notice extra
\nand+on the first line.