Example #1
0
        private static void LoadPBRMaps(SF.Shader shader)
        {
            GL.ActiveTexture(TextureUnit.Texture0 + 26);
            RenderTools.specularPbr.Bind();
            GL.Uniform1(shader.GetUniformLocation("specularIbl"), 26);

            //    GL.GenerateMipmap(GenerateMipmapTarget.TextureCubeMap);

            // PBR IBL
            GL.ActiveTexture(TextureUnit.Texture0 + 25);
            RenderTools.diffusePbr.Bind();
            GL.Uniform1(shader.GetUniformLocation("irradianceMap"), 25);

            GL.ActiveTexture(TextureUnit.Texture0 + 27);
            RenderTools.brdfPbr.Bind();
            GL.Uniform1(shader.GetUniformLocation("brdfLUT"), 27);
        }
Example #2
0
        private static bool TextureUniform(SF.Shader shader, FMAT mat, string name, MatTexture mattex)
        {
            if (mattex.textureState == STGenericMatTexture.TextureState.Binded)
            {
                return(true);
            }

            // Bind the texture and create the uniform if the material has the right textures.
            bool IsBound = BindTexture(mattex, mat, shader, mat.GetResFileU() != null);
            int  texId   = mattex.textureUnit + 1;

            if (IsBound)
            {
                GL.Uniform1(shader.GetUniformLocation(name), texId);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        private static void SetTextureUniforms(FMAT mat, FSHP m, SF.Shader shader)
        {
            GL.ActiveTexture(TextureUnit.Texture0 + 1);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);

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

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

            GL.Uniform1(shader.GetUniformLocation("debugOption"), 2);


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

            GL.Uniform1(shader.GetUniformLocation("normalMap"), 0);
            GL.Uniform1(shader.GetUniformLocation("BakeShadowMap"), 0);

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

            LoadPBRMaps(shader);

            for (int t = 0; t < mat.TextureMaps.Count; t++)
            {
                MatTexture matex = (MatTexture)mat.TextureMaps[t];

                if (matex.Type == MatTexture.TextureType.Diffuse)
                {
                    mat.HasDiffuseMap = TextureUniform(shader, mat, "DiffuseMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Normal)
                {
                    mat.HasNormalMap = TextureUniform(shader, mat, "NormalMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Emission)
                {
                    mat.HasEmissionMap = TextureUniform(shader, mat, "EmissionMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Specular)
                {
                    mat.HasSpecularMap = TextureUniform(shader, mat, "SpecularMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Shadow)
                {
                    mat.HasShadowMap = TextureUniform(shader, mat, "BakeShadowMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Light)
                {
                    mat.HasLightMap = TextureUniform(shader, mat, "BakeLightMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Metalness)
                {
                    mat.HasMetalnessMap = TextureUniform(shader, mat, "MetalnessMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Roughness)
                {
                    mat.HasRoughnessMap = TextureUniform(shader, mat, "RoughnessMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.TeamColor)
                {
                    mat.HasTeamColorMap = TextureUniform(shader, mat, "TeamColorMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.Transparency)
                {
                    mat.HasTransparencyMap = TextureUniform(shader, mat, "TransparencyMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.DiffuseLayer2)
                {
                    mat.HasDiffuseLayer = TextureUniform(shader, mat, "DiffuseLayer", matex);
                }
                else if (matex.Type == MatTexture.TextureType.SphereMap)
                {
                    mat.HasSphereMap = mat.HasSphereMap = TextureUniform(shader, mat, "SphereMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.SubSurfaceScattering)
                {
                    mat.HasSubSurfaceScatteringMap = TextureUniform(shader, mat, "SubSurfaceScatteringMap", matex);
                }
                else if (matex.Type == MatTexture.TextureType.MRA)
                {
                    mat.HasMRA = TextureUniform(shader, mat, "MRA", matex);
                }
            }

            SetDefaultTextureAttributes(mat, shader);
        }