I’m creating a custom Spline Extrude script in Unity to generate square spline meshes using Unity’s spline package. I’ve made good progress with flat shading and added rotation offset functionality. However, I’m facing an issue:
Issue:
I want the sides along the spline path to be smooth-shaded (yellow areas in the image below), while keeping the circumference edges flat-shaded to maintain the square look (blue edges). Currently, all sides are flat-shaded in my implementation.
My ultimate goal is to have a Spline Extrude script that is more flexible than Unity’s default, allowing users to select which axes should be shaded flat or smooth.
What I’ve Done So Far (using the default Spline Extrude script as a base):
Implemented flat shading for the mesh.
Added rotation offset functionality.
Any help or direction would be greatly appreciated!
(I have increased the Segments Per Unit value for this image, but this is not a performant solution)
I think this can be done with normals, but I am not familiar enough with mesh generation to find a solution. I don’t think adding a thin quad at the sharp edge and marking it flat is a good solution as I want more flexibility than Unity’s original SplineExtrude script.
When analyzing the normals I found an error in the previous script I posted, the normals should face outwards. I still did not get to manage to achieve smooth shading along the sides.