Coding Freestyle textured strokes, results and ideas

Hi, I’m hacking into blender to bring back textures on freestyle strokes.


Basically, freestyle generates a geometry for the strokes, attaches a shadeless material to it, uses vertex color to shade the mesh according to freestyle settings and modifiers, render the strokes and destroys all the evidence!

What I did is creating UV coordinates along the strokes and use a texture on the temp material alpha, so I didn’t have to really implement the currently stubbed freestyle texture manager.

Combined with blender compositor and freestyle modifiers, textured strokes give nice NPR results,


Also, sampling the colors from the material and using a brush texture we can obtain paint-like rendering, not limiting the use of freestyle to contour only


I tried many kinds of implementation: an user defined material, choosing a blender texture or a assigning a blender image. The current implementation restores the freestyle TextureAssignerShader, wich takes an index from 1 to 7 as input to choose a texture from a predefined set. I added an 8th option to use blender images as well, but now I think that we should not use this class.

Yes, backward compatibility with freestyle shaders is a nice thing, but we should take in account these points:

  • Backward compatibility should not force bad design
  • The blender freestyle interface is not 100% backward compatible already
  • Loading textures at rendertime and destroying them after each render is unoptimal
  • Why should we stick to a limited set of textures while we have a full CG application at hand?
  • We could mimic GL blending options with texture blending options, but then we could just choose what to do with the alpha (multiply, mix, lighten) from a proper menu.

So, the way I would like to implement freestyle textures is a new freestyle shader function, something like BlenderTextureShader() that passes a pointer to a blender image, plus some blending options (factor, blending, texture step). The current freestyle texture shaders should report a message telling to use BlenderTextureShader instead, and the BlenderTextureManager class should be removed.

Predefined brushes could then be implemented at high level, as collections or addons.

What do you think? Should we also be able to assign procedural textures, or images only? Why not use textures for color as well? Or as color and alpha modifiers?

I’m interested in everyone’s feedback and I would like developers to help me having this into blender, we really need this feature at our studio and I would be forced to fork forever! :eek:

Patch is coming soon, some code cleanup is still needed, and I hope to have some feedback to submit a better patch.

Thank you

Looks pretty awesome

Though, isn’t there a huge change coming up in the freestyle api? Might want to check the developerpages/bugtracker for this.

Looks cool though.

That appears to be the case: https://developer.blender.org/T37565 :yes:

Hi, I’m aware of the ongoing freestyle API refactor, my work is mostly not API related, so that should not be a problem :slight_smile:

You should probably contact the main (I think) freestyle developer: rd6t-kjym (at) asahi-net.or.jp .

He browses these forums from time to time. But I’m not sure how often he visits.

Hi,

Thanks a lot for your effort on implementing textured strokes in Freestyle. This functionality will be much appreciated by many Freestyle users!

I totally agree with all the design thoughts. Backward compatibility is not an issue in this case, because textured strokes were not supported at all so far in Freestyle for Blender. Style modules written for the standalone version of Freestyle are also not supported either. It is a good idea to introduce a BlenderTextureShader class to give access to texture data (this addition won’t be affected by the ongoing API updates by the way, since the main concern of the API changes is where to store API classes in a hierarchy of Python packages). The shader implementation based on UV coordinates over stroke meshes sounds okay. The integration of the functionality into the Parameter Editor mode looks also great. The demo renders are really awesome!

I will be happy to review the code when it is ready. Please, feel free to take your time.

veeeeeeeeeeeeeeeeeery cool and veeeeeeeeeeeeeeery welcome.

Awesome. Thanks for this!

I’ve been cutting my tooth on a production using freestyle of late, and this looks like a great addition. Thank you, and looking forward to trying it out soon!

I love to tinker around with Freestyle, but it isn’t until recently that I have considered it a viable option for my pictures/animations.

This opens up the possibilities of Freestyle that I had previously only imagined. Taking it to an all new level.

The development seems to be going smoothly:

https://developer.blender.org/T38327

I can’t try it out ATM. But I hope it’s as awesome as I think it is! :slight_smile:
It’s really nice to see more developers working on freestyle!

Hi, apart some minimal tweak the patch proposal is now complete, I’m waiting for kjym3 and other developers feedback, maybe there are bugs I can’t see (well I’m expecting some bug or bad design to be there, no way I did it on first try!) or some elements that will be better moved somewhere else.

It’s really nice to see more developers working on freestyle!

I hope there’s more coming, both in terms of developers and NPR development :slight_smile:

Thanks for watching this project, I would have liked to release some binary as well but my ubuntu box is on a total mess with dependencies, and a static build is out of the league at the moment.

Today I was wondering if it`s possible to get something like this in Blender.

And here you are!

This looks amazing, I love it so much! Thank you for your effort!:slight_smile:

the best i can get without this feature is



and

any hope of seeing the OP’s hacks in trunk some day soon? :slight_smile:

I love the squiggly line effects on the mouse. Is that a new freestyle feature?

That’s been in for a long time if not from the beginning of Freestyle, use a noise or displacement type geometry modifier, in this example I used Perlin 2D, spatial AND sinus… maybe overkill!


ah very cool!!

Freestyle is really awesome atm. I still wish we had the ability to use any texture for the lines.

And the ability to apply the same types of distortion effects that freestyle lines have on color cell shades.

@@blurymind
Lines on mouse is done with spatial noise modifier.

But to do the line on the toycar may crash Blender.
I did a little extreme, crash my OS too.

@@pKrime
Does texture handle alpha?

So far, my major issue with freestyle is the way it handles transparency on objects whose transparency is defined by textures. polygonal hair in particular suffers from this issue. freestyle just traces the contours not caring which parts are transparent and which parts aren’t.

Also, caching the freestyle mesh should be used to reduce re-render times
Perhaps in future, we would be able to enable/disable freestyle per material or per object. That would greatly reduce the work on compositing

Other than that, I really enjoy using freestyle. So keep up the good work! I don’t know how I survived before freestyle