Exemplo n.º 1
0
        internal static void UpdateRenderSettings(MyRenderSettings1 settings)
        {
            MyRender11.Log.WriteLine("UpdateRenderSettings");
            MyRender11.Log.IncreaseIndent();

            var prevSettings = m_renderSettings;

            m_renderSettings = settings;

            LogUpdateRenderSettings(ref settings);

            MyRenderProxy.Settings.EnableCameraInterpolation = settings.InterpolationEnabled;
            MyRenderProxy.Settings.EnableObjectInterpolation = settings.InterpolationEnabled;

            MyRenderProxy.Settings.GrassDensityFactor = settings.GrassDensityFactor;

            //       if(settings.GrassDensityFactor != prevSettings.GrassDensityFactor)
            //           MyRenderProxy.ReloadGrass();

            if (settings.ShadowQuality != prevSettings.ShadowQuality)
            {
                MyShadows.ResizeCascades();
            }

            if (settings.AntialiasingMode != prevSettings.AntialiasingMode)
            {
                GlobalShaderHeader = MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine(), MyRender11.FxaaEnabled ? "FXAA_ENABLED" : null);
                MyShaders.Recompile();
                MyMaterialShaders.Recompile();
                MyRenderableComponent.MarkAllDirty();

                if (settings.AntialiasingMode.SamplesCount() != prevSettings.AntialiasingMode.SamplesCount())
                {
                    CreateScreenResources();
                }
            }

            if (settings.AnisotropicFiltering != prevSettings.AnisotropicFiltering)
            {
                UpdateTextureSampler(m_textureSamplerState, TextureAddressMode.Wrap);
                UpdateTextureSampler(m_alphamaskarraySamplerState, TextureAddressMode.Clamp);
            }

            if (settings.TextureQuality != prevSettings.TextureQuality)
            {
                //MyTextureManager.UnloadTextures();

                MyVoxelMaterials1.InvalidateMaterials();
                MyMeshMaterials1.InvalidateMaterials();
                MyTextures.ReloadQualityDependantTextures();

                //MyVoxelMaterials.ReloadTextures();
                //MyMaterialProxyFactory.ReloadTextures();
            }

            m_settingsChangedListeners();

            MyRender11.Log.DecreaseIndent();
        }
Exemplo n.º 2
0
        internal static void Init()
        {
            //m_copyPs = MyShaders.CreatePs("postprocess.hlsl", "copy");
            //m_clearAlphaPs = MyShaders.CreatePs("postprocess.hlsl", "clear_alpha");

            m_blurH = MyShaders.CreatePs("blur.hlsl", "blur_h", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));
            m_blurV = MyShaders.CreatePs("blur.hlsl", "blur_v");
        }
Exemplo n.º 3
0
        //internal static void RecreateShadersForSettings()
        //{
        //    m_bloomShader = MyShaderFactory.CreateCS("tonemapping.hlsl", "bloom_initial", MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine(), "NUMTHREADS 8"));
        //}

        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_bloomShader     = MyShaders.CreateCs("tonemapping.hlsl", "bloom_initial", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_downscaleShader = MyShaders.CreateCs("tonemapping.hlsl", "downscale", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_blurH           = MyShaders.CreateCs("tonemapping.hlsl", "blur_h", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_blurV           = MyShaders.CreateCs("tonemapping.hlsl", "blur_v", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
        }
Exemplo n.º 4
0
 internal static void Init()
 {
     m_VS          = MyShaders.CreateVs("foliage2.hlsl", "vs");
     m_GS[0]       = MyShaders.CreateGs("foliage2.hlsl", "gs");
     m_PS[0]       = MyShaders.CreatePs("foliage2.hlsl", "ps");
     m_GS[1]       = MyShaders.CreateGs("foliage2.hlsl", "gs", MyShaderHelpers.FormatMacros("ROCK_FOLIAGE"));
     m_PS[1]       = MyShaders.CreatePs("foliage2.hlsl", "ps", MyShaderHelpers.FormatMacros("ROCK_FOLIAGE"));
     m_inputLayout = MyShaders.CreateIL(m_VS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.CUSTOM_UNORM4_0));
 }
        internal unsafe static void Init()
        {
            m_vs          = MyShaders.CreateVs("billboard.hlsl", "vs");
            m_ps          = MyShaders.CreatePs("billboard.hlsl", "ps");
            m_vsLit       = MyShaders.CreateVs("billboard.hlsl", "vs", MyShaderHelpers.FormatMacros("LIT_PARTICLE"));
            m_psLit       = MyShaders.CreatePs("billboard.hlsl", "ps", MyShaderHelpers.FormatMacros("LIT_PARTICLE"));
            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H));

            //MyCallbacks.RegisterDeviceResetListener(new OnDeviceResetDelegate(OnDeviceRestart));

            InitBillboardsIndexBuffer(MaxBillboards);

            m_VB = MyHwBuffers.CreateVertexBuffer(MaxBillboards * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic);

            var stride = sizeof(MyBillboardData);

            m_SB = MyHwBuffers.CreateStructuredBuffer(MaxBillboards, stride, true);

            MyTextureAtlas.ParseAtlasDescription("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai", m_atlasedTextures);
        }
