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

Improve support for transparent textures #2994

Merged
merged 14 commits into from
Jan 7, 2022
Merged

Improve support for transparent textures #2994

merged 14 commits into from
Jan 7, 2022

Conversation

pmconne
Copy link
Member

@pmconne pmconne commented Jan 6, 2022

Currently, a textured mesh draws in either the opaque pass or the transparent pass based on the transparency of the texture image.
We consider a texture image containing at least one transparent pixel to be "transparent". It draws in the transparent pass, and because of the way our order-independent transparency works, any opaque pixels end up displaying as slightly transparent. This effect is more noticeable with overlapping transparent objects.

#2981 introduced TextureTransparency which specifies 3 types of transparency: opaque, transparent, and mixed.
This PR takes advantage of this such that opaque textures render in the opaque pass, transparent textures in the transparent pass, and mixed textures in both.
The opaque pass discards transparent pixels and vice-versa.

This required a change to how we determine in which render pass(es) a given primitive should be drawn. Previously, every primitive could specify a single RenderPass; now, textured meshes may need to specify two.
Replaced most usage of RenderPass with a new Pass type, from which RenderPass(es) can be derived.
The primary changes are in RenderCommands.ts and RenderFlags.ts and /glsl/ - the rest just involve replace RenderPass with Pass.

Note: originally we had intended to ignore 100% transparent pixels - e.g., an image consisting only of 100% opaque and 100% transparent pixels would be considered opaque.
However, that doesn't really work because mip-mapping will produce semi-transparent pixels at the boundaries of the opaque regions; rendering in the opaque pass would produce abrupt, jagged boundaries.

Example from ImageTests test case - these buildings used to render as transparent because their texture contains a mix of fully-transparent and fully-opaque pixels causing them to be rendered in the translucent pass:
image

They now correctly render opaque:
image

Another example (images enlarged): on the right, the opaque portions of the plant texture now fully obscure the geometry behind them.
image

