Haxe Forum > hxsl - indirect access
-
Alex Jun 03 at 09:29
Hi!
How should I pass data in shader like this:
function vertex( pos : Float4<10> ) { ... }
?
Naive Array<Float> and ByteArray doesn't work. -
Alex Jun 04 at 05:13
OK, it seems I made some progress.
Here is my shader:
class TestShader extends format.hxsl.Shader { static var SRC = { var input : { indices : Float2 }; function vertex( pos : Float4<10> ) { out = pos[indices.x] + pos[indices.y]; } function fragment() { out = [0.5,0.5,0.5,1]; } }; }
Here is it correct(I suppose) initialization:
var p = new format.hxsl.Shader.Array<Vector3D,10>(); testShader.init( { pos : p }, {} );
But there is a problem - there is a runtime error when I create the shader. Here:
testShader = new TestShader( context3d );
Error: Error #3625: AGAL validation failed: Bad AGAL source operands. Both are constants (this must be precomputed) at token 1 of vertex program.Have someone faced this problem?
-
Alex Jun 04 at 05:16
Yeah, it has tested on all Flash versions: from 11.0 to 11.3, with the same result.
-
Alex Jun 04 at 06:13
Okay, seems I get it. Not sorted out completely how it works but how to use it.
class TestShader extends format.hxsl.Shader { static var SRC = { var input : { pos : Float3, }; function vertex( mpos : M44, mproj : M44, pos_ : Float4, quat : Float4<10> ) { var i : Float = 0; var p : Float4 = pos.xyzw; p += quat[i]; out = p.xyzw * mpos * mproj; } function fragment() { out = [1,0,0,1]; } }; }
var shader = shaders.testShader; var p : format.hxsl.Shader.Array<Vector3D,10> = new format.hxsl.Shader.Array<Vector3D,10>(); p[0] = new Vector3D(1, 0, 0, 0); for ( i in 1...10 ) { p[i] = new Vector3D(); } shader.init( { mpos : positionMatrix, mproj : projectionMatrix, quat : p }, {} ); shader.draw( rectangle.vbuf, rectangle.ibuf );
< Prev
| Page 1 / 1 |
Next >