Client - don't draw unnecessary vertices. #99

Open
opened 2015-05-29 16:46:03 -04:00 by UnknownShadow200 · 9 comments
UnknownShadow200 commented 2015-05-29 16:46:03 -04:00 (Migrated from github.com)

Currently, the client renders all vertices of all faces (example here, with all blocks being drawn at half extent to make the overdraw visible):
truecraft1

There are two main ways you can reduce this:
For solid blocks

  1. Add a 'IsSolidFace(Face...' method to BlockProvider. You can skip drawing a face when the face on this block is solid and the corresponding face on the neighbouring block is also solid.
    (There are some corner cases. For example, cactus would only be true for Y positive and Y negative)

For transparent and transluscent blocks, you can do this:
2) Add a 'CanShareWithNeighbours(Face...' method to BlockProvider. You can skip drawing a face when a block and its neighbour are the same type. (e.g. for glass, water)
(Note that water is a bit trickier - for horizontal neighbours, you have to make sure that they have the same height and shape)

Currently, the client renders all vertices of all faces (example here, with all blocks being drawn at half extent to make the overdraw visible): ![truecraft1](https://cloud.githubusercontent.com/assets/6509348/7892224/438bbcfa-0696-11e5-8ca2-1dc7413b1227.png) There are two main ways you can reduce this: For solid blocks 1) Add a 'IsSolidFace(Face...' method to BlockProvider. You can skip drawing a face when the face on this block is solid and the corresponding face on the neighbouring block is also solid. (There are some corner cases. For example, cactus would only be true for Y positive and Y negative) For transparent and transluscent blocks, you can do this: 2) Add a 'CanShareWithNeighbours(Face...' method to BlockProvider. You can skip drawing a face when a block and its neighbour are the same type. (e.g. for glass, water) (Note that water is a bit trickier - for horizontal neighbours, you have to make sure that they have the same height and shape)
ddevault commented 2015-05-29 16:48:21 -04:00 (Migrated from github.com)
  1. Add a 'IsSolidFace(Face...' method to BlockProvider. You can skip drawing a face when the face on this block is solid and the corresponding face on the neighbouring block is also solid.

We already half do this. The chunk renderer only creates meshes for blocks that neighbor transparent blocks. You're suggesting to extend this to even omit faces that do not neighbor transparent blocks? It's a good idea but will be complicated to implement.

  1. Add a 'CanShareWithNeighbours(Face...' method to BlockProvider. You can skip drawing a face when a block and its neighbour are the same type. (e.g. for glass, water)

Yeah, good call.

> 1) Add a 'IsSolidFace(Face...' method to BlockProvider. You can skip drawing a face when the face on this block is solid and the corresponding face on the neighbouring block is also solid. We already half do this. The chunk renderer only creates meshes for blocks that neighbor transparent blocks. You're suggesting to extend this to even omit faces that do not neighbor transparent blocks? It's a good idea but will be complicated to implement. > 2) Add a 'CanShareWithNeighbours(Face...' method to BlockProvider. You can skip drawing a face when a block and its neighbour are the same type. (e.g. for glass, water) Yeah, good call.
UnknownShadow200 commented 2015-05-29 16:53:41 -04:00 (Migrated from github.com)

Maybe I didn't clarify enough. You can see above that the client is drawing the underlying stone and dirt - even when they are all hidden anyways.

Maybe I didn't clarify enough. You can see above that the client is drawing the underlying stone and dirt - even when they are all hidden anyways.
ddevault commented 2015-05-29 16:55:30 -04:00 (Migrated from github.com)

In that screenshot, all of that dirt/stone is surrounded by air blocks and has to be drawn. I'm definitely missing something here.

In that screenshot, all of that dirt/stone is surrounded by air blocks and has to be drawn. I'm definitely missing something here.
UnknownShadow200 commented 2015-05-29 16:56:09 -04:00 (Migrated from github.com)

Sorry I didn't make that clear in the screenshot.
I'd changed the 'CreateUniformCube' mesh size from 0.5 to 0.25 to show that the blocks are being drawn, even though they are normally completely hidden.

Sorry I didn't make that clear in the screenshot. I'd changed the 'CreateUniformCube' mesh size from 0.5 to 0.25 to show that the blocks are being drawn, even though they are normally completely hidden.
ddevault commented 2015-05-29 17:01:41 -04:00 (Migrated from github.com)

Oh, I understand. I thought the actual world had the spaces in it. This is definitely a bug, then. This code is meant to collect a list of coordinates that neighbor transparent blocks, and this code renders only those coordinates. Are you using the most up to date client? If so, then this is definitely a bug.

Oh, I understand. I thought the actual world had the spaces in it. This is definitely a bug, then. [This code](https://github.com/SirCmpwn/TrueCraft/blob/master/TrueCraft.Client/ChunkConverter.cs#L124-L153) is meant to collect a list of coordinates that neighbor transparent blocks, and [this code](https://github.com/SirCmpwn/TrueCraft/blob/master/TrueCraft.Client/ChunkConverter.cs#L154-L186) renders only those coordinates. Are you using the most up to date client? If so, then this is definitely a bug.
ddevault commented 2015-05-29 17:07:16 -04:00 (Migrated from github.com)

Yeah, I've confirmed the bug for myself now. Investigating.

Yeah, I've confirmed the bug for myself now. Investigating.
UnknownShadow200 commented 2015-05-29 17:07:58 -04:00 (Migrated from github.com)
var coords = new Coordinates3D(x, y, z);
var id = chunk.GetBlockId(coords);
var provider = BlockRepository.GetBlockProvider(id);
if (id != 0)
   DrawableCoordinates.Add(coords);

That always adds coordinates for opaque blocks though?

``` var coords = new Coordinates3D(x, y, z); var id = chunk.GetBlockId(coords); var provider = BlockRepository.GetBlockProvider(id); if (id != 0) DrawableCoordinates.Add(coords); ``` That always adds coordinates for opaque blocks though?
ddevault commented 2015-05-29 17:08:31 -04:00 (Migrated from github.com)

Yeah, found and fixed the error. I'll push up a commit shortly.

Yeah, found and fixed the error. I'll push up a commit shortly.
ddevault commented 2015-05-29 18:05:42 -04:00 (Migrated from github.com)

Thanks for pointing out that mistake, @UnknownShadow200, performance is much better with that bug fixed.

Thanks for pointing out that mistake, @UnknownShadow200, performance is much better with that bug fixed.
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: AstralTransRocketries/TrueCraft#99
No description provided.