@pmconne pmconne marked this pull request as ready for review January 6, 2022 16:09
@pmconne pmconne requested review from bbastings, kabentley and a team as code owners January 6, 2022 16:09
@pmconne pmconne requested a review from a team as a code owner January 6, 2022 20:28
@pmconne pmconne merged commit 42a25e6 into master Jan 7, 2022
@pmconne pmconne deleted the rework-render-pass branch January 7, 2022 15:29
pmconne added a commit that referenced this pull request Jan 14, 2022
* Update changelog for 3.0 release (#2854)

* Create a table of contents and re-organize the contents to be more navigable.
* Spelling and formatting fixes
* Consistent casing; fix header level.
* Updates to AppUi change info

* Example with `ParentNode` symbol for root node rule makes no sense
* Promote `getContentInstanceKeys` API to @beta to make it referenceable from docs

Co-authored-by: Paul Connelly <[email protected]>
Co-authored-by: NancyMcCallB <[email protected]>
Co-authored-by: Grigas <[email protected]>

* Web IPC fix (#2996)

* Update roadmap.md (#2989)

Co-authored-by: Matt.Gooding <[email protected]>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Grigas <[email protected]>
Co-authored-by: bsteinbk <[email protected]>
Co-authored-by: Caleb Shafer <[email protected]>
Co-authored-by: Keith Bentley <[email protected]>

* Update to latest Rush and pnpm versions (#2990)

* 3.0.0-dev.177

* transformer defer aspect export of deferred elements (#2983)

* prevent trying to export aspects of deferred elements
* configure linter to understand the dot notation escape hatch
* remove callProtected
* remove protection from IModelExportHandler methods to make it less weird and add note about exclusivity of calls

Co-authored-by: Michael Belousov <[email protected]>

* Improve support for transparent textures (#2994)

* Define Pass type.

* Helper functions.

* Use Pass in place of RenderPass.

* Textured surfaces with mixed transparency draw in both passes.

Not producing correct results yet.

* Seems to work.

* api; lint.

* api; lint.

* fix raster text.

* not for classifiers.

* Update early z flags.

* Specify texture transparency for test.

* fix transparent pixel discard for classifiers.

* Fix flickering in TwoWayViewportSync (#3002)

* Swap to use the new imodels clients (#2912)

* Update to use the new imodels client
* Remove the old imodelhub tests

* keep an internal imodelbank-client for testing

* Improve ambient occlusion algorithm in situations where scene depth range is very deep (#3001)

Co-authored-by: Paul Connelly <[email protected]>

* 3.0.0-dev.178

* 3.0.0-dev.179

* 3.0.0-dev.180

* 3.0.0-dev.181

* UI: Fix tree node icon alignment (#2853)

* Bug: MessageBoxIconType.NoSymbol shows Success icon instead of no symbol (#2998)

* Honor "None" and "No Symbol" for MessageBox
components

* Update testing

* extract-api

* Support view-independent decoration graphics (#3007)

* Default camera on for 3d View Creator (#3004)

Co-authored-by: Paul Connelly <[email protected]>

* 3.0.0-dev.182

* Remove @EarlinLutz from CODEOWNERS.md (#3013)

* Create integration tests (full stack tests) for RealityDataSource and RealityDataAccess client. (#2952)

* Create integration tests (full stack tests) for RealityDataSource and RealityDataAccess client.

* Put back package in alphabetical order

* Add changelog

* Revisited the way map layers authentication is handled in the UI. (#3009)

* Revisited the way map layers authentifcation is handled in the UI.

* Added changed log

* Added api files

* Fixed build errors following linting.  Updated changedlog message,

* Created new documentation group for map layers.

* Updated module directives to MapLayers

* Revert adjustZPlanes globe change (#3014)

* Sky cube primitive buffers must be bound when attempting to draw a sky cube.

* Revert adjustZPlanes globe change.

* rush extract-api

* rush change

* changelog unneeded for regression that was never released.

Co-authored-by: Paul Connelly <[email protected]>

* Updating map-layers code owner. (#3020)

* Optimize matrix calculation (#3022)

* optimize matrix calculation

* optimize matrix calculation

* remove vague changelog of no interest to package consumers

Co-authored-by: Paul Connelly <[email protected]>

* lock down itwinui-react version (#3023)

* 3.0.0-dev.183

* Unregister maplayers itemsProvider and widget control on terminate (#3003)

* Unregister maplayers itemsProvider and widget control on termine

* Added changelog.

* Dont register Widget control.

* Fix lint errors.

* Remove the itwin client package (#3021)

* Remove the `@bentley/itwin-client` package
* Roll the request wrappers into packages that need it, including imodelhub client, core-mobile and core-frontend

Co-authored-by: Paul Connelly <[email protected]>

* Fix schedule state synchronization (#3030)

* 2.19.14 - 2.19.28 changelogs (#3031)

* clean up old changelogs (#3029)

* Set correct dist-tag in publish pipeline (#2700)

* Fix bug where new releases of old versions would get 'latest' tag

* delete unused variables

* Update dist tag logic

* Improve logic for giving out 'previous' tag

* Fix bugs and add comments to dist tag script

* Handle empty versions

* 3.0.0-dev.184

* Fix unhandled exception on iOS when exitPointerLock is called. (#3033)

* Presentation: Empty selection set after clear and replace (#3034)

* Add a test to reproduce selection set becoming empty due to unified selection after clearing and replacing selection set

* Fix unified selection tests to wait not only for `unified -> viewport` selection, but also for `viewport -> unified` selection to be synced

* Fix hilite set being cached with wrong guid

* rush change

* [build] Fix the use of the previousVer variable (#3037)

* Replace Viewport.readImage (#3035)

* readImageBuffer.

* Allow absolute viewport position so view rect can be precisely specified in pixels.

* testBlankViewport

* Test proving readImage reads upside-down.

* Test inverted y in view rect.

* Corresponding readImageBuffer tests.

* Implement readImageBuffer; tests pass.

* docs, rename.

* deprecate RenderTarget.readImage too.

* tests

* finish up tests.

* doc.

* NextVersion.md

* fix up callers of readImage.

* update test for correct behavior.

* update a couple more tests.

* extract-api

* doc is lie.

* completely unimportant typo.

* Provide default tool assistance for face/edge/vertex selection phase. (#3036)

* 3.0.0-dev.185

* 3.1.0-dev.0

* @bentley/imodeljs-native 3.1.1

* Update core-mobile API exports and release tags (#2836)

* Update core-mobile release tags

* Simplify RenderMaterial creation. (#3042)

* Simplify RenderMaterial creation.

* move webgl test to webgl dir.

* wip tests.

* wip test

* fix test.

* finish tests.

* docs.

* docs, deprecation

* Lint; NextVersion

* words.

* words words

* extract-api

* unused import.

* 3.1.0-dev.1

* fix presentation-full-stack-tests

Co-authored-by: Caleb Shafer <[email protected]>
Co-authored-by: NancyMcCallB <[email protected]>
Co-authored-by: Grigas <[email protected]>
Co-authored-by: swbsi <[email protected]>
Co-authored-by: Matt.Gooding <[email protected]>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: bsteinbk <[email protected]>
Co-authored-by: Keith Bentley <[email protected]>
Co-authored-by: imodeljs-admin <[email protected]>
Co-authored-by: Michael Belousov <[email protected]>
Co-authored-by: Michael Belousov <[email protected]>
Co-authored-by: markschlosseratbentley <47000437+markschlosseratbentley@users.noreply.github.com>
Co-authored-by: Robert Lukasonok <[email protected]>
Co-authored-by: kckst8 <[email protected]>
Co-authored-by: MarcBedard8 <[email protected]>
Co-authored-by: Michel D'Astous <[email protected]>
Co-authored-by: MarcNeely <[email protected]>
Co-authored-by: Seamus Kirby <[email protected]>
Co-authored-by: Travis Cobbs <[email protected]>
Co-authored-by: bbastings <[email protected]>
Co-authored-by: GerardasB <[email protected]>
Co-authored-by: Robert Schili <[email protected]>
Co-authored-by: hnn0003 <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Colin Kerr <[email protected]>
Co-authored-by: williamkbentley <[email protected]>
Co-authored-by: affank <[email protected]>
Co-authored-by: Affan Khan <[email protected]>
Co-authored-by: Sam Wilson <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants