iam trying to set some parameters of my fragmentshader. First I used the ProgramConstantHelper but it simply is to slow to use in the final program.
After some errors I couldnt figure out how setting the parameters with setProgramConstantsFromVector works, better said, I did not know which registers I have to set. To find that out I first inspected some values in the debugger and than wrote a little code giving me this output.
FragmentParameter: color startRegister: 1 offset: 0
FragmentParameter: size startRegister: 1 offset: 3
FragmentParameter: fposition startRegister: 2 offset: 0
FragmentParameter: resolution startRegister: 2 offset: 2
FragmentParameter: strength startRegister: 3 offset: 0
FragmentParameter: thickness startRegister: 3 offset: 1
first I thought every parameter has its own register, but I was wrong. If the compiler is able to put some parameters into one register, it does.
this is the code to set the parameters of the vector:
The vector is generated with: new Vector.<Number>(12, true);
and this is the call of setProgramConstantsFromVector:
this.m_context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 1, this.m_parameters);
can someone tell me what is wrong with the code?
It looks like I solved it myself. The problem is, that the numericalConstants of the shader also have to be set manually!
So I tried this
this.m_context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.m_constants);
I got the constants with this:
this.m_constants = fragmentRegisterMap.numericalConstants.values;
Yes, this is exactly the work that ProgramConstantsHelper does for you. If you look at AGAL, there are no built in constants so all constant values need to be passed in.
I simply didnt thought about it, so all I got was strange behavior of the shaders ;-) Now everything works fine and fast