Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mefihl | |
Old Version | Published before Godot 3 was released. |
How create shader on polygon2D?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mefihl | |
Old Version | Published before Godot 3 was released. |
How create shader on polygon2D?
Reply From: | Zylann |
Every CanvasItem
(Node2D
, Control
, Polygon2D
…) can have a CanvasItemMaterial
on it. To create a shader and apply it on your node, you must create a CanvasItemMaterial
in the material
property, and create a CanvasItemShader
in it. Then you’ll be allowed to edit the shader.
They are both resources, so you can choose to save them in a file (useful so you can re-use them) or leave them built into the scene.
Shader works on polygon2D without texture? I wants to impose on polygon2D the bloom effect.
Mefihl | 2017-02-10 05:59
Shaders work as long as there is any triangles or rectangles to draw, with or without texture.
Well, bloom effect is more than a shader and is achieved a bit differently.
I know it works in 3D by having a WorldEnvironment with bloom enabled, and by using HDR (for example, Color(2,2,2) which is “brighter” white, while Color(1,1,1) is standard white).
But I have no clue how to do it easily in 2D with Godot 2.x.
It’s usually baked in sprites when using textures, however with procedural polygons you need a more general setup.
Basically bloom requires to have an overlay on top of your polygon (or the whole screen, usually) and have a shader on this overlay that takes pixels already drawn, picks the brightest ones (or whatever you want), blurs them and draws the result with an additive blend.
It’s kinda the same as to what you would do in an image editor, but done with shaders.
Zylann | 2017-02-10 11:15
Ok, thx for info.
Mefihl | 2017-02-10 17:38
Actually I found the official demos have an example called “HDR for 2D”, which features a texture that can glow. It involves using a WorldEnvironment
node, which sounds a bit unusual for 2D, but it could be useful for you
Zylann | 2017-02-12 01:58