[SOLVED] Vertex offset causes some polygons not to render at certain angles (is not Bounds Scale)

Im generating procedural “Pies” for a PieChart plotter. My idea is to procedurally generate the necesary pie slices for the chart once, an then animate their vertex via Shader through vertex offset.

This is the desired effect, without the flicker

310246-pie-anim-optimized2-1.gif

My problem is that the pie appears to be perfectly formed (all tris pointing outwards, as they should), but when applying vertex offset and the mesh is at certain angles some polygons are missing ( for example rot x0y0z0 == missing top & bot caps).

I have checked & rechecked my math and i believe is correct, and it actually renders correctly in some angles.

310247-pie-flicker-angles-optimized2.gif

310248-pie-wireframe-optimized2.gif

I thought it could be due to Bounds scale but it tried pushing it to 100 and still no change.

Two-sided doesnt work either, so i think is not that the polygons get backwards or anything.

this procedural pie is generated by generating 2x 2D Arcs at different heights, then joining them by the sides. Caps and Sides vertex are duplicated because i didnt know how to make split-vertex-normals on ProceduralMeshComponent, so each part (top cap, bot cap, side) is a Section.

This is the shader SHADER PASTEBIN

The material takes the local position for each vertex and deduces its corresponding angle in a unit circle, then lerps that angle towards 0 and recalculates the vertex position. It also corrects the normal orientation to match the offset.

I cant think of anything that could cause this behaviour, if someone could offer some thoughts would be greatly appreciated. Ask me for any extra information, thanks

Just to provide some more information.

I believed the problem might be caused by culling, that’s why i tried to play with BoundsScale. But the culling should happen for the entire object if im correct, so it doesnt make sense that some parts of the same mesh are occluded and some not. Also, playing with boundsScale didnt make a difference, neither did Two-Sided, so it doesnt seem to be culling-related.

So im applying an offset to every vertex. If im messing up, maybe the new positions are making some polygons smash into the same vertex. For example if i happen to apply some much offset to the center vertex, the whole top & bot caps could render pretty badly. But in the shader I apply a mask for the center vertex so i dont make any angle-related changes (its true, at the end i apply some offset, but is not the cause of the problem i can assure it).

Also, if i pipe the offset (in LocalSpace, prior to transform to WorldSpace) to the BaseColor to visualize, i can see that all the values are correct at every angle, and that there is no variance in offset for being at a different position or rotation

310282-pie-local-offset-optimized-20fps.gif

So it doesnt seem to be a miscalculation… im totally lost

This is the same shader, but this time with a static mesh created in 3DsMax, the problem persists, so is not a problem of the procedurally generated mesh. Again, i include also a video with the local offset, you can see its consistent and doesnt randomly change at certain angles. So i dont know but maybe the value of local position (excluding offsets) being received in the vertex shader is wrong??. Because in the pixel shader all appears correct.

What could cause those vertex to cull?

310279-static-mesh-pie.gif

310280-static-mesh-local-offset-2.gif

(Color artifacts are due to gif compression)

If someone cares! Had to move the center vertex by a tiny amount in the procedural mesh. For some reason being at 0,0 creates some infinity somewhere on the shader and brakes it. With this fix just works.

Ended up messing with it and adding waves, here you have it after playing a while xDD see ya

310921-ezgifcom-optimize.gif

2 Likes