Пример #1
0
        public static void SetTextureUniformsNudMatSphere(Shader shader, Nud.Material mat, Dictionary <NudEnums.DummyTexture, Texture> dummyTextures)
        {
            SetHasTextureUniforms(shader, mat);
            SetRenderModeTextureUniforms(shader);

            // The material shader just uses predefined textures from the Resources folder.
            Nud.MatTexture diffuse     = new Nud.MatTexture((int)NudEnums.DummyTexture.DummyRamp);
            Nud.MatTexture cubeMapHigh = new Nud.MatTexture((int)NudEnums.DummyTexture.StageMapHigh);

            SetHasTextureUniforms(shader, mat);
            SetRenderModeTextureUniforms(shader);

            // The type of texture can be partially determined by texture order.
            GenericMaterial textures = new GenericMaterial(nutTextureUnitOffset);

            textures.AddTexture("dif", GetSphereTexture("dif", dummyTextures));
            textures.AddTexture("spheremap", GetSphereTexture("spheremap", dummyTextures));
            textures.AddTexture("dif2", GetSphereTexture("dif2", dummyTextures));
            textures.AddTexture("dif3", GetSphereTexture("dif3", dummyTextures));
            textures.AddTexture("stagecube", GetSphereTexture("stagecube", dummyTextures));
            textures.AddTexture("cube", GetSphereTexture("cube", dummyTextures));
            textures.AddTexture("ao", GetSphereTexture("ao", dummyTextures));
            textures.AddTexture("normalMap", GetSphereTexture("normalMap", dummyTextures));
            textures.AddTexture("ramp", GetSphereTexture("ramp", dummyTextures));
            textures.AddTexture("dummyRamp", GetSphereTexture("dummyRamp", dummyTextures));

            textures.SetShaderUniforms(shader);
        }
Пример #2
0
        private static void SetTextureParameters(Texture texture, Nud.MatTexture matTexture)
        {
            // Set the texture's parameters based on the material settings.
            texture.TextureWrapS = NudEnums.wrapModeByMatValue[matTexture.wrapModeS];
            texture.TextureWrapT = NudEnums.wrapModeByMatValue[matTexture.wrapModeT];
            texture.MinFilter    = NudEnums.minFilterByMatValue[matTexture.minFilter];
            texture.MagFilter    = NudEnums.magFilterByMatValue[matTexture.magFilter];

            if (OpenGLExtensions.IsAvailable("GL_EXT_texture_filter_anisotropic") && (texture is Texture2D))
            {
                texture.Bind();
                TextureParameterName anisotropy = (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt;
                GL.TexParameter(TextureTarget.Texture2D, anisotropy, 0.0f);
                if (matTexture.mipDetail == 0x4 || matTexture.mipDetail == 0x6)
                {
                    GL.TexParameter(TextureTarget.Texture2D, anisotropy, 4.0f);
                }
            }
        }
Пример #3
0
        public static Texture GetTexture(int hash, Nud.MatTexture matTexture, int loc, Dictionary <NudEnums.DummyTexture, Texture> dummyTextures)
        {
            // Look through all loaded textures and not just the current modelcontainer.
            foreach (NUT nut in Runtime.textureContainers)
            {
                Texture texture;
                if (nut.glTexByHashId.TryGetValue(hash, out texture))
                {
                    SetTextureParameters(texture, matTexture);
                    return(texture);
                }
            }

            if (Enum.IsDefined(typeof(NudEnums.DummyTexture), hash))
            {
                return(dummyTextures[(NudEnums.DummyTexture)hash]);
            }

            return(RenderTools.defaultTex);
        }