internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_screenVertexShader    = MyShaders.CreateVs("debug_base_color.hlsl");
            m_baseColorShader       = MyShaders.CreatePs("debug_base_color.hlsl");
            m_baseColorLinearShader = MyShaders.CreatePs("debug_base_color_linear.hlsl");
            m_normalShader          = MyShaders.CreatePs("debug_normal.hlsl");
            m_glossinessShader      = MyShaders.CreatePs("debug_glossiness.hlsl");
            m_metalnessShader       = MyShaders.CreatePs("debug_metalness.hlsl");
            m_matIDShader           = MyShaders.CreatePs("debug_mat_id.hlsl");
            m_aoShader              = MyShaders.CreatePs("debug_ambient_occlusion.hlsl");
            m_emissiveShader        = MyShaders.CreatePs("debug_emissive.hlsl");
            m_ambientDiffuseShader  = MyShaders.CreatePs("debug_ambient_diffuse.hlsl");
            m_ambientSpecularShader = MyShaders.CreatePs("debug_ambient_specular.hlsl");
            m_edgeDebugShader       = MyShaders.CreatePs("debug_edge.hlsl");
            m_shadowsDebugShader    = MyShaders.CreatePs("debug_cascades_shadow.hlsl");
            m_NDotLShader           = MyShaders.CreatePs("debug_NDotL.hlsl");
            m_stencilShader         = MyShaders.CreatePs("debug_Stencil.hlsl");

            m_blitTextureShader      = MyShaders.CreatePs("debug_blitTexture.hlsl");
            m_blitTexture3DShader    = MyShaders.CreatePs("debug_blitTexture3D.hlsl");
            m_blitTextureArrayShader = MyShaders.CreatePs("debug_blitTextureArray.hlsl");
            m_inputLayout            = MyShaders.CreateIL(m_screenVertexShader.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2, MyVertexInputComponentType.TEXCOORD0));

            m_quadBuffer = MyHwBuffers.CreateVertexBuffer(6, MyVertexFormatPosition2Texcoord.STRIDE, BindFlags.VertexBuffer, ResourceUsage.Dynamic);
        }
Esempio n. 2
0
        internal static void OnDeviceReset()
        {
            MyHwBuffers.OnDeviceReset();
            MyShaders.OnDeviceReset();
            MyMaterialShaders.OnDeviceReset();
            MyPipelineStates.OnDeviceReset();
            MyTextures.OnDeviceReset();
            MyRwTextures.OnDeviceReset();
            MyTransparentRendering.OnDeviceReset();

            ResetShadows(Settings.ShadowCascadeCount, RenderSettings.ShadowQuality.ShadowCascadeResolution());

            MyBillboardRenderer.OnDeviceRestart();
            MyScreenDecals.OnDeviceReset();

            MyMeshMaterials1.InvalidateMaterials();
            MyVoxelMaterials1.InvalidateMaterials();

            MyRenderableComponent.MarkAllDirty();
            foreach (var f in MyComponentFactory <MyFoliageComponent> .GetAll())
            {
                f.Dispose();
            }

            foreach (var c in MyComponentFactory <MyGroupRootComponent> .GetAll())
            {
                c.OnDeviceReset();
            }

            MyBigMeshTable.Table.OnDeviceReset();
            MySceneMaterials.OnDeviceReset();
            MyMeshes.OnDeviceReset();
            MyInstancing.OnDeviceReset();
            MyScreenDecals.OnDeviceReset();
        }
 internal static void Init()
 {
     m_ps        = MyShaders.CreatePs("ForwardPostprocess.hlsl", "apply_skybox");
     m_mipmap    = MyShaders.CreateCs("EnvPrefiltering.hlsl", "buildMipmap");
     m_prefilter = MyShaders.CreateCs("EnvPrefiltering.hlsl", "prefilter");
     m_blend     = MyShaders.CreateCs("EnvPrefiltering.hlsl", "blend");
 }
Esempio n. 4
0
        public static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("Debug/Histogram.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
            m_drawHistogram  = MyShaders.CreatePs("Debug/DataVisualizationHistogram.hlsl");

            m_psDisplayHdrIntensity = MyShaders.CreatePs("Debug/DisplayHdrIntensity.hlsl");
        }
        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");
        }
Esempio n. 6
0
        internal unsafe static void Init()
        {
            m_cbCustomProjections = MyHwBuffers.CreateConstantsBuffer(sizeof(Matrix) * MAX_CUSTOM_PROJECTIONS_SIZE, "BilloardCustomProjections");

            m_vs          = MyShaders.CreateVs("Transparent/Billboards.hlsl");
            m_vsDepthOnly = MyShaders.CreateVs("Transparent/BillboardsDepthOnly.hlsl");
            m_ps          = MyShaders.CreatePs("Transparent/Billboards.hlsl");
            m_psDepthOnly = MyShaders.CreatePs("Transparent/BillboardsDepthOnly.hlsl");
            m_psOIT       = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("OIT", null) });
            m_vsLit       = MyShaders.CreateVs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) });
            m_psLit       = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) });
            m_psLitOIT    = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) });

            m_psAlphaCutout       = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null) });
            m_psAlphaCutoutAndLit = MyShaders.CreatePs("Transparent/Billboards.hlsl",
                                                       new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null) });
            m_psAlphaCutoutOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl",
                                                    new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("OIT", null) });
            m_psAlphaCutoutAndLitOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl",
                                                          new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) });

            m_psDebugUniformAccum    = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null) });
            m_psDebugUniformAccumOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null), new ShaderMacro("OIT", null) });

            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H));

            InitBillboardsIndexBuffer();

            m_VB = MyHwBuffers.CreateVertexBuffer(MAX_BILLBOARDS_SIZE * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyBillboardRenderer");

            var stride = sizeof(MyBillboardData);

            m_SB    = MyHwBuffers.CreateStructuredBuffer(MAX_BILLBOARDS_SIZE, stride, true, null, "MyBillboardRenderer");
            m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai");
        }
        internal unsafe MyFoliageGeneratingPass()
        {
            var soElements = new StreamOutputElement[2];

            soElements[0].Stream         = 0;
            soElements[0].SemanticName   = "TEXCOORD";
            soElements[0].SemanticIndex  = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot     = 0;
            soElements[1].Stream         = 0;
            soElements[1].SemanticName   = "TEXCOORD";
            soElements[1].SemanticIndex  = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot     = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            if (m_geometryShader == GeometryShaderId.NULL)
            {
                m_geometryShader = MyShaders.CreateGs("passes/foliage_streaming/geometry_stage.hlsl", null, new MyShaderStreamOutputInfo {
                    Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream
                });
            }

            SetImmediate(true);
        }
Esempio n. 8
0
        private void InitShaders()
        {
            if (m_markVS == VertexShaderId.NULL)
            {
                m_markVS = MyShaders.CreateVs("shape.hlsl");
            }

            if (m_markPS == PixelShaderId.NULL)
            {
                m_markPS = MyShaders.CreatePs("shape.hlsl");
            }

            if (m_inputLayout == InputLayoutId.NULL)
            {
                m_inputLayout = MyShaders.CreateIL(m_markVS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));
            }

            if (m_combinePS == PixelShaderId.NULL)
            {
                m_combinePS = MyShaders.CreatePs("CombineShadows.hlsl");
            }

            m_gatherCS_LD = MyShaders.CreateCs("shadows.hlsl");
            m_gatherCS_MD = MyShaders.CreateCs("shadows.hlsl", new [] { new ShaderMacro("ENABLE_PCF", null) });
            m_gatherCS_HD = MyShaders.CreateCs("shadows.hlsl", new[] { new ShaderMacro("ENABLE_PCF", null), new ShaderMacro("ENABLE_DISTORTION", null) });
        }
