Beispiel #1
0
        private static void SetUniforms(GFLXMaterialData mat, ShaderProgram shader, GFLXMesh m, int id)
        {
            // Texture Maps

            /*  shader.SetBoolToInt("useColorTex", false);
             * shader.SetBoolToInt("EmissionMaskUse", false);
             * shader.SetBoolToInt("SwitchPriority", false);
             * shader.SetBoolToInt("Layer1Enable", false);
             * shader.SetBoolToInt("AmbientMapEnable", false);
             * shader.SetBoolToInt("NormalMapEnable", false);
             * shader.SetBoolToInt("LightTableEnable", false);
             * shader.SetBoolToInt("BaseColorAddEnable", false);
             * shader.SetBoolToInt("SphereMapEnable", false);
             * shader.SetBoolToInt("EffectVal", false);*/

            //Switch UVs
            shader.SetBoolToInt("SwitchEmissionMaskTexUV", false);
            shader.SetBoolToInt("SwitchAmbientTexUV", false);
            shader.SetBoolToInt("SwitchNormalMapUV", false);

            //UV Scale
            shader.SetFloat("ColorUVScaleU", 1);
            shader.SetFloat("ColorUVScaleV", 1);

            //UV Translate
            shader.SetFloat("ColorUVTranslateU", 0);
            shader.SetFloat("ColorUVTranslateV", 0);

            SetUniformData(mat, shader, "ColorUVScaleU");
            SetUniformData(mat, shader, "ColorUVScaleV");
            SetUniformData(mat, shader, "ColorUVTranslateU");
            SetUniformData(mat, shader, "ColorUVTranslateV");
        }
Beispiel #2
0
        private static void SetTextureUniforms(GFLXMaterialData mat, GFLXMesh m, ShaderProgram shader)
        {
            if (!mat.HasVertexColors())
            {
                shader.SetBoolToInt("renderVertColor", false);
            }
            else
            {
                shader.SetBoolToInt("renderVertColor", Runtime.renderVertColor);
            }

            SetDefaultTextureAttributes(mat, shader);

            GL.ActiveTexture(TextureUnit.Texture0 + 1);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);

            GL.Uniform1(shader["debugOption"], 2);

            GL.ActiveTexture(TextureUnit.Texture11);
            GL.Uniform1(shader["weightRamp1"], 11);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.BoneWeightGradient.Id);

            GL.ActiveTexture(TextureUnit.Texture12);
            GL.Uniform1(shader["weightRamp2"], 12);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.BoneWeightGradient2.Id);


            GL.ActiveTexture(TextureUnit.Texture10);
            GL.Uniform1(shader["UVTestPattern"], 10);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);

            shader.SetInt("RedChannel", 0);
            shader.SetInt("GreenChannel", 1);
            shader.SetInt("BlueChannel", 2);
            shader.SetInt("AlphaChannel", 3);

            LoadPBRMaps(shader);

            foreach (STGenericMatTexture matex in mat.TextureMaps)
            {
                if (matex.Type == STGenericMatTexture.TextureType.Diffuse)
                {
                    shader.SetBoolToInt("HasDiffuse", true);
                    TextureUniform(shader, mat, true, "DiffuseMap", matex);
                }
                if (matex.Type == STGenericMatTexture.TextureType.Normal)
                {
                    shader.SetBoolToInt("HasNormalMap", true);
                    TextureUniform(shader, mat, true, "NormalMap", matex);
                }
                if (matex.Type == STGenericMatTexture.TextureType.AO)
                {
                    shader.SetBoolToInt("HasAmbientMap", true);
                    TextureUniform(shader, mat, true, "AmbientMap", matex);
                }
            }
        }
Beispiel #3
0
        private static void TextureUniform(ShaderProgram shader, GFLXMaterialData mat, bool hasTex, string name, STGenericMatTexture mattex)
        {
            if (mattex.textureState == STGenericMatTexture.TextureState.Binded)
            {
                return;
            }

            // Bind the texture and create the uniform if the material has the right textures.
            if (hasTex)
            {
                GL.Uniform1(shader[name], BindTexture(mattex, shader));
            }
        }
Beispiel #4
0
 private static void SetUniformData(GFLXMaterialData mat, ShaderProgram shader, string propertyName)
 {
     if (mat.SwitchParams.ContainsKey(propertyName))
     {
         bool Value = (bool)mat.SwitchParams[propertyName].Value;
         shader.SetBoolToInt(propertyName, Value);
     }
     if (mat.ValueParams.ContainsKey(propertyName))
     {
         var Value = mat.ValueParams[propertyName].Value;
         shader.SetFloat(propertyName, (float)Value);
     }
     if (mat.ColorParams.ContainsKey(propertyName))
     {
         Vector3 Value = (Vector3)mat.ColorParams[propertyName].Value;
         shader.SetVector3(propertyName, Value);
     }
 }
Beispiel #5
0
        private void SetUniformBlocks(GFLXMaterialData mat, ShaderProgram shader, GFLXMesh m, int id)
        {
            /*     shader.UniformBlockBinding("TexCoord1", 3);
             *   GL.GetActiveUniformBlock(shader.program,
             *                   shader.GetUniformBlockIndex("TexCoord1"),
             *                   ActiveUniformBlockParameter.UniformBlockBinding, out int binding);*/

            /*      GL.BindBuffer(BufferTarget.UniformBuffer, TexCoord1Buffer);
             *    GL.BufferData(BufferTarget.UniformBuffer,
             *    (IntPtr)MTOBWrapper.TexCoord1.Size,
             *    ref mat.TexCoord1Buffer,
             *    BufferUsageHint.StaticDraw);
             *    GL.BindBuffer(BufferTarget.UniformBuffer, 0);
             *    GL.BindBufferRange(BufferRangeTarget.UniformBuffer, 0, TexCoord1Buffer, (IntPtr)0,
             *        MTOBWrapper.TexCoord1.Size);
             *    GL.BindBuffer(BufferTarget.UniformBuffer, TexCoord1Buffer);
             *    GL.BINDBUFFER*/
        }
Beispiel #6
0
 private static void SetDefaultTextureAttributes(GFLXMaterialData mat, ShaderProgram shader)
 {
 }