Esempio n. 1
0
        protected override void  OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                m_device.Init(m_viewerForm.Handle, false, true);

                // Create our compute shaders
                                #if !DEBUG
                using (ScopedForceShadersLoadFromBinary scope = new ScopedForceShadersLoadFromBinary())
                                #endif
                {
                    m_CS_BilateralFilter   = new ComputeShader(m_device, new System.IO.FileInfo("./Shaders/BilateralFiltering.hlsl"), "CS", null);
                    m_CS_GenerateSSBumpMap = new ComputeShader(m_device, new System.IO.FileInfo("./Shaders/GenerateSSBumpMap.hlsl"), "CS", null);
                    m_PS_Display           = new Shader(m_device, new System.IO.FileInfo("./Shaders/Display.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS", null);
                }


                // Create our constant buffers
                m_CB_Input  = new ConstantBuffer <CBInput>(m_device, 0);
                m_CB_Filter = new ConstantBuffer <CBFilter>(m_device, 0);

                m_CB_Display           = new ConstantBuffer <CBDisplay>(m_device, 0);
                m_CB_Display.m._Width  = (uint)m_viewerForm.Width;
                m_CB_Display.m._Height = (uint)m_viewerForm.Height;

                // Create our structured buffer containing the rays
                m_SB_Rays = new StructuredBuffer <float3>(m_device, 3 * MAX_THREADS, true, false);
                integerTrackbarControlRaysCount_SliderDragStop(integerTrackbarControlRaysCount, 0);

//				LoadHeightMap( new System.IO.FileInfo( "eye_generic_01_disp.png" ) );
//				LoadHeightMap( new System.IO.FileInfo( "10 - Smooth.jpg" ) );
            } catch (Exception _e) {
                MessageBox("Failed to create DX11 device and default shaders:\r\n", _e);
                Close();
            }
        }
