Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additive blending #1189

Closed
stevesan opened this issue Dec 18, 2017 · 12 comments
Closed

Additive blending #1189

stevesan opened this issue Dec 18, 2017 · 12 comments

Comments

@stevesan
Copy link

Additive blending is commonly used for particle effects, and it's easy to implement. How about an alphaMode=ADD?

@donmccurdy
Copy link
Contributor

I could imagine two ways of declaring this:

"alphaMode": "ADD"
"alphaMode": "BLEND",
"blendEquation": "TRANSLUCENT" | "ADD"

If we think that other blending equations may be needed, the second seems a bit more future-proof.

Is this appropriate for a 2.X release, or best included via an extension? This can be implemented widely enough that, IMO, 2.X would be appropriate.

/cc @AurL you have some use cases for this too, yes?

@emackey
Copy link
Member

emackey commented Dec 19, 2017

+1 for better control over blending modes. Worth remembering that glTF 1.0 had the full set of WebGL blending options, with enums for blendFuncSeparate, blendEquationSeparate and so on. Perhaps not all of these are compatible with other rendering APIs, but some subset of them that includes additive blending should be commonly available.

@bghgary
Copy link
Contributor

bghgary commented Dec 19, 2017

Does additive blending make sense with PBR?

@emackey
Copy link
Member

emackey commented Dec 19, 2017

I would say that having additive-blended effects in the same scene as PBR can be useful. Glowing sparks with additive blending can make a scene more exciting.

@bghgary
Copy link
Contributor

bghgary commented Dec 19, 2017

Makes sense for particle effects, non PBR-materials (like unlit), KHR_technique_webgl, and possibly other extensions. Should we put this in the core spec if the core spec itself does not need it?

@emackey
Copy link
Member

emackey commented Dec 20, 2017

It may be worth having its own extension, separate from the _webgl one (even though the webgl one gets this essentially for free since glTF 1.0 had it). I don't know what it takes to get this on Vulkan and D3D but I imagine it's a much lower bar than all of WebGL.

Would be good to get more feedback on how popular such an extension might be, and how it might be used.

@stevesan
Copy link
Author

It would mainly be for particle effects. For example, Tilt Brush sketches on Google Poly: https://poly.google.com/view/74IwAq0ig8u The snow there is all additive. Without additive, you'd have two options:

  1. Render all snowflake geo as a single draw call, and live with sorting artifacts.
  2. Split them into many draw calls to get better sorting, and live with worse performance.

With additive, you get good performance, no sorting artifacts, and live with less accurate blending (snow flakes over the white snow on the ground disappear).

Does this make sense for PBR? It's certainly possible to light using PBR and still do additive blend, so it's not in conflict. But if by "make sense" you mean "correct and physically based", then it's definitely not. But ya know, when it comes to rendering transparency in real time, from my experience you typically choose the option that's least bad for your particular case. So offering additive, which is simple to implement (can't imagine any issues with Vulkan or D3D or anything), seems like a good idea to me.

@donmccurdy
Copy link
Contributor

+1 for separating this from _webgl, whether it ends up as an extension or part of core spec.

@lexaknyazev
Copy link
Member

Previous discussion on this matter: #1033.

@donmccurdy
Copy link
Contributor

donmccurdy commented Jan 5, 2018

Picking up from the last comments by @bghgary and @lexaknyazev

We didn't include add or multiply for alphaMode because it's typically for particle effects which are not currently in the core spec. Without effects, having the ADD mode would seem out of place.

"EXT_material_effects": {
 "type": "SPARK",
 "someParameter": 0.5
}

Is it possible to define clear parameterized models for "effects" as we do for PBR? This seems well into application-specific territory, whereas additive blending is a basic graphics feature that can be used in many contexts... I'd expect apps like Tilt Brush to have their own effects rather than using a pre-defined "type": "SPARK" feature in glTF.

IMO it feels safer to just support additive blending and other required features, and let users create application-specific effects using KHR_technique_webgl etc.

@donmccurdy
Copy link
Contributor

Going to try to get this rolling in parallel with, but separate from, KHR_techniques_webgl.

Feedback welcome on draft EXT_blend in #1302.

@donmccurdy
Copy link
Contributor

Let's merge this thread into #1302 – feedback welcome. I think there's some question still of how broad a set of blend states should be handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants