Performance gains with C++? [SOLVED]
-
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
-
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.