Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@matanlurey
Copy link
Contributor

@matanlurey matanlurey commented Jan 19, 2024

Document some confusing bits of geometry for the next bub.

Originally this PR was to add a test and fix a bug, but that's being handled here: #49938.

@matanlurey
Copy link
Contributor Author

matanlurey commented Jan 20, 2024

This is not really ready for review, but I need to mark it ready for review for Flutter gold to run.

Ready for review!

@matanlurey matanlurey marked this pull request as ready for review January 20, 2024 00:47
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #49910 at sha 9941c87

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #49910 at sha 064ceba

@matanlurey matanlurey force-pushed the engine-impeller-entity-transform branch from 064ceba to b4503be Compare January 22, 2024 23:37
@matanlurey matanlurey changed the title WIP: Entity transform bug in Impeller Geometry Wars: Documentation Edition Jan 22, 2024
@matanlurey matanlurey requested review from bdero and flar January 22, 2024 23:39
@matanlurey
Copy link
Contributor Author

There are no longer golden changes or tests in this PR, it's purely documentation. Thanks!

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, but with some fixes as mentioned in the comments.

texture_coverage.GetNormalizingTransform() * effect_transform;
// Calculate UV-specific transform based on texture coverage and effect.
// For example, if the texture is 100x100 and the effect transform is
// scaling by 2, then the UV transform should be scaling by 0.5.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be .02?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify? I'm not sure how the reuslt would be 0.02.

Copy link
Member

@bdero bdero Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the example given of a 100x100 texture, texture_bounds.GetNormalizingTransform() will result in a Matrix that scales by 0.01. Then, if the effect_transform is Matrix::MakeScale(Vector2{2, 2}), the resulting uv_transform will have x and y basis vectors with scale 0.02.

Copy link
Member

@bdero bdero Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv_transform is used to squish local positions (source_rect) into a 0-1 space for texture sampling.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdero beat me to it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both!


/// @brief Computes geometry and UV coordinates for a rectangle to be rendered.
///
/// UV is the horizontal and vertical axes within the texture.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean the horizontal and vertical coordinates within the texture.

An axis is a direction, not a position.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of suggestions, but otherwise LGTM :)

/// @param entity The entity to use for the transform.
/// @param pass The render pass to use for the transform.
GeometryResult ComputeUVGeometryForRect(Rect source_rect,
Rect texture_coverage,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming to texture_bounds or texture_local_coverage. "Coverage" as a standalone word has a screen/pass space connotation around other parts of the Entities layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// UV is the horizontal and vertical axes within the texture.
///
/// @param source_rect The rectangle to be rendered.
/// @param texture_coverage The size of the texture to be rendered.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more accurate description for this would be something like: "The local space bounding box of the geometry."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

// 2: position
// 3: UV
// etc.
std::vector<Point> data(8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bonus points: change this to an arrary so we don't do an extra heap allocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@matanlurey matanlurey requested a review from flar January 23, 2024 18:28
Copy link
Contributor Author

@matanlurey matanlurey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

texture_coverage.GetNormalizingTransform() * effect_transform;
// Calculate UV-specific transform based on texture coverage and effect.
// For example, if the texture is 100x100 and the effect transform is
// scaling by 2, then the UV transform should be scaling by 0.5.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify? I'm not sure how the reuslt would be 0.02.

// 2: position
// 3: UV
// etc.
std::vector<Point> data(8);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


/// @brief Computes geometry and UV coordinates for a rectangle to be rendered.
///
/// UV is the horizontal and vertical axes within the texture.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

/// UV is the horizontal and vertical axes within the texture.
///
/// @param source_rect The rectangle to be rendered.
/// @param texture_coverage The size of the texture to be rendered.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

/// @param entity The entity to use for the transform.
/// @param pass The render pass to use for the transform.
GeometryResult ComputeUVGeometryForRect(Rect source_rect,
Rect texture_coverage,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2024
@auto-submit auto-submit bot merged commit 220416c into flutter:main Jan 23, 2024
@ditman
Copy link
Member

ditman commented Jan 23, 2024

Just wanted to compliment the reference in this PR's title.

KUDOS! 🚗💨

std::vector<Point> data(8);
// Calculate UV-specific transform based on texture coverage and effect.
// For example, if the texture is 100x100 and the effect transform is
// scaling by 0.2, texture_bounds.GetNormalizingTransform() will result in a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 2.0?

@matanlurey matanlurey deleted the engine-impeller-entity-transform branch January 23, 2024 22:47
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 23, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 23, 2024
auto-submit bot pushed a commit that referenced this pull request Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants