Exemplo n.º 1
0
        private static void RenderPresetsToFiles()
        {
            using (GameWindow gameWindow = OpenTkSharedResources.CreateGameWindowContext(width, height))
            {
                // Resource creation.
                screenTriangle = ScreenDrawing.CreateScreenTriangle();
                shader         = OpenTkSharedResources.shaders["NudSphere"];

                // Skip thumbnail generation if the shader didn't compile.
                if (!shader.LinkStatusIsOk)
                {
                    return;
                }

                // HACK: This isn't a very clean way to pass resources around.
                NudMatSphereDrawing.LoadMaterialSphereTextures();
                Dictionary <NudEnums.DummyTexture, Texture> dummyTextures = RenderTools.CreateNudDummyTextures();

                CreateNudSphereShader();

                foreach (string file in Directory.EnumerateFiles(MainForm.executableDir + "\\materials", "*.nmt", SearchOption.AllDirectories))
                {
                    Nud.Material material   = NudMaterialEditor.ReadMaterialListFromPreset(file)[0];
                    string       presetName = Path.GetFileNameWithoutExtension(file);
                    RenderMaterialPresetToFile(presetName, material, dummyTextures);
                }
            }
        }
Exemplo n.º 2
0
        public static void LoadTextures()
        {
            dummyTextures = CreateNudDummyTextures();

            NudMatSphereDrawing.LoadMaterialSphereTextures();

            // Helpful textures.
            uvTestPattern = new Texture2D();
            uvTestPattern.LoadImageData(Properties.Resources.UVPattern);
            uvTestPattern.TextureWrapS = TextureWrapMode.Repeat;
            uvTestPattern.TextureWrapT = TextureWrapMode.Repeat;

            // TODO: Simplify this conversion.
            Dds specularSdr = new Dds(new FileData(Properties.Resources.specularSDR));

            specularPbr = NUT.CreateTextureCubeMap(specularSdr.ToNutTexture());

            Dds diffuseSdr = new Dds(new FileData(Properties.Resources.diffuseSDR));

            diffusePbr = NUT.CreateTextureCubeMap(diffuseSdr.ToNutTexture());
            // Don't use mipmaps.
            diffusePbr.MinFilter = TextureMinFilter.Linear;
            diffusePbr.MagFilter = TextureMagFilter.Linear;

            boneWeightGradient = new Texture2D();
            boneWeightGradient.LoadImageData(Properties.Resources.boneWeightGradient);

            boneWeightGradient2 = new Texture2D();
            boneWeightGradient2.LoadImageData(Properties.Resources.boneWeightGradient2);

            defaultTex = new Texture2D();
            defaultTex.LoadImageData(Resources.Resources.DefaultTexture);

            try
            {
                floorTexture = new Texture2D();
                floorTexture.LoadImageData(new Bitmap(Runtime.floorTexFilePath));

                backgroundTexture = new Texture2D();
                backgroundTexture.LoadImageData(new Bitmap(Runtime.backgroundTexFilePath));
            }
            catch (Exception)
            {
                // File paths are incorrect or never set.
            }
        }
Exemplo n.º 3
0
        private static void RenderMaterialPresetToFile(string presetName, Nud.Material material, Dictionary <NudEnums.DummyTexture, Texture> dummyTextures)
        {
            // Setup new dimensions.
            GL.Viewport(0, 0, width, height);

            Framebuffer framebuffer = new Framebuffer(FramebufferTarget.Framebuffer, width, height, PixelInternalFormat.Rgba);

            framebuffer.Bind();

            // Draw the material to a textured quad.
            NudMatSphereDrawing.DrawNudMaterialSphere(shader, material, screenTriangle, dummyTextures);

            // Save output.
            using (Bitmap image = framebuffer.ReadImagePixels(true))
            {
                string outputPath = String.Format("{0}\\Preview Images\\{1}.png", MainForm.executableDir, presetName);
                image.Save(outputPath);
            }
        }