How to chamfer edges with shaders


I would like to know how to chamfer edges of mesh using shaders.

I know it could be done when i saw this person does it.…mal-map#latest

I’ve sent him messages but he doesn’t reply, if someone know how to do the same i will be very grateful.

Base on what he/she mentioned it should not be hard in theory, but i really don’t have any past experience with shaders, i would like any help.

I would like to bevel cube and cylinder edges

Many Thanks

Does anyone knows about this?
i really need it and i would appreciate any help.

The reason this is difficult is that generally, a bevel effect requires access to normals and edges outside of the current pixel which generally can’t be read directly from a material.

That said, since the shape of spheres and cylinders are known in advance, it is possible to make something along these lines, although it doesn’t seem like it would be a great approach.

This isn’t a complete solution, but here’s a quick example of beveling the corners of a cube by constraining vertices to a specific radius (i.e. a sphere). There are some unfortunate limitations to doing it this way, though, such as the fact that tessellation needs to be enabled to allow new vertices/edges to be created.

Is there a reason this needs to happen in a material specifically? This seems like the most roundabout way of achieving this effect.

I really Apperiate you taking your time to answer my question.

why i want to implement the bevel this way is because i have a archvis 3d model that i want my users to be able to change the bevel at runtime.
i thought it would be much more time efficient if i could implement it using this way instead of manually making beveled meshes for my items then morph between them when user wants to bevel

Unfortunately, I think doing this in a material is challenging partly for the same reason as beveling in a modeling package before import: additional geometry needs to be created. I think that the easiest solution in this case is probably to automate the process of beveling and generating morph targets in advance in whatever modeling package is being used, rather than adding bevels afterwards in the engine itself. It almost certainly won’t be as messy as an attempt to do this all inside of an Unreal material, and it will probably give a better result as well.