Exemplo n.º 1
0
        private readonly ConstantsBuffer <float> constants; //alas, lack of root constants

        public CompressToSwap(ContentArchive content, float gamma = 2.2f) : base(
                content.Load <GLSLContent>(@"PostProcessing\CompressToSwap.glvs").Source,
                content.Load <GLSLContent>(@"PostProcessing\CompressToSwap.glfs").Source
                )
        {
            Gamma     = gamma;
            constants = new ConstantsBuffer <float>(BufferTarget.UniformBuffer, debugName: "CompressToSwap Constants");
        }
Exemplo n.º 2
0
 public BackgroundRenderer(Device device, ShaderCache cache)
 {
     vertexShader           = new VertexShader(device, cache.GetShader(@"Background\RenderBackground.hlsl.vshader"));
     vertexShader.DebugName = "BackgroundVS";
     pixelShader            = new PixelShader(device, cache.GetShader(@"Background\RenderBackground.hlsl.pshader"));
     pixelShader.DebugName  = "BackgroundPS";
     constants = new ConstantsBuffer <Matrix>(device, debugName: "BackgroundRenderer Constants");
 }
Exemplo n.º 3
0
 public GlyphRenderer(ContentArchive content, int maximumGlyphsPerDraw = 2048) : base(
         content.Load <GLSLContent>(@"UI\RenderGlyphs.glvs").Source,
         content.Load <GLSLContent>(@"UI\RenderGlyphs.glfs").Source
         )
 {
     instances       = new StructuredBuffer <GlyphInstance>(BufferTarget.ShaderStorageBuffer, maximumGlyphsPerDraw, "Glyph Instances");
     indices         = new IndexBuffer(Helpers.GetQuadIndices(maximumGlyphsPerDraw), "Glyph Indices");
     vertexConstants = new ConstantsBuffer <VertexConstants>(BufferTarget.UniformBuffer, debugName: "Glyph Renderer Vertex Constants");
 }
Exemplo n.º 4
0
 public MeshRenderer(MeshCache meshCache, ContentArchive content, int maximumInstancesPerDraw = 2048) : base(
         content.Load <GLSLContent>(@"ShapeDrawing\RenderMeshes.glvs").Source,
         content.Load <GLSLContent>(@"ShapeDrawing\RenderMeshes.glfs").Source
         )
 {
     this.meshCache  = meshCache;
     instances       = new StructuredBuffer <MeshInstance>(BufferTarget.ShaderStorageBuffer, maximumInstancesPerDraw, $"Mesh Instances");
     vertexConstants = new ConstantsBuffer <RasterizedVertexConstants>(BufferTarget.UniformBuffer, debugName: $"Mesh Renderer Vertex Constants");
 }
