Unity3D, around the edges of the box, cube?

What is the usual way to round the edges on a cube, a rectangular object, as in the examples?

enter image description hereenter image description here

An ideal result will look something like these images.

(Naturally, you could literally use a mesh with carefully rounded edges and corners, but it takes a lot of tris to achieve this.)


Pay attention, of course, to the NON- shader approach ...

enter image description here

Add two small flat drawers and just make this new normal halfway, i.e. 45 degrees, between the two sides:

enter image description here

That would be perfect ...

The GDG below provided an article in which someone claims that this is indeed the best way if you do not use the shader approach.

I'm really curious how to do this with a shader .


Note - an incredibly detailed guide to a non-shader approach

http://catlikecoding.com/unity/tutorials/rounded-cube/

+6
source share
3 answers

Using deferred shading, you can access the G-buffer to find and round borders, as done in this article . Although it is a post-processing method, it is therefore capable of emulating roundness within some pixels.

enter image description here

Simple averaged normals (1 pixel wide):

enter image description here

Simple averaged normals (2 pixels wide):

enter image description here

Simple averaged normals (3 pixels wide):

enter image description here

+3
source

Of course, I would prefer a shader-oriented answer, but especially if the necessary shaders are not available on this platform, I would achieve this with a few β€œlevel of detail” models like LoD.

  • Give a GameObject for this grid object for a 6-sided rectangle, a slightly curved rectangle, and a very close curved rectangle. ( http://www.wings3d.com/ this is my simple modeling tool)
  • Give GameObject a behavior script that checks each frame for a distance from the camera.

  • Activate the appropriate grid based on distance and deactivate the rest, this should be done at a distance when the change is not detected at the highest resolution available to the player.

This technique is pretty widely used in 3D games, and it's a good way to imagine distant clusters of things that can become much more detailed when the camera zooms in.

+1
source

We were able to complete beveled cubes for our WorldToBuild game. The key is that you can really make a beveled model and then just move the vertices in groups.

In short, all I needed to do to achieve the effect was:

  • Create a beveled cube (I used Blender).
  • Find the vertices that you are going to move in each direction, according to their position from the center.
  • Calculate the beveled edges and set the exact size.

I wrote an article about it here. Scroll to the end of the article if you just want to know the process:

https://www.linkedin.com/pulse/coding-resizable-beveled-cubes-unity-richard-christley

0
source

Source: https://habr.com/ru/post/973222/


All Articles