How to not render unseen objects?

Hey everyone!

I wanted to know how do I go about not rendering the sides of objects that are not seen to save VRAM and RAM. Basically let’s say I build a pyramid of cubes, which I have done just to play around with the engine, but the performance is horrendous even on a relatively beefy system. The pyramid is filled with cubes, and I believe the engine is rendering them even though the player cannot see them. What would I have to implement for the engine to know that an object is not visible so it does not render it? Then how can I make the engine render it when, say, I remove the block in front of it?

Thanks in advance guys



Well you need some kind of intelligent datastructure, I gues you can find tons of stuffs for this if you search for older thread about remake minecraft

Cubes are very simple to cull by cam position. Just set the cullhint to always for all cubes the cam cant see anyway.

Do you have the URL on hand for the remake minecraft thread?

But normen, if the cube comes into view it will stay invisible using your method, correct?

You can scan your 3D matrix and see if a cube is blocked by all 26 sides, and if so, set its CullHint to Always

Just a small note - by culling the cubes you will not save RAM/VRAM, only fragment/vertex processing. If you are seeing huge RAM/VRAM usage for identical cubes, there is probably something else you do wrong.

It was just a form of expression I guess. I don’t see high RAM or VRAM usages, but the FPS is low when I render this pyramid, obviously because of the rendering of the block that aren’t being seen, and the sides of the pyramid that aren’t seen.

Momoko, I’m a novice at this engine, how would I do such a thing, do you have any code examples?

This is not an engine thing, its how you manage your data kind of thing. If you can get all adjacent cubes to a certain cube you can determine if it should be culled or not.

Seems as though that would be kind of intensive, don’t you think?

What is intensive? You only do this when the state changes, not for every cube every frame

Ahhhh, gotcha. I’ll see how I can get this to work. Thanks! :slight_smile:

Are you trying out something like minecraft?

Keep in mind that minecraft does not render every cube, just the ones on the edge to the air. So underground cubes, completely surrounded, are not even generated, let alone rendered.

For managing the data, look into voxels, oct-trees, and occlusion techniques.

I believe there is a thread somewhere on this, just can’t find it.

1 Like

Sploreg, that’s what I’m looking at doing. I wanna figure out how to make the engine not render the cubes that aren’t seen.

You should search “occlusion querry” or “occlusion culling” on google, i think it’s exactly what you need.

No, don’t search for it! The solution I gave should suffice.

You should only need occlusion querying if your world is more complex than a bunch of cubes.

You can also hide cubes that are on the edges of the map and are below the surface, if you do this correctly the only cubes rendered would be the ones on the surface. To further optimize rendering I also recommend using octrees.

I recommand batching the remaining cubes as well