Esempio n. 9
0
        internal static void OnDeviceReset()
        {
            MyHwBuffers.OnDeviceReset();
            MyShaders.OnDeviceReset();
            MyMaterialShaders.OnDeviceReset();
            MyPipelineStates.OnDeviceReset();
            MyTextures.OnDeviceReset();
            MyRwTextures.OnDeviceEnd();
            MyShadows.OnDeviceReset();
            MyBillboardRenderer.OnDeviceRestart();

            MyMeshMaterials1.InvalidateMaterials();
            MyVoxelMaterials1.InvalidateMaterials();

            MyRenderableComponent.MarkAllDirty();
            foreach (var f in MyComponentFactory <MyFoliageComponent> .GetAll())
            {
                f.Dispose();
            }

            foreach (var c in MyComponentFactory <MyGroupRootComponent> .GetAll())
            {
                c.OnDeviceReset();
            }

            MyBigMeshTable.Table.OnDeviceReset();
            MySceneMaterials.OnDeviceReset();
            MyMeshes.OnDeviceReset();
            MyInstancing.OnDeviceReset();
        }
        private void InitShaders()
        {
            if (m_VS == VertexShaderId.NULL)
            {
                m_VS = MyShaders.CreateVs(FoliageRenderShader);
            }

            if (m_GS[0] == GeometryShaderId.NULL)
            {
                m_GS[0] = MyShaders.CreateGs(FoliageRenderShader);
            }

            if (m_PS[0] == PixelShaderId.NULL)
            {
                m_PS[0] = MyShaders.CreatePs(FoliageRenderShader);
            }

            var foliageMacro = new[] { new ShaderMacro("ROCK_FOLIAGE", null) };

            if (m_GS[1] == GeometryShaderId.NULL)
            {
                m_GS[1] = MyShaders.CreateGs(FoliageRenderShader, foliageMacro);
            }

            if (m_PS[1] == PixelShaderId.NULL)
            {
                m_PS[1] = MyShaders.CreatePs(FoliageRenderShader, foliageMacro);
            }

            if (m_inputLayout == InputLayoutId.NULL)
            {
                m_inputLayout = MyShaders.CreateIL(m_VS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.CUSTOM_UNORM4_0));
            }
        }
Esempio n. 11
0
        internal unsafe static void Init()
        {
            //m_spotlightShadowmapPool = new MyShadowmapArray(256, 256, 4, Format.R16_Typeless, Format.D16_UNorm, Format.R16_Float);
            //m_spotlightShadowmapPool.SetDebugName("spotlight shadowmaps pool");

            m_cascadesNum = 4;
            m_splitDepth  = new float[m_cascadesNum + 1];

            m_cascadeResolution = 1024;
            ResizeCascades();

            m_csmConstants = MyHwBuffers.CreateConstantsBuffer((sizeof(Matrix) + sizeof(Vector2)) * 8 + 2 * sizeof(Vector4));

            m_cascadesBoundingsVertices = MyHwBuffers.CreateVertexBuffer(8 * 4, sizeof(Vector3), BindFlags.VertexBuffer, ResourceUsage.Dynamic);
            InitIB();

            m_cornersCS = new Vector3[8] {
                new Vector3(-1, -1, 0),
                new Vector3(-1, 1, 0),
                new Vector3(1, 1, 0),
                new Vector3(1, -1, 0),

                new Vector3(-1, -1, 1),
                new Vector3(-1, 1, 1),
                new Vector3(1, 1, 1),
                new Vector3(1, -1, 1)
            };

            m_markVS      = MyShaders.CreateVs("shape.hlsl", "vs");
            m_markPS      = MyShaders.CreatePs("shape.hlsl", "ps_dummy");
            m_inputLayout = MyShaders.CreateIL(m_markVS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));
        }
        internal unsafe MyFoliageGeneratingPass()
        {
            var soElements = new StreamOutputElement[2];

            soElements[0].Stream         = 0;
            soElements[0].SemanticName   = "TEXCOORD";
            soElements[0].SemanticIndex  = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot     = 0;
            soElements[1].Stream         = 0;
            soElements[1].SemanticName   = "TEXCOORD";
            soElements[1].SemanticIndex  = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot     = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            if (m_geometryShader == GeometryShaderId.NULL)
            {
                string stageFile = Path.Combine(MyMaterialShaders.PassesFolder, MyMaterialShaders.FOLIAGE_STREAMING_PASS, "GeometryStage.hlsl");
                m_geometryShader = MyShaders.CreateGs(stageFile, null, new MyShaderStreamOutputInfo {
                    Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream
                });
            }

            SetImmediate(true);
        }
