コード例 #1
0
        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_depthShader = MyShaders.CreatePs("debug_Depth.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, null, "MyDebugRenderer quad");
        }
コード例 #2
0
        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_LODShader = MyShaders.CreatePs("Debug/DebugLOD.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 = MyManagers.Buffers.CreateVertexBuffer(
                "MyDebugRenderer quad", 6, MyVertexFormatPosition2Texcoord.STRIDE,
                usage: ResourceUsage.Dynamic);
        }
コード例 #3
0
        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
			m_baseColorShader = MyShaders.CreatePs("debug.hlsl", "base_color");
            m_baseColorLinearShader = MyShaders.CreatePs("debug.hlsl", "base_color_linear");
            m_normalShader = MyShaders.CreatePs("debug.hlsl", "normal");
            m_glossinessShader = MyShaders.CreatePs("debug.hlsl", "glossiness");
            m_metalnessShader = MyShaders.CreatePs("debug.hlsl", "metalness");
            m_matIDShader = MyShaders.CreatePs("debug.hlsl", "mat_id");
            m_aoShader = MyShaders.CreatePs("debug.hlsl", "ambient_occlusion");
            m_emissiveShader = MyShaders.CreatePs("debug.hlsl", "emissive");
            m_ambientDiffuseShader = MyShaders.CreatePs("debug.hlsl", "debug_ambient_diffuse");
            m_ambientSpecularShader = MyShaders.CreatePs("debug.hlsl", "debug_ambient_specular");
            m_edgeDebugShader = MyShaders.CreatePs("debug.hlsl", "debug_edge");
			m_shadowsDebugShader = MyShaders.CreatePs("debug.hlsl", "cascades_shadow", MyRender11.ShaderCascadesNumberHeader());
            m_NDotLShader = MyShaders.CreatePs("debug.hlsl", "NDotL");


            m_screenVertexShader = MyShaders.CreateVs("debug.hlsl", "screenVertex");
            m_blitTextureShader = MyShaders.CreatePs("debug.hlsl", "blitTexture");
            m_blitTexture3DShader = MyShaders.CreatePs("debug.hlsl", "blitTexture3D");
            m_blitTextureArrayShader = MyShaders.CreatePs("debug.hlsl", "blitTextureArray");
            m_inputLayout = MyShaders.CreateIL(m_screenVertexShader.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2, MyVertexInputComponentType.TEXCOORD0));

            m_quadBuffer = MyHwBuffers.CreateVertexBuffer(6, MyVertexFormatPosition2Texcoord.STRIDE, BindFlags.VertexBuffer, ResourceUsage.Dynamic);
        }
コード例 #4
0
ファイル: MyScreenPass.cs プロジェクト: 2asoft/SpaceEngineers
        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));

        }
コード例 #5
0
        //internal static void CreateInputLayout(byte[] bytecode)
        //{
        //    m_inputLayout = MyVertexInputLayout.CreateLayout(MyVertexInputLayout.Empty().Append(MyVertexInputComponentType.POSITION3).Append(MyVertexInputComponentType.COLOR4), bytecode);
        //}

        internal unsafe static void Init()
        {
            m_currentBufferSize = 100000;

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

            m_vs = MyShaders.CreateVs("primitive.hlsl", "vs");
            m_ps = MyShaders.CreatePs("primitive.hlsl", "ps");
            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.COLOR4));
        }
コード例 #6
0
        internal static void Init()
        {
            m_vs = MyShaders.CreateVs("decal.hlsl");
            var normalMapMacro = new ShaderMacro("USE_NORMALMAP_DECAL", null);
            var colorMapMacro = new ShaderMacro("USE_COLORMAP_DECAL", null);
            m_psColorMap = MyShaders.CreatePs("decal.hlsl", new ShaderMacro[] { colorMapMacro, new ShaderMacro("USE_DUAL_SOURCE_BLENDING", null) });
            m_psNormalMap = MyShaders.CreatePs("decal.hlsl", new ShaderMacro[] { normalMapMacro });
            m_psNormalColorMap = MyShaders.CreatePs("decal.hlsl", new ShaderMacro[] { normalMapMacro, colorMapMacro });

            InitIB();
        }
コード例 #7
0
        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, m_VB.Buffer);
            mapping.WriteAndPosition(vertsForMask, 0, 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));
        }
コード例 #8
0
ファイル: MyClouds.cs プロジェクト: 2asoft/SpaceEngineers
        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) });
        }
コード例 #9
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();
        }
