#Generated greedy mesh improper behaviour

74 messages · Page 1 of 1 (latest)

umbral wigeon
#

See attached image. Faces rendered are wrong.
I also randomly get a message like the following (which is coming from rapier, probably while generating the collider):

thread 'Compute Task Pool (3)' panicked at 'index out of bounds: the len is 512836 but the index is 512840', /Users/visual/.cargo/registry/src/github.com-1ecc6299db9ec823/parry3d-0.10.0/src/shape/trimesh.rs:502:17

Code is here: https://github.com/ChefKissInc/CaveGame/blob/master/src/plugins/terrain/world.rs

high stone
#

I think this happens when the AlphaMode is set to Blend. Try Opaque

umbral wigeon
#

the faces are drawing the wrong way

#

it's supposed to be cubes

high stone
#

Oh, you're right 😅
It looked very similar to a different bug :v

modest coyote
#

You might be able to reverse your triangle indices and it'll work correctly.

#

Winding order is important

umbral wigeon
#

see the big get_voxel_data_for function

umbral wigeon
#

(there's probably a lot of flaws with this code)

wicked verge
umbral wigeon
#

not 50% of the cube side is not visible

#

or triangles flipped

wicked verge
#

Yea some traingles seem to be winded differently from others

#

The bottom is flipped but left/right is correct

#

Back/front seems to also be flipped

umbral wigeon
wicked verge
#

Ok can you post a image what it looks like now?

umbral wigeon
#

here you go

wicked verge
#

Still seems the sides are flipped

umbral wigeon
#

is this not what you meant

wicked verge
#

Are you using a custom shader?

umbral wigeon
#

no custom shader

wicked verge
#

The lighting seems off too but IDK

umbral wigeon
#

i have ambient lighting

wicked verge
umbral wigeon
wicked verge
#

If you add a direcitonal light the normals will be easier to see

umbral wigeon
wicked verge
#

Winding order = order of verticies

umbral wigeon
#

if i switch the .filter(...) to always return true, it displays fine

wicked verge
#

Oh that might be voxel code then

#

My bad it looks just like a winding issue

umbral wigeon
#

i copied the vertices, normals, and uvs from bevy's cube shape

#

the sides were commented like in my code, and i assumed that by front, back, etc, they meant in the actual axis

wicked verge
#

Is there a way for you to color the sides depending on what cube they are from? So it's easier to see if you are filtering the wrong cubes of positioning the faces of each cube incorrectly?

umbral wigeon
#

oh, there is actually another code bug

#

i wasn't skipping drawing air blocks

#

here it is now

umbral wigeon
wicked verge
umbral wigeon
wicked verge
#

Can you send a piture more zoomed in one one of the blocks please?

umbral wigeon
#

sure

umbral wigeon
#

and this

wicked verge
#

So I'm looking at your code and not seeing any obvious issues, though I'm not looking very closely

#

What's odd is the right faces seem to work very consistently

#

But the others all sometimes appear correct and sometimes not

#

In the top screnshot the front faces seem ok on the left half of the screen but missing completely on the right

umbral wigeon
#

i'm like extremely new to all this stuff; rendering and the vertices, triangles, the coordinate system, bevy itself, etc so i am clueless

wicked verge
#

So I'm unfortunalty not sure what the issue is, but if I where you I'd reduce your scene to be very small, maybe 2x2x2. Then instead of random generation manually try some combinations of faces to see if you can find a pattern what works and what not

umbral wigeon
#

i do not understand

wicked verge
#

Like right now you are trying a huge map. I know the faces are in the wrong place but I don't know where they are supposed to be. If you use a tiny map, as small as you can, like 2 by 2 by 2 or 3 by 3 by 3 cells it will be much easier to see

wicked verge
#

Also you can use a debugger or print the values. See which ones are not what you expect

umbral wigeon
#

i don't know what i am expecting in values

#

i think there is some kind of relation between the vertices and the world's positions

#

that i am not getting

umbral wigeon
#

the top is actually the front

#

why'd bevy mislabel the data

#

@wicked verge there we go

#

Top/Bottom was actually Front/Back and Front/Back was actually Top/Bottom

#

thanks for getting me into thinking more through the code

#

i have one minor issue though, if i set the chunk width/height to 64 i get a "bus error" and from macos "application exited unexpectedly" for some reason
but this doesn't seem related

#

thread 'Compute Task Pool (0)' has overflowed its stack
fatal runtime error: stack overflow
[1] 83810 abort cargo run
interesting
EDIT: nvm, fixed by using a Vec<Vec<Vec<>>> instead of nested arrays

wicked verge
#

Nice

wicked verge
#

it's a unfortunate rust limiation

pseudo night