Esempio n. 2
0
        public void Init()
        {
                        #if !DEBUG
            using (ScopedForceShadersLoadFromBinary scope = new ScopedForceShadersLoadFromBinary())
                        #endif
            {
                m_PS_Display = new Shader(Device, new System.IO.FileInfo("./Shaders/Display.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
            }

            m_CB_Display           = new ConstantBuffer <CBDisplay>(Device, 0);
            m_CB_Display.m._Width  = (uint)Width;
            m_CB_Display.m._Height = (uint)Height;

            // Setup camera
            m_Camera.CreatePerspectiveCamera((float)(60.0 * Math.PI / 180.0), (float)Width / Height, 0.01f, 100.0f);
            m_Manipulator.Attach(this, m_Camera);
            m_Manipulator.InitializeCamera(new float3(0, -0.1f, 0.1f), new float3(0, 0, 0), float3.UnitY);
            m_Manipulator.ManipulationPanSpeed = 0.1f;
            m_Camera.CameraTransformChanged   += new EventHandler(Camera_CameraTransformChanged);
            m_Manipulator.EnableMouseAction   += new CameraManipulator.EnableMouseActionEventHandler(m_Manipulator_EnableMouseAction);
            Camera_CameraTransformChanged(m_Manipulator, EventArgs.Empty);

            Application.Idle += new EventHandler(Application_Idle);
        }
Esempio n. 3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                m_Device.Init(panelOutput.Handle, false, true);
            } catch (Exception _e) {
                m_Device = null;
                MessageBox("Failed to initialize DX device!\n\n" + _e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            m_CB_Main         = new ConstantBuffer <CB_Main>(m_Device, 0);
            m_CB_Camera       = new ConstantBuffer <CB_Camera>(m_Device, 1);
            m_CB_AutoExposure = new ConstantBuffer <CB_AutoExposure>(m_Device, 10);
            m_CB_ToneMapping  = new ConstantBuffer <CB_ToneMapping>(m_Device, 10);

            try {
                                #if !DEBUG
                ScopedForceShadersLoadFromBinary loadFromBinary = new ScopedForceShadersLoadFromBinary();
                                #endif
                m_Shader_RenderHDR            = new Shader(m_Device, new System.IO.FileInfo("Shaders/RenderCubeMap.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
                m_Shader_ComputeTallHistogram = new ComputeShader(m_Device, new System.IO.FileInfo("Shaders/AutoExposure/ComputeTallHistogram.hlsl"), "CS");
                m_Shader_FinalizeHistogram    = new ComputeShader(m_Device, new System.IO.FileInfo("Shaders/AutoExposure/FinalizeHistogram.hlsl"), "CS");
                m_Shader_ComputeAutoExposure  = new ComputeShader(m_Device, new System.IO.FileInfo("Shaders/AutoExposure/ComputeAutoExposure.hlsl"), "CS");
                m_Shader_ToneMapping          = new Shader(m_Device, new System.IO.FileInfo("Shaders/ToneMapping.hlsl"), VERTEX_FORMAT.Pt4, "VS", null, "PS");
            } catch (Exception _e) {
                MessageBox("Shader failed to compile!\n\n" + _e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                m_Shader_RenderHDR            = null;
                m_Shader_ComputeTallHistogram = null;
                m_Shader_FinalizeHistogram    = null;
                m_Shader_ComputeAutoExposure  = null;
                m_Shader_ToneMapping          = null;
            }

            // Create the HDR buffer
            m_Tex_HDR = new Texture2D(m_Device, (uint)panelOutput.Width, (uint)panelOutput.Height, 1, 1, ImageUtility.PIXEL_FORMAT.RGBA32F, ImageUtility.COMPONENT_FORMAT.AUTO, false, false, null);

            // Create the histogram & auto-exposure buffers
            int tallHistogramHeight = (panelOutput.Height + 3) >> 2;
            m_Tex_TallHistogram         = new Texture2D(m_Device, 128, (uint)tallHistogramHeight, 1, 1, ImageUtility.PIXEL_FORMAT.R32, ImageUtility.COMPONENT_FORMAT.UINT, false, true, null);
            m_Tex_Histogram             = new Texture2D(m_Device, 128, 1, 1, 1, ImageUtility.PIXEL_FORMAT.R32, ImageUtility.COMPONENT_FORMAT.UINT, false, true, null);
            m_Buffer_AutoExposureSource = new StructuredBuffer <autoExposure_t>(m_Device, 1, true, false);
            m_Buffer_AutoExposureSource.m[0].EngineLuminanceFactor  = 1.0f;
            m_Buffer_AutoExposureSource.m[0].TargetLuminance        = 1.0f;
            m_Buffer_AutoExposureSource.m[0].MinLuminanceLDR        = 0.0f;
            m_Buffer_AutoExposureSource.m[0].MaxLuminanceLDR        = 1.0f;
            m_Buffer_AutoExposureSource.m[0].MiddleGreyLuminanceLDR = 1.0f;
            m_Buffer_AutoExposureSource.m[0].EV    = 0.0f;
            m_Buffer_AutoExposureSource.m[0].Fstop = 0.0f;
            m_Buffer_AutoExposureSource.m[0].PeakHistogramValue = 0;
            m_Buffer_AutoExposureSource.Write();
            m_Buffer_AutoExposureTarget = new StructuredBuffer <autoExposure_t>(m_Device, 1, true, false);

            // Load cube map
            try {
                m_Tex_CubeMap = LoadCubeMap(new System.IO.FileInfo("garage4_hd.dds"));
//				m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\hdrcube6.dds" ) );
//				m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_28_cube_BC6H_UF16.bimage" ) );		// Tunnel
//              m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_89_cube_BC6H_UF16.bimage" ) );		// Large sky
//              m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_115_cube_BC6H_UF16.bimage" ) );	// Indoor
//              m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_123_cube_BC6H_UF16.bimage" ) );	// Under the arch
//              m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_189_cube_BC6H_UF16.bimage" ) );	// Indoor viewing out (vista)
//              m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_246_cube_BC6H_UF16.bimage" ) );	// Nice! Statue's feet
//              m_Tex_CubeMap = LoadCubeMap( new System.IO.FileInfo( @"..\..\..\Arkane\CubeMaps\dust_return\pr_obe_248_cube_BC6H_UF16.bimage" ) );	// Nice! In a corner with lot of sky
            } catch (Exception) {
            }

            // Setup camera
            m_Camera.CreatePerspectiveCamera((float)(90.0 * Math.PI / 180.0), (float)panelOutput.Width / panelOutput.Height, 0.01f, 100.0f);
            m_Manipulator.Attach(panelOutput, m_Camera);
            m_Manipulator.InitializeCamera(new float3(0, 0, 1), new float3(0, 0, 0), float3.UnitY);
        }