Ejemplo n.º 1
0
 private void FinishMaterial(BatchInfo material)
 {
     //DrawTechnique tech = material.Technique.Res;
     this.SetupBlendType(BlendMode.Reset);
     NativeShaderProgram.Bind(null);
     NativeTexture.ResetBinding(this.sharedSamplerBindings);
 }
Ejemplo n.º 2
0
        private void FinishSharedParameters()
        {
            NativeTexture.ResetBinding();

            this.sharedSamplerBindings = 0;
            this.sharedShaderParameters.Clear();
            this.activeShaders.Clear();
        }
Ejemplo n.º 3
0
        private void SetupMaterial(BatchInfo material, BatchInfo lastMaterial)
        {
            DrawTechnique tech     = material.Technique.Res ?? DrawTechnique.Solid.Res;
            DrawTechnique lastTech = lastMaterial != null ? lastMaterial.Technique.Res : null;

            // Setup BlendType
            if (lastTech == null || tech.Blending != lastTech.Blending)
            {
                this.SetupBlendType(tech.Blending, this.currentDevice.DepthWrite);
            }

            // Bind Shader
            ShaderProgram       shader       = tech.Shader.Res ?? ShaderProgram.Minimal.Res;
            NativeShaderProgram nativeShader = shader.Native as NativeShaderProgram;

            NativeShaderProgram.Bind(nativeShader);

            // Setup shader data
            ShaderFieldInfo[] varInfo   = nativeShader.Fields;
            int[]             locations = nativeShader.FieldLocations;

            // Setup sampler bindings
            int curSamplerIndex = this.sharedSamplerBindings;

            for (int i = 0; i < varInfo.Length; i++)
            {
                if (locations[i] == -1)
                {
                    continue;
                }
                if (varInfo[i].Type != ShaderFieldType.Sampler2D)
                {
                    continue;
                }
                if (this.sharedShaderParameters.Contains(varInfo[i].Name))
                {
                    continue;
                }

                ContentRef <Texture> texRef = material.GetInternalTexture(varInfo[i].Name);
                NativeTexture.Bind(texRef, curSamplerIndex);
                GL.Uniform1(locations[i], curSamplerIndex);

                curSamplerIndex++;
            }
            NativeTexture.ResetBinding(curSamplerIndex);

            // Setup uniform data
            for (int i = 0; i < varInfo.Length; i++)
            {
                if (locations[i] == -1)
                {
                    continue;
                }
                if (varInfo[i].Type == ShaderFieldType.Sampler2D)
                {
                    continue;
                }
                if (this.sharedShaderParameters.Contains(varInfo[i].Name))
                {
                    continue;
                }

                float[] data = material.GetInternalData(varInfo[i].Name);
                if (data == null)
                {
                    continue;
                }

                NativeShaderProgram.SetUniform(ref varInfo[i], locations[i], data);
            }
        }