void InitD3D() { try { m_device.Init(panelOutput.Handle, false, true); m_shader_Render = new Shader(m_device, new System.IO.FileInfo("Shaders/Demo/Render.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS", null); // m_shader_ComputeIndirectMap = new Shader( m_device, new System.IO.FileInfo( "Shaders/Demo/ComputeIndirectMap.hlsl" ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null ); m_shader_ComputeIndirectIrradiance = new Shader(m_device, new System.IO.FileInfo("Shaders/Demo/ComputeIndirectIrradiance2.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS", null); // m_shader_FilterIndirectIrradiance = new Shader( m_device, new System.IO.FileInfo( "Shaders/Demo/FilterIndirectIrradiance.hlsl" ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null ); m_CB_Main = new ConstantBuffer <CB_Main>(m_device, 0); m_CB_Main.m._resolutionX = (uint)panelOutput.Width; m_CB_Main.m._resolutionY = (uint)panelOutput.Height; m_CB_SH = new ConstantBuffer <CB_SH>(m_device, 1); m_CB_ComputeIrradiance = new ConstantBuffer <CB_ComputeIrradiance>(m_device, 2); using (ImageFile I = new ImageFile(new System.IO.FileInfo("BlueNoise64x64.png"))) { using (ImageFile monoI = new ImageFile()) { monoI.ConvertFrom(I, PIXEL_FORMAT.R8); m_tex_BlueNoise = new Texture2D(m_device, new ImagesMatrix(new ImageFile[, ] { { monoI } }), COMPONENT_FORMAT.UNORM); } } InitEnvironmentSH(); UpdateSH(); Application.Idle += Application_Idle; } catch (Exception) { m_device = null; } }
Texture2D CreateTextureFromImage(ImageFile _image) { if (_image.PixelFormat == PIXEL_FORMAT.BGR8) { ImageFile convertedImage = new ImageFile(); convertedImage.ConvertFrom(_image, PIXEL_FORMAT.BGRA8); _image = convertedImage; } ImagesMatrix matrix = new ImagesMatrix(new ImageFile[, ] { { _image } }); Texture2D result = new Texture2D(m_device, matrix, ImageUtility.COMPONENT_FORMAT.UNORM); return(result); }