Comments (4)
I had to think a bit before I remembered, but yes it is actually on purpose. The only difference is how the alpha value is computed and since the destination alpha is not used for blending the colors are the same. The reason is that on web the rendered image must end up having an alpha value of one in all pixels otherwise it may look weird on some browsers since it then blends with whatever is behind the canvas. Actually wasn't it you that had a problem with this in the fireworks example? 🙂 Anyway if you find that it's not working in some case then please let me know!
from three-d.
Yeah, it was me: it took me a few minutes to remember the context.
We're just talking about a default value, so maybe it isn't worth too much more time, but let me make a case for returning it to
source_alpha_multiplier: BlendMultiplierType::One,
destination_alpha_multiplier: BlendMultiplierType::Zero,
I think you're right that it won't matter in examples/fireworks, because blending operations never use the destination alpha channel as an input. In this case, the preexisting destination alpha (1.0) is preserved through the entire buffer and prevents the weird browser transparency bug. (FYI: examples/fireworks does not actually use the default BlendParameters value, but examples/fog does)
However, the "traditional" equation will have the expected behavior in a case where buffer alpha is important. For (a contrived) example, consider the creation of a picture of fireworks in a RenderTarget, to be drawn multiple times in a scene with transparency:
- the RenderTarget would initially be filled with rgba=(0,0,0,0)
- some (non-overlapping) fireworks sprites would be rendered into the RenderTarget, writing their own alpha values into it
- this RenderTarget can then be used as a texture in the main scene with correct transparency
If the source_ and destination_ alpha_multipliers are reversed, this RenderTarget buffer would have 0 alpha and could not be rendered in the main scene. Obviously there are lots of things that the traditional default can't do, but if there's a default, it may as well be as unsurprising as possible.
The way I fixed the browser transparency bug was to use the code in #60 (comment) after all rendering had been completed: this simply sets the alpha buffer to what browsers need, with no ramifications for the prior rendering process.
Sorry for resurrecting this issue: I don't remember even looking at the commit when it was made, so I should have made this comment back then.
from three-d.
That is a really good point. I will revert the default transparency back to what it was and then just not use the default in the examples where it causes problems 👍
from three-d.
And I am glad you brought it up again, so it can be fixed, so no worries 🙂
from three-d.
Related Issues (20)
- Uncaught runtime errors
- "You forgot to call destroy() on the egui glow painter. Resources will leak!" HOT 3
- Centering the camera on a model HOT 4
- `Camera` is trying to do too much - not compatible with custom camera implementations HOT 2
- Headless on windows HOT 2
- Weird stretching when rendering finite terrain HOT 2
- Converting between ui space and screen space? HOT 2
- How to control occlusion for 2D shapes? HOT 7
- InstancedMesh but with different material for each instance HOT 5
- Run three-d from egui app HOT 1
- Camera position_at_pixel() is missing window_scale_factor on HiDPI displays HOT 2
- Any plans to support custom buffer element types for interleaved data? HOT 1
- ColorMaterial Transparency breaks when renderered at negative Y position? HOT 2
- Upgrading V0.16.1 => V0.17 breaks loading a 1x1 pixel white texture HOT 2
- Some kind of blend/alpha issue with some models (inside-out models) HOT 1
- Trying to use PhysicalMaterial without lights crashes the program HOT 1
- Warning when running on the browser / crash in debug mode HOT 3
- InstancedMesh Individual Animations HOT 2
- `egui` links don't work? HOT 1
- How would other shadow algorithms slot in?
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 three-d.