예제 #1
0
        public ShaderCode SamplingLoading()
        {
            CodeGenerator             generator = new CodeGenerator(BindingStage.VertexShader);
            Texture2DBinder <Floatx3> texture   = generator.CreateTexture2D <Floatx3>("Texture");
            SamplerBinder             sampler   = generator.CreateSampler("Sampler");
            Floatx3 sampled = texture.Sample(sampler, generator.InputFloatx2(PinComponent.TexCoord0));

            return(generator.ShaderCode);
        }
예제 #2
0
        /// <summary>
        /// Sample at specific address.
        /// </summary>
        public T Sample([NotNull] SamplerBinder sampler, [NotNull] Floatx3 address)
        {
            if (address.Generator != this.Generator ||
                sampler.Generator != this.Generator)
            {
                throw new ArgumentException("Mixing generators not allowed.");
            }

            SampleOperation op = new SampleOperation();

            op.BindInputs(sampler.Pin, pin, address.Pin);

            return((T)this.Generator.CreateFrom(op.Outputs[0]));
        }
예제 #3
0
        /// <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]));
        }
예제 #4
0
 /// <summary>
 /// Samples at specific address.
 /// </summary>
 public T Sample([NotNull] SamplerBinder sampler, [NotNull] Floatx3 address)
 {
     return(Sample(sampler, address, null));
 }