Esempio n. 13
0
        internal static void Init()
        {
            MyGPUEmitters.Init();

            m_resetSystem = true;

            m_csInitDeadList   = MyShaders.CreateCs("Transparent/GPUParticles/InitDeadList.hlsl", null);
            m_csResetParticles = MyShaders.CreateCs("Transparent/GPUParticles/Reset.hlsl", null);
            m_csEmit           = MyShaders.CreateCs("Transparent/GPUParticles/Emit.hlsl", null);
            m_csEmitSkipFix    = MyShaders.CreateCs("Transparent/GPUParticles/EmitSkipFix.hlsl", null);
            m_csSimulate       = MyShaders.CreateCs("Transparent/GPUParticles/Simulation.hlsl", null);

            var macrosRender    = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null) };
            var macrosRenderOIT = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) };

            m_vs    = MyShaders.CreateVs("Transparent/GPUParticles/Render.hlsl", macrosRender);
            m_ps    = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", macrosRender);
            m_psOIT = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", macrosRenderOIT);

            var macroDebug = new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null) };

            m_psDebugUniformAccum    = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", MyShaders.ConcatenateMacros(macrosRender, macroDebug));
            m_psDebugUniformAccumOIT = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", MyShaders.ConcatenateMacros(macrosRenderOIT, macroDebug));

            InitDevice();
        }
        private static void UpdateAntialiasingMode(MyAntialiasingMode mode, MyAntialiasingMode oldMode)
        {
            var defineList = new List <ShaderMacro>();
            var msDefine   = ShaderMultisamplingDefine();

            if (msDefine.HasValue)
            {
                defineList.Add(msDefine.Value);
            }
            if (DebugMode)
            {
                defineList.Add(MyShadersDefines.DebugMacro);
            }

            GlobalShaderMacro = defineList.ToArray();

            MyShaders.Recompile();
            MyMaterialShaders.Recompile();
            MyRenderableComponent.MarkAllDirty();

            if (mode.SamplesCount() != oldMode.SamplesCount())
            {
                CreateScreenResources();
            }
        }
        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_screenVertexShader    = MyShaders.CreateVs("Debug/DebugBaseColor.hlsl");
            m_baseColorShader       = MyShaders.CreatePs("Debug/DebugBaseColor.hlsl");
            m_albedoShader          = MyShaders.CreatePs("Debug/DebugAlbedo.hlsl");
            m_normalShader          = MyShaders.CreatePs("Debug/DebugNormal.hlsl");
            m_normalViewShader      = MyShaders.CreatePs("Debug/DebugNormalView.hlsl");
            m_glossinessShader      = MyShaders.CreatePs("Debug/DebugGlossiness.hlsl");
            m_metalnessShader       = MyShaders.CreatePs("Debug/DebugMetalness.hlsl");
            m_aoShader              = MyShaders.CreatePs("Debug/DebugAmbientOcclusion.hlsl");
            m_emissiveShader        = MyShaders.CreatePs("Debug/DebugEmissive.hlsl");
            m_ambientDiffuseShader  = MyShaders.CreatePs("Debug/DebugAmbientDiffuse.hlsl");
            m_ambientSpecularShader = MyShaders.CreatePs("Debug/DebugAmbientSpecular.hlsl");
            m_edgeDebugShader       = MyShaders.CreatePs("Debug/DebugEdge.hlsl");
            m_shadowsDebugShader    = MyShaders.CreatePs("Debug/DebugCascadesShadow.hlsl");
            m_NDotLShader           = MyShaders.CreatePs("Debug/DebugNDotL.hlsl");
            m_depthShader           = MyShaders.CreatePs("Debug/DebugDepth.hlsl");
            m_stencilShader         = MyShaders.CreatePs("Debug/DebugStencil.hlsl");
            m_rtShader              = MyShaders.CreatePs("Debug/DebugRt.hlsl");

            m_blitTextureShader      = MyShaders.CreatePs("Debug/DebugBlitTexture.hlsl");
            m_blitTexture3DShader    = MyShaders.CreatePs("Debug/DebugBlitTexture3D.hlsl");
            m_blitTextureArrayShader = MyShaders.CreatePs("Debug/DebugBlitTextureArray.hlsl");
            m_inputLayout            = MyShaders.CreateIL(m_screenVertexShader.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2, MyVertexInputComponentType.TEXCOORD0));

            m_quadBuffer = MyHwBuffers.CreateVertexBuffer(6, MyVertexFormatPosition2Texcoord.STRIDE, BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyDebugRenderer quad");
        }
Esempio n. 16
0
 internal static unsafe void Init()
 {
     m_vs          = MyShaders.CreateVs("Primitives/OcclusionQuery.hlsl", null);
     m_ps          = MyShaders.CreatePs("Primitives/OcclusionQuery.hlsl", null);
     m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(
                                            new MyVertexInputComponent(MyVertexInputComponentType.CUSTOM4_0, MyVertexInputComponentFreq.PER_INSTANCE)));
 }
