0
\$\begingroup\$

I am writing a 3D renderer that would render 3D models as if they had been drawn in halftone. Feature-wise I need nothing fancy - no colors, just pure 3D geometry and basic lighting like here:Suzanne Image credit: https://blenderartists.org/forum/showthread.php?438820-Suzanne-Sketch

Notes:

  • I have written a basic 3D renderer in the past, however, I am really inexperienced when it comes to shaders (again, I do know basics) and I have absolutely no idea where to start with this.
  • The example image has been created in Blender, but I am writing my custom renderer.
  • This is not a duplicate of "How can I make a shader effect that looks like a lightly shaded pencil drawing?", as my input is a 3D model, whereas the OP in the linked question used an image.
\$\endgroup\$
  • 1
    \$\begingroup\$ The image you show is not pen(cil) style. It's the style newspapers were printed in (en.wikipedia.org/wiki/Halftone) \$\endgroup\$ – Kromster Oct 8 '17 at 16:25
  • \$\begingroup\$ @Kromster thank you for the correction! I am not a native English speaker, nor is this my area of expertise, so your help is very welcome. :) \$\endgroup\$ – sjaustirni Oct 8 '17 at 16:40
  • 1
    \$\begingroup\$ I agree that the question isn't a duplicate, but not for the reasons you gave. You can always render your model to a 2D image & then apply a 2D image filter. Also, this question might be better suited to the computer graphics stack exchange. \$\endgroup\$ – Pikalek Oct 8 '17 at 19:03
  • \$\begingroup\$ @Pikalek true, however, I was initially thinking about how to use the 3D geometry data from the model, so that's the root of my reasoning. As for the CG SE, thanks for the tip, I wasn't aware of it. \$\endgroup\$ – sjaustirni Oct 8 '17 at 19:22
1
\$\begingroup\$

I would write a two-pass renderer. The first pass renders the geometry to a 2D texture. In a second pass the texture is uploaded to the GPU. Use a different shader for the second pass. This shader then uses the fragment position to decide which part of the crosses it is rendering (whitespace or line). The brightness or thickness of the cross can be obtained by sampling the brightness of the surrounding pixels values from the texture.

Maybe you can get some good results without multi-sampling. Then it is possible to render this in one step by directly calculating the brightness

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you, I will try to use use this technique and will come back for more questions or an accept. Meanwhile, have my upvote :) \$\endgroup\$ – sjaustirni Oct 8 '17 at 16:42
  • \$\begingroup\$ The texture shouldn't get uploaded to the GPU; it should already be there. \$\endgroup\$ – user253751 Nov 22 '17 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.