this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add blend state and depth stencil state parameters in constructor, and fix back culling

+23 -10
+1 -1
src/Peridot.Veldrid/Resources/shader.vert
··· 27 27 28 28 gl_Position = item.projection * view * item.model * vec4(Position, 0, 1); 29 29 30 - if(InvertY) 30 + if(!InvertY) 31 31 gl_Position.y = -gl_Position.y; 32 32 33 33 fsin_Color = item.color;
+22 -9
src/Peridot.Veldrid/VeldridSpriteBatch.cs
··· 30 30 /// <param name="outputDescription">The output description of target framebuffer.</param> 31 31 /// <param name="shaders">The shaders to use to render. Uses <seealso cref="LoadDefaultShaders(GraphicsDevice)"/> for default.</param> 32 32 /// <param name="sampler">The samppler used to sample.</param> 33 - public VeldridSpriteBatch(GraphicsDevice device, OutputDescription outputDescription, Shader[] shaders, Sampler? sampler = null) : base() 33 + public VeldridSpriteBatch(GraphicsDevice device, 34 + OutputDescription outputDescription, 35 + Shader[] shaders, 36 + Sampler? sampler = null, 37 + BlendStateDescription? blendState = null, 38 + DepthStencilStateDescription? depthStencil = null) : base() 34 39 { 35 40 _sampler = sampler ?? device.LinearSampler; 36 41 _device = device; 37 42 _vertexBuffer = CreateVertexBuffer(device); 38 43 _resourceLayouts = CreateResourceLayouts(device); 39 - _pipeline = CreatePipeline(device, outputDescription, shaders, _resourceLayouts); 40 44 _buffers = new(); 45 + 46 + var bs = blendState ?? BlendStateDescription.SingleAlphaBlend; 47 + var ds = depthStencil ?? new( 48 + depthTestEnabled: true, 49 + depthWriteEnabled: true, 50 + comparisonKind: ComparisonKind.LessEqual); 51 + _pipeline = CreatePipeline(device, outputDescription, bs, ds, shaders, _resourceLayouts); 41 52 } 42 53 43 54 /// <summary> ··· 152 163 return layouts; 153 164 } 154 165 155 - private static Pipeline CreatePipeline(GraphicsDevice device, OutputDescription outputDescription, Shader[] shaders, params ResourceLayout[] layouts) 166 + private static Pipeline CreatePipeline(GraphicsDevice device, 167 + OutputDescription outputDescription, 168 + BlendStateDescription blendState, 169 + DepthStencilStateDescription depthStencil, 170 + Shader[] shaders, 171 + params ResourceLayout[] layouts) 156 172 { 157 173 var vertexLayout = new VertexLayoutDescription( 158 174 new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2)); 159 175 160 176 var pipelineDescription = new GraphicsPipelineDescription 161 177 { 162 - BlendState = BlendStateDescription.SingleOverrideBlend, 163 - DepthStencilState = new( 164 - depthTestEnabled: true, 165 - depthWriteEnabled: true, 166 - comparisonKind: ComparisonKind.LessEqual), 178 + BlendState = blendState, 179 + DepthStencilState = depthStencil, 167 180 RasterizerState = new( 168 - cullMode: FaceCullMode.Back | FaceCullMode.Front, 181 + cullMode: FaceCullMode.Back, 169 182 fillMode: PolygonFillMode.Solid, 170 183 frontFace: FrontFace.Clockwise, 171 184 depthClipEnabled: false,