Exemplo n.º 5
0
        public MeshRenderer(Device device, MeshCache meshCache, ShaderCache cache, int maximumInstancesPerDraw = 2048)
        {
            this.meshCache = meshCache;
            instances      = new StructuredBuffer <MeshInstance>(device, maximumInstancesPerDraw, $"Mesh Instances");

            vertexConstants = new ConstantsBuffer <RasterizedVertexConstants>(device, debugName: $"Mesh Renderer Vertex Constants");

            vertexShader = new VertexShader(device, cache.GetShader(@"ShapeDrawing\RenderMeshes.hlsl.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader(@"ShapeDrawing\RenderMeshes.hlsl.pshader"));
        }
Exemplo n.º 6
0
        public RasterizedRenderer(ContentArchive content, string shaderPath, int maximumInstancesPerDraw = 2048) : base(
                content.Load <GLSLContent>($"{shaderPath}.glvs").Source,
                content.Load <GLSLContent>($"{shaderPath}.glfs").Source
                )
        {
            string instanceTypeName = typeof(TInstance).Name;

            instances       = new StructuredBuffer <TInstance>(BufferTarget.ShaderStorageBuffer, maximumInstancesPerDraw, $"{instanceTypeName} Instances");
            vertexConstants = new ConstantsBuffer <RasterizedVertexConstants>(BufferTarget.UniformBuffer, debugName: $"{instanceTypeName} Renderer Vertex Constants");
        }
Exemplo n.º 7
0
        public UILineRenderer(Device device, ShaderCache cache, int maximumLinesPerDraw = 2048)
        {
            instances = new StructuredBuffer <UILineInstance>(device, maximumLinesPerDraw, "UI Line Instances");
            indices   = new IndexBuffer(Helpers.GetQuadIndices(maximumLinesPerDraw), device, "UI Line Indices");

            vertexConstants = new ConstantsBuffer <VertexConstants>(device, debugName: "UI Line Renderer Vertex Constants");

            vertexShader = new VertexShader(device, cache.GetShader(@"UI\RenderUILines.hlsl.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader(@"UI\RenderUILines.hlsl.pshader"));
        }
Exemplo n.º 8
0
        public LineRenderer(Device device, ShaderCache cache, int maximumInstancesPerDraw = 16384)
        {
            instances = new StructuredBuffer <LineInstance>(device, maximumInstancesPerDraw, "Line Instances");
            indices   = new IndexBuffer(Helpers.GetBoxIndices(maximumInstancesPerDraw), device, "Line Quad Indices");

            vertexConstants = new ConstantsBuffer <VertexConstants>(device, debugName: "Line Renderer Vertex Constants");

            vertexShader = new VertexShader(device, cache.GetShader(@"Constraints\RenderLines.hlsl.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader(@"Constraints\RenderLines.hlsl.pshader"));
        }
        public RasterizedRenderer(Device device, ShaderCache cache, string shaderPath, int maximumInstancesPerDraw = 2048)
        {
            string instanceTypeName = typeof(TInstance).Name;

            instances = new StructuredBuffer <TInstance>(device, maximumInstancesPerDraw, $"{instanceTypeName} Instances");

            vertexConstants = new ConstantsBuffer <RasterizedVertexConstants>(device, debugName: $"{instanceTypeName} Renderer Vertex Constants");

            vertexShader = new VertexShader(device, cache.GetShader($"{shaderPath}.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader($"{shaderPath}.pshader"));
        }
Exemplo n.º 10
0
        public BoxRenderer(Device device, ShaderCache cache, int maximumInstancesPerDraw = 2048)
        {
            instances = new StructuredBuffer <BoxInstance>(device, maximumInstancesPerDraw, "Box Instances");

            indices = new IndexBuffer(Helpers.GetBoxIndices(maximumInstancesPerDraw), device, $"Box Indices");

            vertexConstants = new ConstantsBuffer <VertexConstants>(device, debugName: $"Box Renderer Vertex Constants");

            vertexShader = new VertexShader(device, cache.GetShader(@"ShapeDrawing\RenderBoxes.hlsl.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader(@"ShapeDrawing\RenderBoxes.hlsl.pshader"));
        }
Exemplo n.º 11
0
        public RayTracedRenderer(ContentArchive content, string shaderPath, int maximumInstancesPerDraw = 2048) : base(
                content.Load <GLSLContent>($"{shaderPath}.glvs").Source,
                content.Load <GLSLContent>($"{shaderPath}.glfs").Source
                )
        {
            var instanceTypeName = typeof(TInstance).Name;

            instances       = new StructuredBuffer <TInstance>(BufferTarget.ShaderStorageBuffer, maximumInstancesPerDraw, $"{instanceTypeName} Instances");
            indices         = new IndexBuffer(Helpers.GetBoxIndices(maximumInstancesPerDraw), $"{instanceTypeName} AABB Indices");
            vertexConstants = new ConstantsBuffer <RayTracedVertexConstants>(BufferTarget.UniformBuffer, debugName: $"{instanceTypeName} Renderer Vertex Constants");
            pixelConstants  = new ConstantsBuffer <RayTracedPixelConstants>(BufferTarget.UniformBuffer, debugName: $"{instanceTypeName} Renderer Pixel Constants");
        }
Exemplo n.º 12
0
        public SphereRenderer(Device device, ShaderCache cache, int maximumInstancesPerDraw = 2048)
        {
            instances = new StructuredBuffer <SphereInstance>(device, maximumInstancesPerDraw, "Sphere Instances");

            indices = new IndexBuffer(Helpers.GetBoxIndices(maximumInstancesPerDraw), device, "Sphere AABB Indices");

            vertexConstants = new ConstantsBuffer <VertexConstants>(device, debugName: "Sphere Renderer Vertex Constants");
            pixelConstants  = new ConstantsBuffer <PixelConstants>(device, debugName: "Sphere Renderer Pixel Constants");

            vertexShader = new VertexShader(device, cache.GetShader(@"Shapes\RenderSpheres.hlsl.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader(@"Shapes\RenderSpheres.hlsl.pshader"));
        }
Exemplo n.º 13
0
        public RayTracedRenderer(Device device, ShaderCache cache, string shaderPath, int maximumInstancesPerDraw = 2048)
        {
            var instanceTypeName = typeof(TInstance).Name;

            instances = new StructuredBuffer <TInstance>(device, maximumInstancesPerDraw, $"{instanceTypeName} Instances");

            indices = new IndexBuffer(Helpers.GetBoxIndices(maximumInstancesPerDraw), device, $"{instanceTypeName} AABB Indices");

            vertexConstants = new ConstantsBuffer <RayTracedVertexConstants>(device, debugName: $"{instanceTypeName} Renderer Vertex Constants");
            pixelConstants  = new ConstantsBuffer <RayTracedPixelConstants>(device, debugName: $"{instanceTypeName} Renderer Pixel Constants");

            vertexShader = new VertexShader(device, cache.GetShader($"{shaderPath}.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader($"{shaderPath}.pshader"));
        }
Exemplo n.º 14
0
        public CompressToSwap(Device device, ShaderCache cache, float gamma = 2.2f)
        {
            Gamma                  = gamma;
            constants              = new ConstantsBuffer <float>(device, debugName: "CompressToSwap Constants");
            vertexShader           = new VertexShader(device, cache.GetShader(@"PostProcessing\CompressToSwap.hlsl.vshader"));
            vertexShader.DebugName = "CompressToSwapVS";
            pixelShader            = new PixelShader(device, cache.GetShader(@"PostProcessing\CompressToSwap.hlsl.pshader"));
            pixelShader.DebugName  = "CompressToSwapPS";
            var depthStateDescription = DepthStencilStateDescription.Default();

            depthStateDescription.DepthWriteMask = DepthWriteMask.Zero;
            depthStateDescription.IsDepthEnabled = false;
            depthState = new DepthStencilState(device, depthStateDescription);
        }
Exemplo n.º 15
0
        public GlyphRenderer(Device device, DeviceContext context, ShaderCache cache, int maximumGlyphsPerDraw = 2048)
        {
            instances = new StructuredBuffer <GlyphInstance>(device, maximumGlyphsPerDraw, "Glyph Instances");
            indices   = new IndexBuffer(Helpers.GetQuadIndices(maximumGlyphsPerDraw), device, "Glyph Indices");

            var samplerDescription = SamplerStateDescription.Default();

            samplerDescription.Filter = Filter.MinMagMipLinear;
            sampler = new SamplerState(device, samplerDescription);

            vertexConstants = new ConstantsBuffer <VertexConstants>(device, debugName: "Glyph Renderer Vertex Constants");

            vertexShader = new VertexShader(device, cache.GetShader(@"UI\RenderGlyphs.hlsl.vshader"));
            pixelShader  = new PixelShader(device, cache.GetShader(@"UI\RenderGlyphs.hlsl.pshader"));
        }