0
\$\begingroup\$

Question

Is it possible to make a plane appear as a pyramid with a flat top ? I'm thinking of a vertex shader with a slider for where the "flat top" is. I'm having trouble knowing where to even start so if someone can't point me in the right direction I'll be glad to carry the torch from there.

-- EDIT --

The Unity3D default 10x10 plane primitive is what is being used currently and that is what my current vertex & fragment shader is relying on hence why I'm not trying to deviate too much from that. To try and simplify my issue: think of 4 planes in a 2x2 layout and all the textures SHOULD make one seamless image but the process of cutting these dynamic images (which I don't control) leave the textures either slightly too small or otherwise misaligned so my idea is to enlarge my planes to the point that all 4 planes overlap and to sidestep unwanted texture overlap I want to "bend" all edges of each plane down so that potentially overlapping texture residue becomes hidden behind the fragments closer to the camera. I attempted to create a quick visual for this and while this imagery is not exactly what I'm going for it hopefully conveys the idea.

Before:

four planes in a 2x2

After:

four planes with connecting valleys

How I expect to hide excess texture overlap from the user

four planes with valleys from the side

Related Question

\$\endgroup\$
7
  • \$\begingroup\$ Is it an absolute requirement that this be done with a Plane primitive, or are you amenable to other solutions that let you transition between a flat and pyramidal shape? (I ask because the plane's triangulation will not give the right behaviour on two of the corners out of the box, and there are more efficient solutions available) Can you describe what this is doing in your game and what aspect of the frustum your slider is controlling? A diagram may help. \$\endgroup\$
    – DMGregory
    Commented Feb 21, 2023 at 23:22
  • \$\begingroup\$ @DMGregory Thank you for the clarifying questions. I added an edit to my post to add more insight to my current dilemma. \$\endgroup\$
    – Jacksonkr
    Commented Feb 22, 2023 at 17:18
  • \$\begingroup\$ If you just want to crop the images, rather than reshaping the mesh to get the depth buffer to do it, why not do it in the fragment shader by scaling the UVs or using alpha blending or clip() to drop fragments outside the desired image bounds? This looks like an XY problem, and a better question to ask may be "How to display these 4 images with seamless blending between them?" \$\endgroup\$
    – DMGregory
    Commented Feb 22, 2023 at 17:19
  • \$\begingroup\$ My biggest issue is that the images (pulled from a 3rd party at runtime) have an error margin of ~2% often leaving small gaps between planes. I'm combatting that with ALWAYS enlarging tiles as I think having a misaligned seam is better than having texture looking like it is missing. Essentially I'm having to make the best of a bad situation :( -- lmk if I'm missing your point \$\endgroup\$
    – Jacksonkr
    Commented Feb 22, 2023 at 17:26
  • 1
    \$\begingroup\$ I think you could get a more satisfactory solution by doing shader math within a single plane/quad to do a smooth cross-fade at the margins between tiles, rather than a hard Z-clip, and at the cost of less overdraw too. \$\endgroup\$
    – DMGregory
    Commented Feb 22, 2023 at 17:29

0

You must log in to answer this question.

Browse other questions tagged .