Exemplo n.º 6
0
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

            DirectionalEnvironmentLight_Pixel  = MyShaders.CreatePs("light.hlsl", "directional_environment");
            DirectionalEnvironmentLight_Sample = MyShaders.CreatePs("light.hlsl", "directional_environment", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            PointlightsTiled_Pixel  = MyShaders.CreatePs("light.hlsl", "pointlights_tiled");
            PointlightsTiled_Sample = MyShaders.CreatePs("light.hlsl", "pointlights_tiled", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            m_preparePointLights = MyShaders.CreateCs("prepare_lights.hlsl", "prepare_lights", MyShaderHelpers.FormatMacros("NUMTHREADS " + TILE_SIZE));

            SpotlightProxyVs   = MyShaders.CreateVs("light.hlsl", "proxyVs");
            SpotlightPs_Pixel  = MyShaders.CreatePs("light.hlsl", "spotlightFromProxy");
            SpotlightPs_Sample = MyShaders.CreatePs("light.hlsl", "spotlightFromProxy", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));
            SpotlightProxyIL   = MyShaders.CreateIL(SpotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            var stride = sizeof(MyPointlightConstants);

            m_pointlightCullHwBuffer = MyHwBuffers.CreateStructuredBuffer(MyRender11Constants.MAX_POINT_LIGHTS, stride, true);
            m_pointlightsConstants   = MyHwBuffers.CreateConstantsBuffer(sizeof(MyPointlightInfo) * MyRender11Constants.MAX_POINT_LIGHTS);
            m_spotlightsConstants    = MyHwBuffers.CreateConstantsBuffer(sizeof(MySpotlightConstants) * MyRender11Constants.MAX_SPOTLIGHTS);
            m_sunlightConstants      = MyHwBuffers.CreateConstantsBuffer(sizeof(MySunlightConstantsLayout));
        }
Exemplo n.º 7
0
 internal static new void Init()
 {
     m_gather = MyShaders.CreateCs("shadows.hlsl", "write_shadow", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads) + MyRender11.ShaderCascadesNumberHeader());
     m_blur_h = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, MyRender11.ShaderCascadesNumberDefine()));
     m_blur_v = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, "VERTICAL", MyRender11.ShaderCascadesNumberDefine()));
 }
Exemplo n.º 8
0
 internal static string ShaderMultisamplingHeader()
 {
     return(MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine()));
 }
Exemplo n.º 9
0
 internal static void Init()
 {
     m_initialShader = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_init", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_sumShader     = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_reduce", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_finalShader   = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_reduce", MyShaderHelpers.FormatMacros("NUMTHREADS 8", "_FINAL"));
 }
Exemplo n.º 10
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;


        internal static void Init()
        {
            m_ps           = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereInscatter");
            m_psT          = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereTransmittance");
            m_psPerSample  = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereInscatter", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));
            m_psTPerSample = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereTransmittance", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            m_precomputeDensity    = MyShaders.CreateCs("AtmospherePrecompute.hlsl", "precomputeDensity");
            m_precomputeInscatter1 = MyShaders.CreateCs("AtmospherePrecompute.hlsl", "precomputeInscatter1");

            m_proxyVs = MyShaders.CreateVs("atmosphere.hlsl", "proxyVs");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            //Precompute();
        }
Exemplo n.º 11
0
 internal static void Init()
 {
     m_cs     = MyShaders.CreateCs("tonemapping.hlsl", "tonemapping", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_csSkip = MyShaders.CreateCs("tonemapping.hlsl", "tonemapping", MyShaderHelpers.FormatMacros("NUMTHREADS 8", "DISABLE_TONEMAPPING"));
 }
Exemplo n.º 12
0
 internal static string ShaderCascadesNumberHeader()
 {
     return(MyShaderHelpers.FormatMacros(ShaderCascadesNumberDefine()));
 }
        internal static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("histogram.hlsl", "build_histogram", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_drawHistogram  = MyShaders.CreatePs("data_visualization.hlsl", "display_histogram");

            m_histogram = MyRwTextures.CreateUav1D(512, SharpDX.DXGI.Format.R32_UInt, "histogram");
        }
Exemplo n.º 14
0
        //internal static void RecreateShadersForSettings()
        //{
        //    m_cs = MyShaderFactory.CreateCS("custom_resolve.hlsl", "resolve_lbuffer", MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine(), "NUMTHREADS 8"));
        //}

        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_cs = MyShaders.CreateCs("custom_resolve.hlsl", "resolve_lbuffer", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
        }
Exemplo n.º 15
0
 internal static void Init()
 {
     m_gather = MyShaders.CreateCs("shadows.hlsl", "write_shadow", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads));
     m_blur_h = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads));
     m_blur_v = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, "VERTICAL"));
 }