/// <summary> /// Sample at specific address. /// </summary> public T Sample([NotNull] SamplerBinder sampler, [NotNull] Floatx2 address, Integerx2 offset) { if (address.Generator != this.Generator || ((object)offset != null && offset.Generator != this.Generator) || sampler.Generator != this.Generator) { throw new ArgumentException("Mixing generators not allowed."); } SampleOperation op = new SampleOperation(); if ((object)offset != null) { op.BindInputs(sampler.Pin, pin, address.Pin, offset.Pin); } else { op.BindInputs(sampler.Pin, pin, address.Pin); } return((T)this.Generator.CreateFrom(op.Outputs[0])); }
public ShaderCode Simulate() { CodeGenerator generator = new CodeGenerator(BindingStage.PixelShader); Floatx1 dt = generator.ConstantFloatx1("DeltaTime"); Floatx1 mass = generator.ConstantFloatx1("Mass"); // We extract data. Floatx2 position = generator.InputFloatx2(PinComponent.Position); Floatx2 velocity = generator.InputFloatx2(PinComponent.TexCoord0); Floatx2 force = generator.InputFloatx2(PinComponent.TexCoord1); // We update force. velocity += force * mass * dt; position += velocity * dt; // We now update data. generator.Output(PinComponent.Position, position); generator.Output(PinComponent.TexCoord0, velocity); return(generator.ShaderCode); }
/// <summary> /// Samples at specific address. /// </summary> public T Sample([NotNull] SamplerBinder sampler, [NotNull] Floatx2 address) { return(Sample(sampler, address, null)); }