Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Performance gains with C++? [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 174 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 18/05/2015 at 02:11, xxxxxxxx wrote:

      Greetings to all!

      So I wrote my first shader the other day. It's just a really simple 2D shape generator, there's a couple of trig calls (sin, cos, atan2, and sqrt) in the body of the Output() method, but that's about it. It seems to work well for a shader implemented in Python.

      My only problem is that it's kinda slow. The old shaders I was using (basically a bunch of stacked Gradient shaders inside a Layer shader) render out in mere minutes, whereas the shader I wrote seems to take about a half an hour. I'm honestly not sure what else I could do to optimize the code, I've already tried to reduce the problem down as much as I can. The entire thing is less then 40 lines, so we're not talking about anything extravagant here.

      I've noticed that a lot of Python shaders in general seem to be kinda slow. Noise generators, gradient generators, you name it. So my question is this: am I going to see any significant benefits from porting my shader to C++? Is a compiled language really *that* much faster?

      -CMPX

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 18/05/2015 at 07:04, xxxxxxxx wrote:

        Using Python for shaders is especially for fast prototyping. When you move your shader to C++ you will see a significant performance boost. The implemented Python in C4D is bytecode interpreted and has a so-called Global-Interpreter-Lock which prevents real multithreading. Python is not very fast when it comes down to pure number crunching.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post