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