Example #1
0
        public void SetMaterialUniforms(Shader shader)
        {
            // TODO: Rework default texture creation.
            if (defaultTextures == null)
            {
                defaultTextures = new Resources.DefaultTextures();
            }

            if (genericMaterial == null)
            {
                genericMaterial = Material.CreateGenericMaterial(Material);
            }
            genericMaterial.SetShaderUniforms(shader);

            if (uniformBlock == null)
            {
                uniformBlock = new SFGenericModel.Materials.UniformBlock(shader, "MaterialParams")
                {
                    BlockBinding = 1
                };
                Material.AddMaterialParams(uniformBlock);
            }

            uniformBlock.BindBlock(shader);
        }
Example #2
0
        public void Render(Camera camera, RSkeleton Skeleton = null)
        {
            Shader shader = GetCurrentShader();

            if (!shader.LinkStatusIsOk)
            {
                return;
            }

            shader.UseProgram();

            SetUniforms(shader);
            SetCameraUniforms(camera, shader);

            // Bones
            boneUniformBuffer.BindBlock(shader);
            if (Skeleton != null)
            {
                boneBinds = Skeleton.GetAnimationTransforms();
            }
            boneUniformBuffer.SetValues("transforms", boneBinds);

            DrawMeshes(camera, Skeleton, shader);
        }