three.js icon indicating copy to clipboard operation
three.js copied to clipboard

Added outlined-pixel pass example

Open KodyJKing opened this issue 3 years ago • 9 comments

This is a pixelization effect with outlines that add a bit of a pixel art feel.

https://www.youtube.com/watch?v=-WHW48SlvsI

KodyJKing avatar Aug 13 '21 08:08 KodyJKing

EDIT: new live link https://raw.githack.com/KodyJKing/three.js/outlined-pixel-example/examples/webgl_postprocessing_pixel.html

WestLangley avatar Aug 13 '21 10:08 WestLangley

There is already: https://threejs.org/examples/webgl_postprocessing_pixel

Would this PR be an improvement over the existing approach? I don't think the project needs two shaders for pixelated effects.

Mugen87 avatar Aug 13 '21 10:08 Mugen87

I think the example is much more compelling than the existing one personally especially for people who might be looking to make retro-style games. The addition of normal and depth edge sharpening is really nice and gives a more stylized video game sprite-like effect -- it looks nice.

The down side is that it requires a lot more shader texture sampling to achieve those edges. If performance impact is a concern then maybe the effect could be adjusted so no depth or normal sampling is done if either corresponding edge strength parameter equals zero. Otherwise I'd think this would be a neat replacement for the existing pixel effect.

gkjohnson avatar Aug 13 '21 15:08 gkjohnson

@KodyJKing As a next step I suggest you replace the existing webgl_postprocessing_pixel example with your code. Since you have implemented the effect as a pass, PixelShader can be removed.

Mugen87 avatar Aug 16 '21 09:08 Mugen87

I just wanted to say that this is bloody awesome and runs smooth as butter on my 'el-cheapo' Galaxy A50. Very nicely done! ❤️❤️

haroldiedema avatar Aug 18 '21 14:08 haroldiedema

@Mugen87 I replaced webgl_postprocessing_pixel and removed the PixelShader. However, I'm thinking PixelShader still has a use case because my RenderPixelatedPass handles the initial render of the scene and expects to be the first pass in the effect composer. If someone wanted to render the scene and apply various effects before pixelization, my pass wouldn't work for them.

KodyJKing avatar Aug 18 '21 20:08 KodyJKing

I understand but I still think a single pixel shader implementation is sufficient. We have to maintain all this code and thus make compromises.

Besides, a basic pixelated effect is not hard to implement. Most users should figure out by themselves how to do it.

Mugen87 avatar Aug 18 '21 20:08 Mugen87

@mrdoob This PR looks good.

Mugen87 avatar Aug 27 '21 15:08 Mugen87

@Mugen87 @KodyJKing this looks 😍, just a detail: this is not a correct import, it should just be three:

} from '../../../build/three.module.js';

and the normalRenderTarget should probably be RGBAFormat

drcmda avatar Apr 01 '22 09:04 drcmda

Closing in favor of #24873.

Mugen87 avatar Oct 30 '22 09:10 Mugen87

Hey @KodyJKing !

Loving the pixel effect! thank you so much for working on this :1st_place_medal:

DefinitelyMaybe avatar Dec 12 '22 20:12 DefinitelyMaybe

Oh, I haven't checked in on this in a while. Thanks @Mugen87 for getting it ready to merge.

KodyJKing avatar Dec 16 '22 10:12 KodyJKing