コード例 #10
0
        unsafe void IManagerDevice.OnDeviceInit()
        {
            if (m_markerConstantBuffer == ConstantsBufferId.NULL)
                m_markerConstantBuffer = MyHwBuffers.CreateConstantsBuffer(sizeof(MyMarkerConstants), "MyPostprocessMarkCascades.MarkerConstantBuffer");

            if (m_psMarker == PixelShaderId.NULL)
                m_psMarker = MyShaders.CreatePs("Shadows\\StencilMarker.hlsl");
            if (m_vsMarker == VertexShaderId.NULL)
                m_vsMarker = MyShaders.CreateVs("Shadows\\StencilMarker.hlsl");
            if (m_psDrawCoverage == PixelShaderId.NULL)
                m_psDrawCoverage = MyShaders.CreatePs("Shadows\\CascadeCoverage.hlsl");
            if (m_inputLayout == InputLayoutId.NULL)
                m_inputLayout = MyShaders.CreateIL(m_vsMarker.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));

            m_vertexBuffer = CreateVertexBuffer();
            m_indexBuffer = CreateIndexBuffer();
        }
コード例 #11
0
        internal unsafe static void Init()
        {
            m_vs = MyShaders.CreateVs("sprite.hlsl", "vs");
            m_ps = MyShaders.CreatePs("sprite.hlsl", "ps");

            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());
        }
コード例 #12
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_threadGroupCountX = 32;
            m_threadGroupCountY = 32;
            Vector2I pixelCount = MyRender11.ViewportResolution;
            Vector2I threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);

            int tryIndex = 0;
            while(threadsPerThreadGroup.X*threadsPerThreadGroup.Y > 1024)   // Make sure we do are not over the limit of threads per thread group
            {
                if (tryIndex++ % 2 == 0)
                    ++m_threadGroupCountX;
                else
                    ++m_threadGroupCountY;

                threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);
            }

            int pixelsCoveredX = threadsPerThreadGroup.X * m_pixelsPerThreadX * m_threadGroupCountX;
            if (pixelsCoveredX < pixelCount.X)
                ++m_threadGroupCountX;
            int pixelsCoveredY = threadsPerThreadGroup.Y * m_pixelsPerThreadY * m_threadGroupCountY;
            if (pixelsCoveredY < pixelCount.Y)
                ++m_threadGroupCountY;

            m_gatherCS = MyShaders.CreateCs("shadows.hlsl", new [] {
                new ShaderMacro("NUMTHREADS_X", threadsPerThreadGroup.X),
                new ShaderMacro("NUMTHREADS_Y", threadsPerThreadGroup.Y),
                new ShaderMacro("THREAD_GROUPS_X", m_threadGroupCountX),
                new ShaderMacro("THREAD_GROUPS_Y", m_threadGroupCountY),
                new ShaderMacro("PIXELS_PER_THREAD_X", m_pixelsPerThreadX),
                new ShaderMacro("PIXELS_PER_THREAD_Y", m_pixelsPerThreadY)});
        }
コード例 #13
0
        private void InitShaders()
        {
            if (m_markVS == VertexShaderId.NULL)
                m_markVS = MyShaders.CreateVs("ShadowsOld/Shape.hlsl");

            if (m_markPS == PixelShaderId.NULL)
                m_markPS = MyShaders.CreatePs("ShadowsOld/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("ShadowsOld/CombineShadows.hlsl");

            m_gatherCS_LD = MyShaders.CreateCs("ShadowsOld/Shadows.hlsl");
            m_gatherCS_MD = MyShaders.CreateCs("ShadowsOld/Shadows.hlsl", new[] { new ShaderMacro("ENABLE_PCF", null) });
            m_gatherCS_HD = MyShaders.CreateCs("ShadowsOld/Shadows.hlsl", new[] { new ShaderMacro("ENABLE_PCF", null), new ShaderMacro("ENABLE_DISTORTION", null) });
        }
コード例 #14
0
        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");
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        internal static void DrawQuad(float x, float y, float w, float h, VertexShaderId? customVertexShader = null)
        {
            //RC.Context.PixelShader.Set(m_blitTextureShader);

            VertexShaderId usedVertexShader;
            if (!customVertexShader.HasValue)
                usedVertexShader = m_screenVertexShader;
            else
                usedVertexShader = customVertexShader.Value;

            RC.DeviceContext.VertexShader.Set(usedVertexShader);
            RC.DeviceContext.InputAssembler.InputLayout = m_inputLayout;

            var mapping = MyMapping.MapDiscard(m_quadBuffer.Buffer);
            var tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y), new Vector2(0, 0));
            mapping.WriteAndPosition(ref tmpFormat);

            tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y + h), new Vector2(1, 1));
            mapping.WriteAndPosition(ref tmpFormat);

            tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y + h), new Vector2(0, 1));
            mapping.WriteAndPosition(ref tmpFormat);

            tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y), new Vector2(0, 0));
            mapping.WriteAndPosition(ref tmpFormat);

            tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y), new Vector2(1, 0));
            mapping.WriteAndPosition(ref tmpFormat);

            tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y + h), new Vector2(1, 1));
            mapping.WriteAndPosition(ref tmpFormat);

            mapping.Unmap();

            RC.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            RC.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(m_quadBuffer.Buffer, m_quadBuffer.Stride, 0));
            RC.DeviceContext.Draw(6, 0);
        }
コード例 #17
0
ファイル: MyClouds.cs プロジェクト: Chrus/SpaceEngineers
        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);
        }
コード例 #18
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));
        }
コード例 #19
0
        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");
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_baseColorShader       = MyShaders.CreatePs("debug.hlsl", "base_color");
            m_baseColorLinearShader = MyShaders.CreatePs("debug.hlsl", "base_color_linear");
            m_normalShader          = MyShaders.CreatePs("debug.hlsl", "normal");
            m_glossinessShader      = MyShaders.CreatePs("debug.hlsl", "glossiness");
            m_metalnessShader       = MyShaders.CreatePs("debug.hlsl", "metalness");
            m_matIDShader           = MyShaders.CreatePs("debug.hlsl", "mat_id");
            m_aoShader              = MyShaders.CreatePs("debug.hlsl", "ambient_occlusion");
            m_emissiveShader        = MyShaders.CreatePs("debug.hlsl", "emissive");
            m_ambientDiffuseShader  = MyShaders.CreatePs("debug.hlsl", "debug_ambient_diffuse");
            m_ambientSpecularShader = MyShaders.CreatePs("debug.hlsl", "debug_ambient_specular");
            m_edgeDebugShader       = MyShaders.CreatePs("debug.hlsl", "debug_edge");
            m_shadowsDebugShader    = MyShaders.CreatePs("debug.hlsl", "cascades_shadow");


            m_screenVertexShader = MyShaders.CreateVs("debug.hlsl", "screenVertex");
            m_blitTextureShader  = MyShaders.CreatePs("debug.hlsl", "blitTexture");
            m_inputLayout        = MyShaders.CreateIL(m_screenVertexShader.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2, MyVertexInputComponentType.TEXCOORD0));

            m_quadBuffer = MyHwBuffers.CreateVertexBuffer(6, MyVertexFormatPosition2Texcoord.STRIDE, BindFlags.VertexBuffer, ResourceUsage.Dynamic);
        }
コード例 #22
0
ファイル: MyShadows.cs プロジェクト: warex0/SpaceEngineers
        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));
        }
コード例 #23
0
        internal static void InitVs(VertexShaderId id, string file)
        {
            var bytecodeId = VertexShaders.Data[id.Index].Bytecode;

            Compile(bytecodeId);

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

            try
            {
                VsObjects[id.Index] = new VertexShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
            catch (SharpDXException e)
            {
                Compile(bytecodeId, true);
                VsObjects[id.Index] = new VertexShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
            VertexShaders.Data[id.Index].File = file;
            VsObjects[id.Index].DebugName     = file;
        }
コード例 #24
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));
        }
コード例 #25
0
 internal static void Init()
 {
     m_fullscreenQuadVS = MyShaders.CreateVs("postprocess_copy.hlsl");
 }
コード例 #26
0
 internal static VertexShader GetVs(VertexShaderId id)
 {
     return(VsObjects[id.Index]);
 }
コード例 #27
0
ファイル: MyAtmosphere.cs プロジェクト: rem02/SpaceEngineers
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;

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

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

            m_proxyVs = MyShaders.CreateVs("Transparent/Atmosphere/Atmosphere.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));
        }
コード例 #28
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);
        }
コード例 #29
0
ファイル: MyScreenPass.cs プロジェクト: fluxit/SpaceEngineers
 internal static void Init()
 {
     m_fullscreenQuadVS = MyShaders.CreateVs("postprocess.hlsl", "fullscreen");
 }
コード例 #30
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_threadGroupCountX = 32;
            m_threadGroupCountY = 32;
            Vector2I pixelCount            = MyRender11.ViewportResolution;
            Vector2I threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);

            int tryIndex = 0;

            while (threadsPerThreadGroup.X * threadsPerThreadGroup.Y > 1024)   // Make sure we do are not over the limit of threads per thread group
            {
                if (tryIndex++ % 2 == 0)
                {
                    ++m_threadGroupCountX;
                }
                else
                {
                    ++m_threadGroupCountY;
                }

                threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);
            }

            int pixelsCoveredX = threadsPerThreadGroup.X * m_pixelsPerThreadX * m_threadGroupCountX;

            if (pixelsCoveredX < pixelCount.X)
            {
                ++m_threadGroupCountX;
            }
            int pixelsCoveredY = threadsPerThreadGroup.Y * m_pixelsPerThreadY * m_threadGroupCountY;

            if (pixelsCoveredY < pixelCount.Y)
            {
                ++m_threadGroupCountY;
            }

            m_gatherCS = MyShaders.CreateCs("shadows.hlsl", new [] {
                new ShaderMacro("NUMTHREADS_X", threadsPerThreadGroup.X),
                new ShaderMacro("NUMTHREADS_Y", threadsPerThreadGroup.Y),
                new ShaderMacro("THREAD_GROUPS_X", m_threadGroupCountX),
                new ShaderMacro("THREAD_GROUPS_Y", m_threadGroupCountY),
                new ShaderMacro("PIXELS_PER_THREAD_X", m_pixelsPerThreadX),
                new ShaderMacro("PIXELS_PER_THREAD_Y", m_pixelsPerThreadY)
            });
        }
コード例 #31
0
        internal static void InitVs(VertexShaderId id)
        {
            var bytecodeId = VertexShaders.Data[id.Index].Bytecode;
            Compile(bytecodeId);

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

            try
            {
                VsObjects[id.Index] = new VertexShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
            catch(SharpDXException e)
            {
                Compile(bytecodeId, true);
                VsObjects[id.Index] = new VertexShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
        }
コード例 #32
0
        internal static void OnDeviceEnd()
        {
            DoneDevice();

            m_ps = PixelShaderId.NULL;
            m_psOIT = PixelShaderId.NULL;
            m_vs = VertexShaderId.NULL;

            m_csSimulate = ComputeShaderId.NULL;

            m_csResetParticles = ComputeShaderId.NULL;
            m_csInitDeadList = ComputeShaderId.NULL;
            m_csEmit = ComputeShaderId.NULL;
            m_csEmitSkipFix = ComputeShaderId.NULL;

            m_resetSystem = true;
        }
コード例 #33
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();
        }
コード例 #34
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_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));
        }
コード例 #35
0
        //internal static void CreateInputLayout(byte[] bytecode)
        //{
        //    m_inputLayout = MyVertexInputLayout.CreateLayout(MyVertexInputLayout.Empty().Append(MyVertexInputComponentType.POSITION3).Append(MyVertexInputComponentType.COLOR4), bytecode);
        //}

        internal unsafe static void Init()
        {
            m_currentBufferSize = 100000;

            m_VB = MyManagers.Buffers.CreateVertexBuffer(
                "MyPrimitivesRenderer", m_currentBufferSize, sizeof(MyVertexFormatPositionColor), 
                usage: ResourceUsage.Dynamic);

            m_vs = MyShaders.CreateVs("Primitives/Primitives.hlsl");
            m_ps = MyShaders.CreatePs("Primitives/Primitives.hlsl");
            m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.COLOR4));
        }
コード例 #36
0
 internal static VertexShader GetVs(VertexShaderId id)
 {
     return VsObjects[id.Index];
 }
コード例 #37
0
ファイル: MyShaders.cs プロジェクト: liiir1985/SpaceEngineers
        internal static VertexShaderId CreateVs(string file, ShaderMacro[] macros = null)
        {
            var bytecode = CreateBytecode();

            var id = new VertexShaderId { Index = VertexShaders.Allocate() };
            VertexShaders.Data[id.Index] = new MyShaderInfo
            {
                Bytecode = bytecode
            };
            MyArrayHelpers.Reserve(ref VsObjects, id.Index + 1);

            // compile at once

            Shaders[bytecode] = new MyShaderCompilationInfo
            {
                File = X.TEXT_(file),
                Profile = MyShadersDefines.Profiles.vs_5_0,
                Macros = macros
            };

            VsObjects[id.Index] = null;

            InitVs(id, file);
            VsIndex.Add(id);

            return id;
        }
コード例 #38
0
        internal static VertexShaderId CreateVs(string file, string func, string header = "")
        {
            var bytecode = CreateBytecode();

            var id = new VertexShaderId { Index = VertexShaders.Allocate() };
            VertexShaders.Data[id.Index] = new MyShaderInfo
            {
                Bytecode = bytecode
            };
            MyArrayHelpers.Reserve(ref VsObjects, id.Index + 1);

            // compile at once

            Shaders[bytecode] = new MyShaderCompilationInfo
            {
                File = MyStringId.GetOrCompute(file),
                Function = MyStringId.GetOrCompute(func),
                Profile = MyShaderProfileEnum.VS_5_0,
                Header = header,
                Name = String.Format("vs_[{0}][{1}]{2}", file, func, header != null ? header.Replace(Environment.NewLine, "_") : "")
            };

            VsObjects[id.Index] = null;

            InitVs(id);
            VsIndex.Add(id);

            return id;
        }
コード例 #39
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));
 }