Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HalftoneEffect #588

Closed
3 tasks done
Tracked by #600
vanruesc opened this issue Feb 16, 2024 · 8 comments
Closed
3 tasks done
Tracked by #600

Implement HalftoneEffect #588

vanruesc opened this issue Feb 16, 2024 · 8 comments
Assignees
Labels
feature Description for the implementation of a feature
Milestone

Comments

@vanruesc
Copy link
Member

vanruesc commented Feb 16, 2024

Description

Implement a HalftoneEffect (DotScreenEffect).

References:

Tasks

  • Create HalftoneEffect.
  • Create halftone demo.
  • Add unit test.

Implementation Details

  • Update the dot screen shader based on three's halftone shader
@vanruesc vanruesc added the feature Description for the implementation of a feature label Feb 16, 2024
@vanruesc vanruesc added this to the v7 milestone Feb 16, 2024
@vanruesc vanruesc mentioned this issue Feb 17, 2024
33 tasks
@balraj-johal
Copy link

I'd like to pick this up if possible, seems like an interesting one :)

@vanruesc
Copy link
Member Author

Ok, thanks for the help!

@vanruesc
Copy link
Member Author

Just checking in: would you like to stay assigned to this ticket?

@balraj-johal
Copy link

Hi @vanruesc, sorry for the radio silence! Yes I would still like to be assigned, my free time has been eaten by my day job but currently I have the shader compiling, and am getting my head around the modifications required, particularly sampling the color texture at multiple points.

@vanruesc
Copy link
Member Author

vanruesc commented Mar 14, 2024

No worries! Take your time.

I just took another look at the halftone shader in three and have some tips:

  • Blending is already implemented in Effects
  • Greyscale is already implemented via color grading
  • width & height are already available via resolution.xy
  • No need to support all shapes, dot is probably enough for a first implementation, but it's up to you
  • The rand method is already available

Sampling at custom coordinates can be done like this: texture(gBuffer.color, coords);

@balraj-johal
Copy link

Thanks for the pointers!

One thing I was wondering about actually was if there's a way to assign to the output colour directly for debug purposes? For example, if I wanted to see an output of the pass directly without it being composited in the pipeline.

@vanruesc
Copy link
Member Author

a way to assign to the output colour directly for debug purposes

No, effects are incomplete shaders after all and outputColor/gl_FragColor is overwritten at the end of the full shader. But the default blend function SrcBlendFunction basically does what you want.

If you want to render non-color data, do this: effectPass.fullscreenMaterial.colorSpaceConversion = false;

@balraj-johal
Copy link

Cool, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Description for the implementation of a feature
Projects
None yet
Development

No branches or pull requests

2 participants