コード例 #1
0
        private static void RenderPresetsToFiles()
        {
            using (GameWindow gameWindow = OpenTKSharedResources.CreateGameWindowContext(width, height))
            {
                // Resource creation.
                screenVao = ScreenDrawing.CreateScreenTriangleVao();
                shader    = OpenTKSharedResources.shaders["NudSphere"];

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

                // HACK: This isn't a very clean way to pass resources around.
                NudMatSphereDrawing.LoadMaterialSphereTextures();
                Dictionary <NUD.DummyTextures, 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);
                }
            }
        }
コード例 #2
0
ファイル: RenderTools.cs プロジェクト: y4my4my4m/Smash-Forge
        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.
            }
        }
コード例 #3
0
        private static void RenderMaterialPresetToFile(string presetName, NUD.Material material, Dictionary <NUD.DummyTextures, 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, screenVao, dummyTextures);

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