SetUniforms() public method

public SetUniforms ( string prefix, UniformState state ) : void
prefix string
state UniformState
return void
示例#1
0
 /// <summary>
 /// Add the specified state, prefix and mvp.
 /// </summary>
 /// <param name="state">State.</param>
 /// <param name="prefix">Prefix.</param>
 /// <param name="mvp">Mvp.</param>
 public static void Add(this UniformState state, ModelViewProjectionParameters mvp, string prefix = "")
 {
     mvp.SetUniforms(prefix, state);
 }
示例#2
0
 /// <summary>
 /// Sets the mvp.
 /// </summary>
 /// <param name="state">State.</param>
 /// <param name="prefix">Prefix.</param>
 /// <param name="mvp">Mvp.</param>
 public static void SetMvp(this UniformState state, string prefix, ModelViewProjectionParameters mvp)
 {
     mvp.SetUniforms(prefix, state);
 }
        /// <summary>
        /// given color and depth textures, render them.
        /// </summary>
        private static RenderPass CreateSolidBox(
			 FramebufferBindingSet targets,
			 BufferObject<Vector4> sprite_pos_buffer,
			 BufferObject<Vector4> sprite_color_buffer,
			 BufferObject<Vector4> sprite_dimensions_buffer,
			 BufferObject<Matrix4> sprite_rotation_local_buffer,
			 BufferObject<Matrix4> sprite_rotation_buffer,
			 IValueProvider<Vector2> viewport,
			 IValueProvider<int> particles_count,
			 IValueProvider<float> particle_scale_factor,
			 IValueProvider<string> fragdepthroutine,
			 IValueProvider<string> outputroutine,
			 ModelViewProjectionParameters mvp,
			 UniformState subroutineMapping,
			 IEnumerable<Shader> subroutines
		)
        {
            var uniform_state = subroutineMapping != null? new UniformState (subroutineMapping): new UniformState();
            uniform_state.Set ("viewport_size", viewport);
            uniform_state.Set ("particle_scale_factor", particle_scale_factor);
            uniform_state.Set ("u_SetFragmentDepth", ShaderType.FragmentShader, fragdepthroutine);
            uniform_state.Set ("u_SetOutputs", ShaderType.FragmentShader, outputroutine);
            mvp.SetUniforms("", uniform_state);

            var array_state =
                new ArrayObject (
                    new VertexAttribute { AttributeName = "sprite_pos", Buffer = sprite_pos_buffer, Size = 3, Stride = 16, Type = VertexAttribPointerType.Float },
                    new VertexAttribute { AttributeName = "sprite_color", Buffer = sprite_color_buffer, Size = 3, Stride = 16, Type = VertexAttribPointerType.Float },
                    new VertexAttribute { AttributeName = "sprite_dimensions", Buffer = sprite_dimensions_buffer, Size = 3, Stride = 16, Type = VertexAttribPointerType.Float },
                    new VertexAttribute { AttributeName = "sprite_rotation_local", Buffer = sprite_rotation_local_buffer, Size = 16, Stride = 64, Type = VertexAttribPointerType.Float },
                    new VertexAttribute { AttributeName = "sprite_rotation", Buffer = sprite_rotation_buffer, Size = 16, Stride = 64, Type = VertexAttribPointerType.Float }
                );

            var shaders = SeparateProgramPass.GetShaders("solid_box", "RenderPassFactory");
            shaders = shaders.Concat(subroutines ?? new Shader[0]).ToArray();

            //
            var resultPass = new SeparateProgramPass
            (
                 //the name of the pass-program
                 "solid_box_RenderPassFactory",
                 //before state
                 null,
                 //before render
                 null,
                 //render code
                 (window) =>
                 {
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                  GL.Enable (EnableCap.DepthTest);
                    GL.DepthMask(true);
                    GL.DepthFunc (DepthFunction.Less);
                    GL.Disable (EnableCap.Blend);

                    //setup viewport
                    GL.Viewport(0, 0, (int)viewport.Value.X, (int)viewport.Value.Y);
                    GL.DrawArrays (BeginMode.Points, 0, particles_count.Value);
                 },
                 //shaders
                 shaders,

                 //pass state
                 array_state,
                 uniform_state,
                 targets
            );

            return resultPass;
        }