public unsafe void DAGUsageCase2() { // We first initialize our shader. ShaderCode code = new ShaderCode(BindingStage.VertexShader); { // We write a simple Tranform code: code.InputOperation.AddInput(PinComponent.Position, PinFormat.Floatx3); Pin positon = code.InputOperation.PinAsOutput(PinComponent.Position); // We create 3 interations. LoopOperation loop = new LoopOperation(); loop.InputOperation.BindInputs(code.CreateFixed((uint)3).Outputs[0], positon); AddOperation add = new AddOperation(); add.BindInputs(loop.InputOperation.Outputs[1], code.CreateFixed(new Vector3f(1, 0, 0)).Outputs[0]); loop.OutputOperation.BindInputs(add.Outputs[0]); ExpandOperation expand = new ExpandOperation(PinFormat.Floatx4, ExpandType.AddOnesAtW); expand.BindInputs(loop.OutputOperation.Outputs[0]); // We just bind transformed position to output. code.OutputOperation.AddComponentAndLink(PinComponent.Position, expand.Outputs[0]); } // Immutate it. code.Immutable = true; // We now compile it. FixedShaderParameters p = code.FixedParameters; using (GraphicsDevice device = InitializeDevice()) { code.Compile(device, p).Dispose(); } }
/// <summary> /// Creates a fixed float. /// </summary> /// <param name="v"></param> /// <returns></returns> public Floatx2 Fixed(Vector2f v) { ConstantOperation c = dag.CreateFixed(v); return(new Floatx2(c.Outputs[0], this)); }