Jump to content

Support for rendering color gradients on mesh and/or slice preview


Recommended Posts

Posted · Support for rendering color gradients on mesh and/or slice preview

I noticed that Cura supports different colors for mesh and slice views, but I don't see any instance of rendering with color gradient. This is typically achieved by specifying color (or some value) at the vertices and the render interpolates the color inside the triangle (in mesh view) or the gcode line (in the slice view). Is anyone aware that Cura supports this or if it's in the cards. Thanks!

  • Link to post
    Share on other sites

    • 2 months later...
    Posted (edited) · Support for rendering color gradients on mesh and/or slice preview

    Hey, late reply but good news. What you want to do is exactly how Cura works behind the scenes. When adding a triangle (or quad, or line...), Cura uses setVertexColor() on each of its 3 vertices, but uses the same color so there's no gradient.

     

    What you can do is first create your mesh with your primitives, and afterwards go vertex by vertex changing the color.

     

    For example, I tested it on this cube I built for a project of mine. It's made up of 10x10x10 quads. Mind you, quads are actually just a pair of triangles:

    femCube.thumb.png.c318ab053d97ab07d8466ea2a33f4525.png

     

    Then I used this code to randomize the color of every vertex:

    def PrepareMeshBuilder(self):
        ...
        [Here goes code to add primitives (tris, quads...), calculate normals, etc.]
        ...
        
        import random
        for vIndex,_ in enumerate(self.mb.getVertices()):
            r = random.randint(0, 255)
            g = random.randint(0, 255)
            b = random.randint(0, 255)
            self.mb.setVertexColor(vIndex, Color(r, g, b, 255))

     

    And got this:

    gradientTriangles.thumb.PNG.d0ae019080c51f90c1ff4a3720971200.PNG

     

    Edit:

    If I were you, I would override or create a custom addFace() method that took 3 colors instead of 1 and applied them directly. This way you could create your triangles and paint them at the same time.

     

    Edited by Tyronnosaurus
    • Like 1
    Link to post
    Share on other sites

    • 3 months later...

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • Help Us Improve Cura – Join the Ultimaker Research Program
        🚀 Help Shape the Future of Cura and Digital Factory – Join Our Power User Research Program!
        We’re looking for active users of Cura and Digital Factory — across professional and educational use cases — to help us improve the next generation of our tools.
        Our Power User Research Program kicks off with a quick 15-minute interview to learn about your setup and workflows. If selected, you’ll be invited into a small group of users who get early access to features and help us shape the future of 3D printing software.

        🧪 What to Expect:
        A short 15-minute kickoff interview to help us get to know you If selected, bi-monthly research sessions (15–30 minutes) where we’ll test features, review workflows, or gather feedback Occasional invites to try out early prototypes or vote on upcoming improvements
        🎁 What You’ll Get:
         
        Selected participants receive a free 1-year Studio or Classroom license Early access to new features and tools A direct voice in what we build next
        👉 Interested? Please fill out this quick form
        Your feedback helps us make Cura Cloud more powerful, more intuitive, and more aligned with how you actually print and manage your workflow.
        Thanks for being part of the community,

        — The Ultimaker Software Team
        • 0 replies
      • Cura 5.10 stable released!
        The full stable release of Cura 5.10 has arrived, and it brings support for the new Ultimaker S8, as well as new materials and profiles for previously supported UltiMaker printers. Additionally, you can now control your models in Cura using a 3D SpaceMouse and more!
          • Like
        • 18 replies
    ×
    ×
    • Create New...