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

BLEND alpha mode #192

Closed
mittermichal opened this issue Aug 12, 2024 · 6 comments
Closed

BLEND alpha mode #192

mittermichal opened this issue Aug 12, 2024 · 6 comments

Comments

@mittermichal
Copy link
Contributor

in our project we would like to extruded geometry to be transparent to mark certain area. E.g. this red area of forest is infested with bark beetle.

For quick preview I modified MaterialCreator.MaterialBuilder to set BLEND alpha mode intead of OPAQUE:
update ... set geom_triangle = ST_Force3D(St_SetSrid(ST_Translate(ST_Extrude(wkb_geometry,0,0,30),0,0,0.1), 4326));

Height values: [0,1 m - 30,1 m]
Default color: #80FF0000
Default metallic roughness: #008000
Doublesided: True
Create glTF tiles: True
Screenshot 2024-08-12 at 12 02 15

I would like to make PR for this but I am not sure how you would like this to be customizable. I don't think its needed to have option to set MASK mode as whole geometry share the same base color*. But then should this be configurable per-geometry like blendAlphaMode: true in shaders json or should there be just simple switch that will enable this for all geometries or perhaps enable it per geometry anytime base color alpha channel is less than 1.
I think its better to have it per geometry because if someone has huge dataset and only wants few geometries form it to be transparent. Then it could unnecessary slow down rendering if all objects had BLEND alpha mode.

* https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#alpha-coverage

@bertt
Copy link
Member

bertt commented Aug 12, 2024

Yes it's now hardcoded to AlphaMode.OPAQUE (https://github.com/Geodan/pg2b3dm/blob/master/src/wkb2gltf.core/MaterialCreator.cs#L13)

I think the best is to add AlphaMode to the style.json (and default_alpha_mode to the options), like:

Default: OPAQUE
Options:    OPAQUE, MASK, BLEND

{
    "AlphaModes":[list_of_alpha_modes],
    "EmissiveColors": [list_of_emissivecolors in hex],
    "PbrMetallicRoughness": {
        "BaseColors": [ list_of_basecolors in hex],
        "MetallicRoughness": [list_of_metallic_roughness in hex]
    },
    "PbrSpecularGlossiness": {
        "DiffuseColors": [list_of_diffuse in hex],
        "SpecularGlossiness": [list_of_specular_glossiness in hex]
    }
}

Then you can define 1 default Alphamode for everything, 1 AlphaMode per geometry, 1 AlphaMode per inner geometry or 1 AlphaMode per triangle

@mittermichal
Copy link
Contributor Author

thanks, will try to implement this and send PR in next 2-3 days

@bertt
Copy link
Member

bertt commented Aug 12, 2024

Most easy is to only add default_alpha_mode to options (like defaultDoubleSided), if this is sufficient for your usecase.

@mittermichal
Copy link
Contributor Author

sure, but IMO then it should be explained to not combine with non-transparent objects
for our usecase it would be enough

@bertt
Copy link
Member

bertt commented Aug 12, 2024

sure, but IMO then it should be explained to not combine with non-transparent objects for our usecase it would be enough

We can add it in the styling readme https://github.com/Geodan/pg2b3dm/blob/master/styling.md

@bertt
Copy link
Member

bertt commented Aug 14, 2024

It's in release 2.15 :-)

I'll close this issue and create another one for adding alpha mode in the style json

@bertt bertt closed this as completed Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants