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

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

            if (uniformBlock == null)
            {
                uniformBlock = new UniformBlock(shader, "MaterialParams")
                {
                    BlockBinding = 1
                };
                Material.AddMaterialParams(uniformBlock);
            }
            // This needs to be updated more than once.
            Material.AddDebugParams(uniformBlock);

            uniformBlock.BindBlock(shader);
        }
예제 #2
0
        public void Render(Camera camera, RSkeleton Skeleton = null)
        {
            Shader shader = ShaderContainer.GetCurrentRModelShader();

            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);
        }