-
-
Notifications
You must be signed in to change notification settings - Fork 842
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
render: Implement reposition in Z-axis #19405
base: master
Are you sure you want to change the base?
Conversation
0.0, | ||
0.0, | ||
0.0, | ||
1.0 / (viewport_width as f64 / 2.0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find the official resource to justify this scaling in Z. It just worked in image comparison with my eyes.
m | ||
}; | ||
let move_coord = { | ||
// AS3 places Viewpoint at (0, 0, -focalLength). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut m = Matrix3D::IDENTITY; | ||
m.raw_data[0] = focal_length; | ||
m.raw_data[5] = focal_length; | ||
m.raw_data[10] = focal_length; | ||
m.raw_data[11] = 1.0; | ||
m.raw_data[14] = 0.0; | ||
m.raw_data[15] = 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing tests are failing... Some are small differences (e.g. again the 1px border difference), but some have big differences (e.g. Edit: WGSL code for blending had some parameters that don't work well with z values. Fixed at a07df30. |
ab65925
to
a07df30
Compare
a07df30
to
0c0788e
Compare
let pos = common__globals.view_matrix * transforms.world_matrix * vec4<f32>(in.position.x, in.position.y, 1.0, 1.0); | ||
let uv = vec2<f32>((pos.x + 1.0) / 2.0, -((pos.y - 1.0) / 2.0)); | ||
let pos = common__globals.view_matrix * transforms.world_matrix * vec4<f32>(in.position.x, in.position.y, 0.0, 1.0); | ||
let uv = vec2<f32>(in.position.xy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure of this change to be honest. Because in other WGSL files, the uv is independent of world_matrix (and sometimes uses another matrix texture_matrix
), I thought this is correct, but not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct. I believe Ruffle uses those coordinate systems?:
in.position
:[0, 1] * [0, 1]
(e.g.Quad
) (wgpu texture coordinate system)world_matrix * in.position
:[0, width] * [0, height]
(FP coordinate system)view_matrix * world_matrix * in.position
:[-1, 1] * [-1, 1]
(wgpu render coordinate system)
wgpu coordinate systems: https://github.com/gfx-rs/wgpu?tab=readme-ov-file#coordinate-systems
c272872
to
6078de0
Compare
In Transform.Matrix3D setter, the transformation matrix was crushed to 2D, ignoring 3D parameters. This commit picks up tz element (i.e. raw_data[14] element) into render.Transform and take it into account in wgpu rendering. The projection matrix for the default perspective projection (FOV: 55.0 deg, center: stage center) is introduced to rendering.
They replace flash.display.DisplayObject z getter/setter stubs. The z value (z translation) is now taken into account in wgpu rendering.
displayobject_z is the test for rendering with different tz values from a few places by the image comparison.
geom_transform test didn't have meaningful values for z-axis related field on purpose because it was unsupported. This commit adds some random values into fields supported by this patch, translation in z-axis.
Closes #8033 . See #8033 (comment) for the difference.
This PR implements
DisplayObject.z
property feature including its rendering with the default perspective projection.Known limitations
render/wgpu/src/globals.rs
.root.transform.perspectiveProjection
is not effective. (In fact, even its setter is not implemented in Ruffle.)perspectiveProjection
of any ancestors is not taken into account while the doc says:The implementation might not be the good one. Especially the
Transform
struct now has the newtz
in addition to the existingmatrix
(2D). Thetz
property will be removed at the implementation of the full 3D transformation.