Ejemplo n.º 1
0
 public ViewThread(WindowState window, GraphicsState graphics, SpatialState spatial, AssetFactoryState assets)
 {
     Window   = window;
     Graphics = graphics;
     Spatial  = spatial;
     Assets   = assets;
 }
Ejemplo n.º 2
0
        public MeshSpatialObject(GraphicsState graphics, SpatialState spatial, AssetFactoryState assets, Mesh mesh,
                                 bool culling)
        {
            Graphics = graphics;
            Spatial  = spatial;
            Mesh     = mesh;
            // TextureLayer = textureLayer;

            VertexBuffer = new ArrayBuffer <Vertex>(graphics, BufferUsage.StructuredBufferReadOnly,
                                                    mesh.Vertices, ShaderStages.Compute);
            WorldVertexBuffer = new ArrayBuffer <Vertex>(graphics, BufferUsage.StructuredBufferReadWrite,
                                                         mesh.Vertices.Length, ShaderStages.Compute | ShaderStages.Vertex);
            ScreenCoordsBuffer = new ArrayBuffer <Vector3D>(graphics, BufferUsage.StructuredBufferReadWrite,
                                                            mesh.Vertices.Length, ShaderStages.Compute | ShaderStages.Vertex);
            ParameterBuffer = new StructBuffer <Parameters>(graphics, BufferUsage.UniformBuffer,
                                                            ShaderStages.Compute);
            // Texture = texture;

            FaceBuffer = new ResourcelessArrayBuffer <Face>(graphics, BufferUsage.VertexBuffer, mesh.Faces);

            TransformPipeline = new ComputePipeline(graphics,
                                                    assets.Get <ShaderSet>("Shaders.MeshSpatialObject.Transform"),
                                                    VertexBuffer, WorldVertexBuffer, ScreenCoordsBuffer, ParameterBuffer);
            ColorPipeline = new GraphicsPipeline(graphics, Blend.Override, DepthTest.On, culling,
                                                 assets.Get <ShaderSet>("Shaders.MeshSpatialObject.Color"), graphics.IntermediateOutputDescription,
                                                 WorldVertexBuffer, ScreenCoordsBuffer);
            Commands = new Commands(graphics);
        }
Ejemplo n.º 3
0
        public ShaderSet(AssetFactoryState assets, RawShaderSet raw)
        {
            var graphics = assets.Graphics;

            Shader?Compile(ShaderStages stage, string?glsl)
            {
                return(glsl == null
                    ? null
                    : graphics.Device.ResourceFactory.CreateShader(new ShaderDescription(stage,
                                                                                         SpirvCompilation.CompileGlslToSpirv(glsl, stage.ToString(), stage,
                                                                                                                             GlslCompileOptions.Default).SpirvBytes, "main")));
            }

            Vertex                 = Compile(ShaderStages.Vertex, raw.Vertex);
            Geometry               = Compile(ShaderStages.Geometry, raw.Geometry);
            TessellationControl    = Compile(ShaderStages.TessellationControl, raw.TessellationControl);
            TessellationEvaluation = Compile(ShaderStages.TessellationEvaluation, raw.TessellationEvaluation);
            Fragment               = Compile(ShaderStages.Fragment, raw.Fragment);
            Compute                = Compile(ShaderStages.Compute, raw.Compute);
            var vertexElements = Vertex == null
                ? new VertexElementDescription[0]
                : VertexInputPattern.Matches(raw.Vertex !).Select(x =>
                                                                  new VertexElementDescription(x.Groups["name"].Value, VertexElementSemantic.Position,
                                                                                               x.Groups["type"].Value switch
            {
                "ivec4" => VertexElementFormat.Int4,
                _ => throw new NotImplementedException()
            }, uint.Parse(x.Groups["offset"].Value)
Ejemplo n.º 4
0
 public LightFont(AssetFactoryState assets, RawLightFont raw)
 {
     RawFont         = raw.FontData;
     PrerenderSize   = raw.PrerenderSize;
     GlyphInfoBuffer = new ArrayBuffer <PrerenderGlyphInfo>(assets.Graphics, BufferUsage.StructuredBufferReadOnly,
                                                            raw.PrerenderGlyphInfos, ShaderStages.Vertex);
     TextureArray = new TextureArray(assets, raw.TextureArray);
 }
Ejemplo n.º 5
0
        public SpatialViewLayer(GraphicsState graphics, SpatialState spatial, AssetFactoryState assets)
        {
            Graphics = graphics;
            Spatial  = spatial;
            Assets   = assets;

            spatial.Objects.Add(new MeshSpatialObject(graphics, spatial, assets,
                                                      assets.Get <SpatialModel>("Characters.Raccoon").Meshes["Body"], true));
        }
Ejemplo n.º 6
0
 public IntermediateFramebuffer(GraphicsState graphics, AssetFactoryState assets, Blend blend,
                                DepthTest depthTest, OutputDescription outputDescription)
 {
     OutputDescription = outputDescription;
     Graphics          = graphics;
     Assets            = assets;
     Blend             = blend;
     DepthTest         = depthTest;
     Validate();
 }
Ejemplo n.º 7
0
        public TextureArray(AssetFactoryState assets, RawTextureArray raw)
        {
            var graphics = assets.Graphics;
            var rf       = graphics.Device.ResourceFactory;

            // hack: limit arrayLayers to a minimum of 2 to prevent veldrid creating a non-array texture2D
            Texture = rf.CreateTexture(new TextureDescription(
                                           (uint)raw.Width, (uint)raw.Height, 1, (uint)raw.MipLevels, Math.Max((uint)raw.Data.Length, 2),
                                           raw.PixelFormat switch
            {
                PixelFormat.A8 => Veldrid.PixelFormat.R8_UNorm,
                PixelFormat.RGBA8888 => Veldrid.PixelFormat.R8_G8_B8_A8_UNorm_SRgb,
                _ => throw new FormatException()
            }, TextureUsage.Sampled | TextureUsage.GenerateMipmaps, TextureType.Texture2D));
Ejemplo n.º 8
0
 public DebugViewLayer(GraphicsState graphics, SpatialState spatial, AssetFactoryState assets)
 {
     Graphics      = graphics;
     Spatial       = spatial;
     Assets        = assets;
     TextViewLayer = new LightTextViewLayer(graphics, assets, 8, 0, 1024, 1024,
                                            assets.Get <LightFont>("Fonts.Light.FiraSansItalic"),
                                            new[]
     {
         new Feature("kern"), new Feature("liga"), new Feature("clig"), new Feature("onum"),
         new Feature("tnum")
     },
                                            24, 24, new RgbaFloat(0, 0, 0, 0.6f), "");
 }
Ejemplo n.º 9
0
 public SpatialModel(AssetFactoryState assets, RawSpatialModel raw)
 {
     Bones  = raw.Bones;
     Meshes = raw.Meshes;
     // TextureArray = new TextureArray(raw.TextureArray);
 }