Esempio n. 17
0
        private static void OnDeviceReset()
        {
            MyManagers.OnDeviceReset();

            MyShaders.OnDeviceReset();
            MyMaterialShaders.OnDeviceReset();

            MyTransparentRendering.OnDeviceReset();

            ResetShadows(MyShadowCascades.Settings.NewData.CascadesCount, Settings.User.ShadowQuality.ShadowCascadeResolution());

            MyBillboardRenderer.OnDeviceReset();
            MyScreenDecals.OnDeviceReset();

            MyMeshMaterials1.OnDeviceReset();
            MyVoxelMaterials1.OnDeviceReset();

            MyRenderableComponent.MarkAllDirty();
            foreach (var f in MyComponentFactory <MyFoliageComponent> .GetAll())
            {
                f.Dispose();
            }

            foreach (var c in MyComponentFactory <MyGroupRootComponent> .GetAll())
            {
                c.OnDeviceReset();
            }

            MyBigMeshTable.Table.OnDeviceReset();
            MySceneMaterials.OnDeviceReset();
            MyMeshes.OnDeviceReset();
            MyInstancing.OnDeviceReset();
            MyScreenDecals.OnDeviceReset();
        }
Esempio n. 18
0
 internal static void Init()
 {
     m_VS          = MyShaders.CreateVs("foliage2.hlsl", "vs");
     m_GS          = MyShaders.CreateGs("foliage2.hlsl", "gs");
     m_PS          = MyShaders.CreatePs("foliage2.hlsl", "ps");
     m_inputLayout = MyShaders.CreateIL(m_VS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.CUSTOM_UNORM4_0));
 }
Esempio n. 19
0
        internal static void Init()
        {
            m_vs = MyShaders.CreateVs("decal.hlsl", "vs");
            m_ps = MyShaders.CreatePs("decal.hlsl", "ps");

            InitIB();
        }
Esempio n. 20
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();
        }
Esempio n. 21
0
 internal static void Init()
 {
     m_ps         = MyShaders.CreatePs("ForwardPostprocess.hlsl");
     m_atmosphere = MyShaders.CreatePs("AtmospherePostprocess.hlsl");
     m_mipmap     = MyShaders.CreateCs("EnvPrefiltering_mipmap.hlsl");
     m_prefilter  = MyShaders.CreateCs("EnvPrefiltering.hlsl");
     m_blend      = MyShaders.CreateCs("EnvPrefiltering_blend.hlsl");
 }
Esempio n. 22
0
        internal static void Init()
        {
            m_buildHistogram  = MyShaders.CreateCs("histogram.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
            m_drawHistogram   = MyShaders.CreatePs("data_visualization_histogram.hlsl");
            m_drawTonemapping = MyShaders.CreatePs("data_visualization_tonemapping.hlsl");

            m_histogram = MyRwTextures.CreateUav1D(513, SharpDX.DXGI.Format.R32_UInt, "histogram");
        }
Esempio n. 23
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"));
        }
Esempio n. 24
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");
        }
        internal static void Init()
        {
            var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };

            m_initialShader = MyShaders.CreateCs("luminance_reduction_init.hlsl", threadMacro);
            m_sumShader     = MyShaders.CreateCs("luminance_reduction.hlsl", threadMacro);
            m_finalShader   = MyShaders.CreateCs("luminance_reduction.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8), new ShaderMacro("_FINAL", null) });
        }
Esempio n. 26
0
        internal static void Init()
        {
            m_VSCopy = MyShaders.CreateVs("Postprocess/PostprocessCopy.hlsl");

            {
                m_VBFullscreen = MyManagers.Buffers.CreateVertexBuffer(
                    "MyScreenPass.VBFullscreen", 4, VRageRender.Vertex.MyVertexFormatPositionTextureH.STRIDE,
                    usage: ResourceUsage.Dynamic);
                m_vbData[0] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(-1, -1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0, 1f));
                m_vbData[1] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(-1, 1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0, 0));
                m_vbData[2] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(1, -1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(1, 1f));
                m_vbData[3] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(1, 1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(1, 0f));
                MyMapping mapping = MyMapping.MapDiscard(RC, m_VBFullscreen);
                mapping.WriteAndPosition(m_vbData, 4);
                mapping.Unmap();
            }

            {
                m_VBLeftPart = MyManagers.Buffers.CreateVertexBuffer(
                    "MyVRScreenPass.VBLeftPart", 4, VRageRender.Vertex.MyVertexFormatPositionTextureH.STRIDE,
                    usage: ResourceUsage.Dynamic);
                m_vbData[0] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(-1, -1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0, 1));
                m_vbData[1] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(-1, 1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0, 0));
                m_vbData[2] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(0, -1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0.5f, 1));
                m_vbData[3] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(0, 1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0.5f, 0f));
                MyMapping mapping = MyMapping.MapDiscard(RC, m_VBLeftPart);
                mapping.WriteAndPosition(m_vbData, 4);
                mapping.Unmap();
            }

            {
                m_VBRightPart = MyManagers.Buffers.CreateVertexBuffer(
                    "MyVRScreenPass.VBRightPart", 4, VRageRender.Vertex.MyVertexFormatPositionTextureH.STRIDE,
                    usage: ResourceUsage.Dynamic);
                m_vbData[0] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(0, -1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0.5f, 1));
                m_vbData[1] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(0, 1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(0.5f, 0));
                m_vbData[2] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(1, -1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(1, 1));
                m_vbData[3] = new VRageRender.Vertex.MyVertexFormatPositionTextureH(new Vector3(1, 1, 0),
                                                                                    new VRageMath.PackedVector.HalfVector2(1, 0));
                MyMapping mapping = MyMapping.MapDiscard(RC, m_VBRightPart);
                mapping.WriteAndPosition(m_vbData, 4);
                mapping.Unmap();
            }

            // just some shader bytecode is selected
            m_IL = MyShaders.CreateIL(m_VSCopy.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H));
        }
