Пример #1
0
 private void SetRenderSettings(ShaderProgram shader)
 {
     shader.SetInt("renderType", (int)Runtime.DebugRendering);
     shader.SetBoolToInt("hasDiffuse", false);
     shader.SetInt("selectedBoneIndex", Runtime.SelectedBoneIndex);
     shader.SetBoolToInt("renderVertColor", DisplayVertexColors);
     shader.SetBoolToInt("renderVertAlpha", DisplayVertexColorAlpha);
     shader.SetColor("diffuseColor", STColor8.White.Color);
 }
Пример #2
0
 private void SetRenderSettings(ShaderProgram shader)
 {
     shader.SetInt("renderType", (int)Runtime.DebugRendering);
     shader.SetBoolToInt("hasDiffuse", false);
     shader.SetInt("selectedBoneIndex", Runtime.SelectedBoneIndex);
     shader.SetBoolToInt("renderVertColor", DisplayVertexColors);
     shader.SetBoolToInt("renderVertAlpha", DisplayVertexColorAlpha);
     shader.SetColor("diffuseColor", STColor8.White.Color);
     shader.SetBoolToInt("HasSkeleton", false);
     if (Scene.Models.Count > 0)
     {
         shader.SetBoolToInt("HasSkeleton", Scene.Models.Any(x => x.Skeleton.Bones.Count > 0));
     }
 }
Пример #3
0
        public virtual void RenderMaterials(ShaderProgram shader,
                                            STGenericMesh mesh, STPolygonGroup group, STGenericMaterial material, Vector4 highlight_color)
        {
            if (material == null && group.MaterialIndex != -1 && Model.Materials.Count > group.MaterialIndex)
            {
                material = Model.Materials[group.MaterialIndex];
            }

            shader.SetVector4("highlight_color", highlight_color);

            SetTextureUniforms(shader);
            SetMaterialUniforms(shader, material, mesh);
            if (material == null)
            {
                return;
            }

            int textureUintID = 1;

            foreach (var textureMap in material.TextureMaps)
            {
                var tex = textureMap.GetTexture();
                if (textureMap.Type == STTextureType.Diffuse)
                {
                    shader.SetBoolToInt("hasDiffuse", true);
                    BindTexture(shader, Model.Textures, textureMap, textureUintID);
                    shader.SetInt($"tex_Diffuse", textureUintID);
                }

                textureUintID++;
            }
        }
Пример #4
0
        private void SetTextureUniforms(ShaderProgram shader)
        {
            shader.SetInt("debugOption", 2);

            GL.ActiveTexture(TextureUnit.Texture11);
            shader.SetInt("weightRamp1", 11);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.BoneWeightGradient.RenderableTex.TexID);

            GL.ActiveTexture(TextureUnit.Texture12);
            shader.SetInt("weightRamp2", 12);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.BoneWeightGradient2.RenderableTex.TexID);


            GL.ActiveTexture(TextureUnit.Texture10);
            shader.SetInt("UVTestPattern", 10);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
        }
Пример #5
0
        public void Render(Camera camera)
        {
            if (Skeleton == null || !Visibile || !Runtime.DisplayBones)
            {
                return;
            }

            CheckBuffers();

            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            Console.WriteLine($"Skeleton render {Skeleton.Bones.Count}");

            ShaderProgram.Enable();
            GL.Disable(EnableCap.CullFace);
            GL.Disable(EnableCap.DepthTest);

            ShaderProgram.EnableVertexAttributes();
            ShaderProgram.SetMatrix4x4("rotation", ref prismRotation);

            Matrix4 camMat         = camera.ViewMatrix;
            Matrix4 mdlMat         = camera.ModelMatrix;
            Matrix4 projMat        = camera.ProjectionMatrix;
            Matrix4 computedCamMtx = camMat * projMat;

            ShaderProgram.SetMatrix4x4("mtxCam", ref computedCamMtx);
            ShaderProgram.SetMatrix4x4("mtxMdl", ref mdlMat);

            foreach (STBone bn in Skeleton.Bones)
            {
                if (!bn.Visible)
                {
                    continue;
                }

                Matrix4 modelMatrix = Matrix4.Identity;

                ShaderProgram.SetVector4("boneColor", ColorUtility.ToVector4(boneColor));
                ShaderProgram.SetFloat("scale", Runtime.BonePointSize * Skeleton.PreviewScale);
                ShaderProgram.SetMatrix4x4("ModelMatrix", ref modelMatrix);


                Matrix4 transform = bn.Transform;

                ShaderProgram.SetMatrix4x4("bone", ref transform);
                ShaderProgram.SetInt("hasParent", bn.ParentIndex != -1 ? 1 : 0);

                if (bn.ParentIndex != -1)
                {
                    var transformParent = ((STBone)bn.Parent).Transform;
                    ShaderProgram.SetMatrix4x4("parent", ref transformParent);
                }

                Draw(ShaderProgram);

                if (Runtime.SelectedBoneIndex == Skeleton.Bones.IndexOf(bn))
                {
                    ShaderProgram.SetVector4("boneColor", ColorUtility.ToVector4(selectedBoneColor));
                }

                ShaderProgram.SetInt("hasParent", 0);
                Draw(ShaderProgram);
            }

            ShaderProgram.DisableVertexAttributes();

            GL.UseProgram(0);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);
        }