Aaron Wang Posted January 16, 2016 Share Posted January 16, 2016 I noticed that the built-in GrayFilter only works for WebGLRenderer, but I really need to implement the gray filter effect on all renderers, used to highlight and darken objects, is there any alternatives? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 16, 2016 Share Posted January 16, 2016 If you want to apply the filter to all the canvas, you can use CSS filter. Quote Link to comment Share on other sites More sharing options...
Aaron Wang Posted January 16, 2016 Author Share Posted January 16, 2016 3 hours ago, ivan.popelyshev said: If you want to apply the filter to all the canvas, you can use CSS filter. Thanks for you reply, but unfortunately, I need to apply the filter to certain parts of the canvas precisely, I think that'll be verify difficult with CSS. I just have a thought, can I use half transparent gray picture to cover on target region to simulate the filter effect? Will that be possible? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 16, 2016 Share Posted January 16, 2016 May be something can be done with blendModes: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation Quote Link to comment Share on other sites More sharing options...
Aaron Wang Posted January 18, 2016 Author Share Posted January 18, 2016 I end up using transparent dark overlay to highlight/darken objects eventually. Quote Link to comment Share on other sites More sharing options...
Exca Posted January 18, 2016 Share Posted January 18, 2016 One option would be to draw the images to separate canvas, then go through all the pixels (in each image you want to grayscale) and calculate gray variation of the image and use that canvas as texture and alphablend between original image and calculated grayscale. [Edit] To have an area of grayscaled sprites you could then just mask the area which shows grayscaled sprites on an layer above the normal sprites. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.