I've used the past week to update some of the cpp-defined stroke shaders. I've used imagemagick and some python scripting to check for errors, but if I, with my limited c/cpp knowledge, have done something stupid please tell me.
changes:
- use StrokeVertex.u instead of (index of vertex / number of vertices). it is a lot cleaner and actually more correct. this causes slight deviations in render results, but they are barely noticeable.
- I tried to use float arrays and blender's vector operations where it makes sense (that is, where it's shorter and more readable)
- implemented the .orthogonal() method for vec2d objects; much cleaner and usually saves a line.
- tried to improve sampling a bit. memory-wise it should be a little more efficient, speed-wise it barely makes a difference. the result is exactly the same.
- fixed the guiding lines-shader, taking the python version as the right one. the cpp version would not displace some
- strokes and in general showed some weird behavior. there is however quite the visual difference between the two versions.
- using a new deletion method for removing consequtive parts of a stroke, the BezierShader is now faster, especially on dense strokes (600% with sampling 0.1). the same is now true for the tipremovershader, which for dense strokes (sampling 0.1) is now 10% faster. vertex deletion is a real bottleneck. (obviously a sampling value of 0.1 is somewhat impractical, but it shows this flaw quite strikingly.)
- removed lots of unnecessary code. this produces a 1-3% speed increase, but more importantly much cleaner code.
- (some more ifdef'd code could also be removed in my opinion)
- I tried to come up with an alternative method for the LengthDependingThicknessShader. it seems to work quite well already, and is much more predictable that the old version.
- I would furthermore propose (perhaps after a consultation to the blender-npr mailing list) to expose the smoothingshader and the thicknessnoiseshader to the UI. they are sort of on a shelf catching dust, and I could see them being quite useful.
minor points I found out later:
qt messed up the indentation, will fix that next patch
there is a slight error in tipremovershader
