Exemple #1
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));
 }
        internal unsafe static InstancingId Create(uint GID, MyRenderInstanceBufferType type, string debugName)
        {
            var id = new InstancingId {
                Index = Instancings.Allocate()
            };

            Instancings.Data[id.Index] = new MyInstancingInfo
            {
                Type      = type,
                DebugName = debugName
            };

            MyArrayHelpers.Reserve(ref Data, id.Index + 1);
            Data[id.Index] = new MyInstancingData {
                VB = VertexBufferId.NULL
            };

            if (type == MyRenderInstanceBufferType.Cube)
            {
                Instancings.Data[id.Index].Layout = MyVertexLayouts.GetLayout(new MyVertexInputComponent(MyVertexInputComponentType.CUBE_INSTANCE, 2, MyVertexInputComponentFreq.PER_INSTANCE));
                Instancings.Data[id.Index].Stride = sizeof(MyVertexFormatCubeInstance);
            }
            else
            {
                Instancings.Data[id.Index].Layout = MyVertexLayouts.GetLayout(new MyVertexInputComponent(MyVertexInputComponentType.GENERIC_INSTANCE, 2, MyVertexInputComponentFreq.PER_INSTANCE));
                Instancings.Data[id.Index].Stride = sizeof(MyVertexFormatGenericInstance);
            }

            Debug.Assert(!IdIndex.ContainsKey(GID), "Creating instance with ID that already exists!");
            IdIndex.Add(GID, id);

            return(id);
        }
        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));
            }
        }
Exemple #4
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));
        }
Exemple #5
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)));
 }
Exemple #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");
        }
Exemple #7
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) });
        }
Exemple #8
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));
        }
 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));
 }
Exemple #10
0
 internal static void Init()
 {
     OneAndOnlySupportedVertexLayout = MyVertexLayouts.GetLayout(
         new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED),
         new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
         new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
         new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)
         );
 }
Exemple #11
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);
        }
        // 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");
            m_psPerSample = MyShaders.CreatePs("atmosphere.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_precomputeDensity = MyShaders.CreateCs("AtmospherePrecompute.hlsl");

            m_proxyVs = MyShaders.CreateVs("atmosphere.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));
        }
Exemple #13
0
        internal static unsafe void InitSubsystems()
        {
            InitializeBlendStates();
            InitializeRasterizerStates();
            InitilizeSamplerStates();

            MyCommon.Init();
            MyPipelineStates.Init();
            MyTextures.Init();
            MyVertexLayouts.Init();
            MyShaders.Init();
            MyRwTextures.Init();
            MyHwBuffers.Init();
            MyMeshes.Init();
            MyMeshTableSRV.Init();
            MyMergeInstancing.Init();
            MyGeometryRenderer.Init();
            MyLightRendering.Init();
            MyShadows.Init();
            MyLinesRenderer.Init();
            MySpritesRenderer.Init();
            MyPrimitivesRenderer.Init();
            MyFoliageRenderer.Init();
            MyOutline.Init();

            MyComponents.Init();

            MyBillboardRenderer.Init(); // hardcoded limits
            MyDebugRenderer.Init();
            MyGPUFoliageGenerating.Init();

            MyScreenDecals.Init();
            MyEnvProbeProcessing.Init();
            MyShadowsResolve.Init();
            MyAtmosphereRenderer.Init();
            MyAAEdgeMarking.Init();
            MyScreenPass.Init();
            MyCopyToRT.Init();
            MyBlendTargets.Init();
            MyFXAA.Init();
            MyDepthResolve.Init();
            MyBloom.Init();
            MyLuminanceAverage.Init();
            MyToneMapping.Init();
            MySSAO.Init();
            MyHdrDebugTools.Init();

            MySceneMaterials.Init();
            MyMaterials1.Init();
            MyVoxelMaterials1.Init();
            MyMeshMaterials1.Init();

            //MyShaderFactory.RunCompilation(); // rebuild
        }
Exemple #14
0
        internal unsafe static void Init()
        {
            m_vs          = MyShaders.CreateVs("Primitives/Lines.hlsl");
            m_ps          = MyShaders.CreatePs("Primitives/Lines.hlsl");
            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.COLOR4));

            m_currentBufferSize = 100000;
            m_VB = MyManagers.Buffers.CreateVertexBuffer(
                "MyLinesRenderer", m_currentBufferSize, sizeof(MyVertexFormatPositionColor),
                usage: ResourceUsage.Dynamic);
        }
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("Transparent/Clouds/Clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("Transparent/Clouds/Clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                                               new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                                               new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("Transparent/Clouds/Clouds.hlsl", new[] { new ShaderMacro("NUMTHREADS", m_numFogThreads) });
        }
        private static void InitInternal(Vector2[] vertsForMask)
        {
            m_VB = MyHwBuffers.CreateVertexBuffer(vertsForMask.Length, MyVertexFormat2DPosition.STRIDE, BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyStereoStencilMask.VB");
            MyMapping mapping = MyMapping.MapDiscard(RC.DeviceContext, m_VB.Buffer);

            mapping.WriteAndPosition(vertsForMask, 0, vertsForMask.Length);
            mapping.Unmap();

            m_vs = MyShaders.CreateVs("stereo_stencil_mask.hlsl");
            m_ps = MyShaders.CreatePs("stereo_stencil_mask.hlsl");

            m_il = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2));
        }
        internal static unsafe void InitSubsystems()
        {
            MyRwTextures.Init();
            MyHwBuffers.Init();
            MyPipelineStates.Init();
            ResetShadows(MyRenderProxy.Settings.ShadowCascadeCount, RenderSettings.ShadowQuality.ShadowCascadeResolution());
            MyRender11.Init();
            MyCommon.Init();
            SamplerStates.Init();
            MyDepthStencilState.Init();
            MyTextures.Init();
            MyVertexLayouts.Init();
            MyShaders.Init();
            MyMeshes.Init();
            MyMeshTableSRV.Init();
            MyLightRendering.Init();
            MyLinesRenderer.Init();
            MySpritesRenderer.Init();
            MyPrimitivesRenderer.Init();
            MyOutline.Init();
            MyBlur.Init();
            MyTransparentRendering.Init();

            MyFoliageComponents.Init();

            MyBillboardRenderer.Init(); // hardcoded limits
            MyDebugRenderer.Init();

            MyScreenDecals.Init();
            MyEnvProbeProcessing.Init();
            MyAtmosphereRenderer.Init();
            MyCloudRenderer.Init();
            MyAAEdgeMarking.Init();
            MyScreenPass.Init();
            MyCopyToRT.Init();
            MyBlendTargets.Init();
            MyFXAA.Init();
            MyDepthResolve.Init();
            MyBloom.Init();
            MyLuminanceAverage.Init();
            MyToneMapping.Init();
            MySSAO.Init();
            MyPlanetBlur.Init();
            MyHdrDebugTools.Init();

            MySceneMaterials.Init();
            MyMaterials1.Init();
            MyVoxelMaterials1.Init();
            MyMeshMaterials1.Init();
        }
Exemple #18
0
        private static void InitInternal(Vector2[] vertsForMask)
        {
            m_VB = MyManagers.Buffers.CreateVertexBuffer(
                "MyStereoStencilMask.VB", vertsForMask.Length, MyVertexFormat2DPosition.STRIDE,
                usage: ResourceUsage.Dynamic);
            MyMapping mapping = MyMapping.MapDiscard(RC, m_VB);

            mapping.WriteAndPosition(vertsForMask, vertsForMask.Length);
            mapping.Unmap();

            m_vs = MyShaders.CreateVs("Stereo/StereoStencilMask.hlsl");
            m_ps = MyShaders.CreatePs("Stereo/StereoStencilMask.hlsl");

            m_il = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2));
        }
        // 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();
        }
Exemple #20
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;

        internal static unsafe void Init()
        {
            m_ps          = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereGBuffer.hlsl");
            m_psPerSample = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereGBuffer.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_psEnv          = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereEnv.hlsl");
            m_psEnvPerSample = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereEnv.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_precomputeDensity = MyShaders.CreateCs("Transparent/Atmosphere/AtmospherePrecompute.hlsl");

            m_proxyVs = MyShaders.CreateVs("Transparent/Atmosphere/AtmosphereVS.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            m_cb = MyManagers.Buffers.CreateConstantBuffer("CommonObjectCB" + sizeof(AtmosphereConstants), sizeof(AtmosphereConstants),
                                                           usage: SharpDX.Direct3D11.ResourceUsage.Dynamic);
        }
Exemple #21
0
        internal unsafe static void Init()
        {
            m_vs = MyShaders.CreateVs("sprite.hlsl");
            m_ps = MyShaders.CreatePs("sprite.hlsl");

            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(
                                                   new MyVertexInputComponent(MyVertexInputComponentType.CUSTOM_HALF4_0, MyVertexInputComponentFreq.PER_INSTANCE),
                                                   new MyVertexInputComponent(MyVertexInputComponentType.CUSTOM_HALF4_1, MyVertexInputComponentFreq.PER_INSTANCE),
                                                   new MyVertexInputComponent(MyVertexInputComponentType.CUSTOM_HALF4_2, MyVertexInputComponentFreq.PER_INSTANCE),
                                                   new MyVertexInputComponent(MyVertexInputComponentType.COLOR4, MyVertexInputComponentFreq.PER_INSTANCE)
                                                   ));

            m_currentBufferSize = 100000;
            m_VB = MyHwBuffers.CreateVertexBuffer(m_currentBufferSize, sizeof(MyVertexFormatSpritePositionTextureRotationColor), BindFlags.VertexBuffer, ResourceUsage.Dynamic);

            m_contextsStack.Add(new MySpritesContext());
        }
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

            DirectionalEnvironmentLight_Pixel  = MyShaders.CreatePs("Lighting/LightDir.hlsl");
            DirectionalEnvironmentLight_Sample = MyShaders.CreatePs("Lighting/LightDir.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            PointlightsTiled_Pixel  = MyShaders.CreatePs("Lighting/LightPoint.hlsl");
            PointlightsTiled_Sample = MyShaders.CreatePs("Lighting/LightPoint.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_preparePointLights = MyShaders.CreateCs("Lighting/PrepareLights.hlsl", new[] { new ShaderMacro("NUMTHREADS", TILE_SIZE) });

            SpotlightProxyVs   = MyShaders.CreateVs("Lighting/LightSpot.hlsl");
            SpotlightPs_Pixel  = MyShaders.CreatePs("Lighting/LightSpot.hlsl");
            SpotlightPs_Sample = MyShaders.CreatePs("Lighting/LightSpot.hlsl", MyRender11.ShaderSampleFrequencyDefine());
            SpotlightProxyIL   = MyShaders.CreateIL(SpotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            m_pointlightCullHwBuffer = MyHwBuffers.CreateStructuredBuffer(MyRender11Constants.MAX_POINT_LIGHTS, sizeof(MyPointlightConstants), true, null, "MyLightRendering");
        }
        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);
        }
        internal static unsafe void Init()
        {
            m_cbCustomProjections = MyManagers.Buffers.CreateConstantBuffer("BilloardCustomProjections", sizeof(Matrix) * MAX_CUSTOM_PROJECTIONS_SIZE, usage: ResourceUsage.Dynamic);

            GeneratePS();
            m_vs    = MyShaders.CreateVs("Transparent/Billboards.hlsl");
            m_vsLit = MyShaders.CreateVs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) });

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

            InitBillboardsIndexBuffer();

            m_VB = MyManagers.Buffers.CreateVertexBuffer("MyBillboardRenderer", MAX_BILLBOARDS_SIZE * 4, sizeof(MyVertexFormatPositionTextureH), usage: ResourceUsage.Dynamic);

            var stride = sizeof(MyBillboardData);

            m_SB = MyManagers.Buffers.CreateSrv(
                "MyBillboardRenderer", MAX_BILLBOARDS_SIZE, stride,
                usage: ResourceUsage.Dynamic);
            m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai");
        }
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                                               new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                                               new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("clouds.hlsl", new [] { new ShaderMacro("NUMTHREADS", m_numFogThreads) });

            SamplerStateDescription description = new SamplerStateDescription
            {
                AddressU   = TextureAddressMode.Wrap,
                AddressV   = TextureAddressMode.Wrap,
                AddressW   = TextureAddressMode.Wrap,
                Filter     = Filter.MinMagMipLinear,
                MaximumLod = System.Single.MaxValue
            };

            m_textureSampler = MyPipelineStates.CreateSamplerState(description);
        }
        internal unsafe static void Init()
        {
            m_vs    = MyShaders.CreateVs("billboard.hlsl");
            m_ps    = MyShaders.CreatePs("billboard.hlsl");
            m_vsLit = MyShaders.CreateVs("billboard.hlsl", new [] { new ShaderMacro("LIT_PARTICLE", null) });
            m_psLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) });

            m_psAlphaCutout       = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null) });
            m_psAlphaCutoutAndLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null) });

            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, null, "MyBillboardRenderer");

            var stride = sizeof(MyBillboardData);

            m_SB    = MyHwBuffers.CreateStructuredBuffer(MaxBillboards, stride, true, null, "MyBillboardRenderer");
            m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai");
        }
Exemple #27
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", "spotlightVs");
            SpotlightPs      = MyShaders.CreatePs("light.hlsl", "spotlightFromProxy");
            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));
        }
Exemple #28
0
        internal unsafe static void Init()
        {
            ResetCascades();

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

            InitIB();

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

                new Vector3D(-1, -1, 1),
                new Vector3D(-1, 1, 1),
                new Vector3D(1, 1, 1),
                new Vector3D(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 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);
        }
Exemple #30
0
        internal static void InitIL(InputLayoutId id)
        {
            var info = InputLayouts.Data[id.Index];

            if (ILObjects[id.Index] != null)
            {
                ILObjects[id.Index].Dispose();
                ILObjects[id.Index] = null;
            }

            ILObjects[id.Index] = new InputLayout(MyRender11.Device, GetBytecode(info.BytecodeId), MyVertexLayouts.GetElements(info.VLayoutId));
        }