Esempio n. 27
0
        internal unsafe static void Init()
        {
            m_vs          = MyShaders.CreateVs("line.hlsl");
            m_ps          = MyShaders.CreatePs("line.hlsl");
            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.COLOR4));

            m_currentBufferSize = 100000;
            m_VB = MyHwBuffers.CreateVertexBuffer(m_currentBufferSize, sizeof(MyVertexFormatPositionColor), BindFlags.VertexBuffer, ResourceUsage.Dynamic);
        }
Esempio n. 28
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));
 }
        static void RenderDirectionalEnvironmentLight()
        {
            PixelShaderId directionalPixelShader;

            if (!MyRenderProxy.Settings.EnableShadows)
            {
                if (DirectionalEnvironmentLight_NoShadow == PixelShaderId.NULL)
                {
                    DirectionalEnvironmentLight_NoShadow = MyShaders.CreatePs("light_dir.hlsl", new[] { new ShaderMacro("NO_SHADOWS", null) });
                }

                directionalPixelShader = DirectionalEnvironmentLight_NoShadow;
            }
            else
            {
                directionalPixelShader = DirectionalEnvironmentLight_Pixel;
            }
            MySunlightConstantsLayout constants;

            constants.Direction = MyEnvironment.DirectionalLightDir;
            constants.Color     = MyEnvironment.DirectionalLightIntensity;

            var mapping = MyMapping.MapDiscard(m_sunlightConstants);

            mapping.WriteAndPosition(ref constants);
            mapping.Unmap();

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.SetPS(directionalPixelShader);
            RC.SetCB(1, m_sunlightConstants);
            RC.SetCB(4, MyRender11.DynamicShadows.ShadowCascades.CascadeConstantBuffer);
            RC.DeviceContext.PixelShader.SetSamplers(0, MyRender11.StandardSamplers);
            RC.DeviceContext.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkybox, MyTextureEnum.CUBEMAP, true)));

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT,
                                                           MyRender11.IsIntelBrokenCubemapsWorkaround ? MyTextures.GetView(MyTextures.IntelFallbackCubeTexId) : MyEnvironmentProbe.Instance.cubemapPrefiltered.ShaderView);
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkybox, MyTextureEnum.CUBEMAP, true)));
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, MyRender11.DynamicShadows.ShadowCascades.CascadeShadowmapArray.ShaderView);
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SHADOW_SLOT, MyRender11.PostProcessedShadows.ShaderView);

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                                           MyCommon.GetAmbientBrdfLut());

            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }
Esempio n. 30
0
        internal static unsafe void Init()
        {
            m_ps = MyShaders.CreatePs("EnvProbe/ForwardPostprocess.hlsl");
            //m_atmosphere = MyShaders.CreatePs("EnvProbe/AtmospherePostprocess.hlsl");
            m_mipmap    = MyShaders.CreateCs("EnvProbe/EnvPrefilteringMipmap.hlsl");
            m_prefilter = MyShaders.CreateCs("EnvProbe/EnvPrefiltering.hlsl");
            m_blend     = MyShaders.CreateCs("EnvProbe/EnvPrefilteringBlend.hlsl");

            TransformConstants = MyManagers.Buffers.CreateConstantBuffer("TransformConstants", sizeof(Matrix) * 2 + sizeof(Vector4), usage: ResourceUsage.Dynamic);
        }