Theodore Enderby

  • Content count

  • Joined

  • Last visited

Community Reputation

139 Neutral

About Theodore Enderby

  • Rank
  1. How to draw lots of billboard sprites

    Wow your billboarding matrix works great. Way simpler than my attempts. Could you explain more about your "inferred 3 layered shading" and "OIT", I'm unfamiliar with these and I am having trouble finding docs on it.
  2. How to draw lots of billboard sprites

    Hey so I've successfully implemented instancing for my sprites and I can draw a ton of them, thank you. Now I've got to figure out how to put back in billboarding and the alpha test.   In my effects file I can probably using the view and projection matrices to make the sprite face the camera, correct? As for how to do the multipass aplha test I was using I have no idea. So back google.   If anyone has any tips I'd be happy to hear them.
  3. How to draw lots of billboard sprites

    Oh looks good I'll try this out soon. Thanks.
  4. Howdy first post! So I have all these "gameSprites" that contain "BillboardSprites". They are pngs that are chopped up and billboarded to be in 3D space. I'm using them as characters and other things and I'd like to be able to draw a ton of them. (video of game before adding a lot more sprites!) They are drawn in there own buffers whith their own indices and vertices arrays. This is very slow and reading suggests that the graphics card would prefer if I told it about all the gamesprites in one buffer instead. I can add all their vertices and indices together, and draw them all I'd imagine. But they are also drawn with an effect file, and that is passed its world matrix(Scale and position etc), plus the billboarding effect and textures. So how would I keep my ability to individually change scaling,positioning,texture and other things in each gamesprite while still being able to draw all of them in one batch? I'm new so I don't know if my understanding of xna is that great but this is where I'm at! If someone could just give me some ideas or theories or examples that would be great.   public void Draw(GraphicsDevice graphics, Camera camera) { setVertexBuffer(graphics); //Gets texture from sprite sheet for animation. StopAtCurrentFrame(graphics); //set previous states RasterizerState prevRasterizerState = graphics.RasterizerState; BlendState prevBlendState = graphics.BlendState; Matrix billboardMatrix = Matrix.CreateConstrainedBillboard(WorldMatrix.Translation, camera.Position, Vector3.Up, camera.Forward, Vector3.UnitZ); Matrix ScalePositionFix = Matrix.CreateTranslation(Position * -scale); Matrix YFix = Matrix.CreateTranslation(new Vector3(0, (HEIGHT / WIDTH) * 2, 0)); Matrix AppliedWorldMatrix = WorldMatrix * ScalePositionFix * YFix; //First Pass: //Render the non-transparent pixels of the billboards and store their depths billBoardEffect.Parameters["world"].SetValue(billboardMatrix * AppliedWorldMatrix); billBoardEffect.Parameters["view"].SetValue(camera.View); billBoardEffect.Parameters["projection"].SetValue(camera.Projection); billBoardEffect.Parameters["billboardSize"].SetValue(0); billBoardEffect.Parameters["alphaTestDirection"].SetValue(1); billBoardEffect.Parameters["colorMap"].SetValue(texture); graphics.BlendState = BlendState.Opaque; graphics.DepthStencilState = DepthStencilState.Default; graphics.RasterizerState = RasterizerState.CullNone; foreach (EffectPass pass in billBoardEffect.CurrentTechnique.Passes) { pass.Apply(); graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexBuffer.VertexCount, 0, (int)(vertexBuffer.VertexCount * 0.5f)); } graphics.Indices = null; graphics.SetVertexBuffer(null); //Second pass billBoardEffect.Parameters["alphaTestDirection"].SetValue(-1.0f); graphics.BlendState = BlendState.NonPremultiplied; graphics.DepthStencilState = DepthStencilState.DepthRead; //graphics.SamplerStates[0] = SamplerState.PointWrap; setVertexBuffer(graphics); foreach (EffectPass pass in billBoardEffect.CurrentTechnique.Passes) { pass.Apply(); graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexBuffer.VertexCount, 0, (int)(vertexBuffer.VertexCount * 0.5f)); } graphics.SetVertexBuffer(null); graphics.Indices = null; //set previous states graphics.BlendState = prevBlendState; graphics.RasterizerState = prevRasterizerState; setBounds();   Here's my draw for the GameSprite code, excuse the mess, still new: