godot
godot copied to clipboard
Add Texture Smooth Pixel Filter property to BaseMaterial3D
When enabled, this displays the texture with an appearance that mimics nearest-neighbor filtering with a shader to smooth out aliasing between pixels. This can be used for a pixel art look that is still antialiased regardless of the current antialiasing method in use.
This is also available in SpriteBase3D and Label3D. This could also be implemented in Decal (via a project setting to toggle it for all decals), but this may be left to a future PR as it's more complex.
Thanks to @CptPotato for providing the shader code :slightly_smiling_face:
- This closes https://github.com/godotengine/godot-proposals/issues/9106.
Testing project: test_smooth_pixel_filtering.zip
Preview
Disabled | Enabled |
---|---|
On Label3D (alpha transparency) and SpriteBase3D (alpha scissor transparency, so only the internals are smoothed out):
Without mipmaps
Watch videos in fullscreen to avoid aliasing (viewport resolution is 1280×720, but videos are 3840×2160).
Disabled
https://github.com/godotengine/godot/assets/180032/792371f0-ba50-4d5d-a174-5b1ca4f76f43
Enabled
https://github.com/godotengine/godot/assets/180032/3247d467-60a6-4d71-b58a-5167c96f41d9
With mipmaps + 16× anisotropic filtering
Disabled
https://github.com/godotengine/godot/assets/180032/ae66bfef-58bc-4eec-96c6-2db8d7622bdc
Enabled
https://github.com/godotengine/godot/assets/180032/16dc733a-2ad5-499f-9214-5484b1ef40c0
I'll be shocked if this doesn't make it in seeing as so many games use it. Having to hack around with shader material is a pain, especially since it makes it tough to use the 3D sprite nodes. This is much better...
Bump, Interested on this to be merged too!
@PerikiyoXD Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.
This was discussed a while ago in a rendering meeting under @clayjohn 's discretion (I believe?).
The meeting notes about this are as follows:
- Simplify PR, then it would be acceptable (texture_custom, remove textureSize)
- In the future we need to avoid being put in this position, so we need to make the process of using custom shaders en masse easier
- Add ability to grab albedo_tex in shader material in Sprite3D to override the main texture. To make using custom shaders more feasible
Just putting these here for safe-keeping. I hope you're taking notes too, Calinou! Cheers!
- Simplify PR, then it would be acceptable (texture_custom, remove textureSize)
What do you mean by texture_custom
? Is it a way of improving code reuse by making every material sampling function use this method, then redirecting it to texture()
or texture_point_smooth()
depending on the setting? If so, I can look into doing that.
Also, how can I get rid of textureSize()
while allowing arbitrary-sized textures to work with this material? Different PBR maps may also have a different resolution for each PBR map.
- Add ability to grab albedo_tex in shader material in Sprite3D to override the main texture. To make using custom shaders more feasible
Sounds good, it might be worth creating a dedicated proposal for this though, as I feel this is out of scope for this particular PR.