Comments (3)
It seems the Gradient fills it only up to
256
pixels, but I don't really see the connection withwidth
.
The whole Polygon2D is filled, but its texture repeating is disabled as its texture_filter
is set to Inherit
, and rendering/textures/canvas_textures/default_texture_repeat
project setting is set to Disabled
(both are default values).
For disabled repeating the texture is clamped to edge. Might be more obvious with a different texture:
texture repeat disabled | texture repeat enabled |
---|---|
This works as expected, no bug in here.
I expected the polygon to get filled completely in the first color if the Gradient offsets are 0 and 1 and the interpolation mode is constant.
Whether the polygon gradient texture should be filled completely with the first color in such case seems debatable / expectations might differ. I'm not sure what's the expected behavior here.
Currently the GradientTexture1D's i
-th pixel color (0 <= i < width
) is determined by point-sampling the assigned Gradient at i / (float)(width - 1)
.
So it's like if you'd stretch the Gradient from the middle of the first pixel to the middle of the last pixel, and assign each pixel the color from the Gradient corresponding to the pixel's center. Something like:
The example is for linear sampling but it's sampled like that for all sampling modes. That's why for constant sampling mode the last pixel (i == width - 1
) gets the color at Gradient's 1.0
offset.
For linear/cubic sampling modes I think it might be expected that the first/last pixels match the colors at 0.0
/1.0
offsets exactly, hence it's sampled like that.
But maybe specifically for constant mode it should sample like (i + 0.5) / (float)width
instead? 🤔 Not sure.
(see also #76164, kinda related discussion)
Seems like an arbitrary decision / up to discussion (so not really a bug).
Set the width of the Gradient to
300
Still the texture doesn't fill the polygon
It does though, after you ran the project once
There's indeed some problem with the GradientTexture1D's preview not updating, and the polygon not accounting for the new size of the texture:
(same in v4.3.beta1.official [a4f2ea9])
This is definitely a bug.
from godot.
Thanks a ton for this awesome explanation and precise definition of the actual bug that appeared.
So I'm going to increase the width now to at least the width of the polygon so I have enough colors available (even if it's not really changing quite so often when using constant
). And additionally I won't trust the editor for now regarding this and only try it in the running scene.
from godot.
By the way. The real issue I had was that I couldn't figure out how to fill a centered polygon:
3ter/godot-issue-polygon2d-gradient-fill@c735740.
When setting the points centered from the beginning I couldn't for the life of me get the texture to work:
When setting the points and using a transform instead it works like a charm:
from godot.
Related Issues (20)
- Skeleton3D with bones causes continuous editor update HOT 2
- ImmediateMesh surface_add_vertex fails to inherit parent coordinate space or top_level property HOT 1
- Runtime TileData Z-Index modifications are reset after TileMapLayer _rendering_update
- Hue Variation not applied in CPUParticles2D if hue variation curve is unset
- [ProgressBar] inconsistent Step behavior HOT 3
- Animation Player animation drop-down not showing scrollbars sometimes with a long list with 4.3-beta1 HOT 6
- CharacterBody3D.move_and_slide() doubles in speed as "physics ticks per second" gets higher (when sliding against wall and floor simultaneously) HOT 2
- Viewport does not retain new camera settings when set via EditorPlugin
- Dev assert on editor exit: 1 shaders of type ParticlesShaderRD were never freed HOT 3
- `SpinBox` and `EditorSpinSlider` do not take into account that `min_value` may have more decimals than `step`
- False error "Parse Error: The function signature doesn't match the parent." thrown in larger projects after changing both parent and child. HOT 2
- LineEdit breaks when using circumflex or acute accent characters HOT 2
- OpenGL: 3D MSAA crashing Meta Quest 2 OS when using compatibility mode HOT 2
- Can not play animation in sub thread
- Can't edit CollisionShape3D with Half Resolution HOT 2
- Distance Fade PixelDither and ObjectDither does not work when usign Compatibility Rendering HOT 4
- buggy editor preview on android HOT 1
- In the GDScript, adding an Animation with LoopMode set to LOOP_PINGPONG does not produce the expected effect.
- Instances of inherited scenes are not updated properly after changing any property
- Improvement notification export for GDExtensions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot.