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

Removed hard-coded swizzle hack in RayQueries sample #1210

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yknishidate
Copy link
Contributor

@yknishidate yknishidate commented Oct 26, 2024

Description

Removed hard-coded swizzle of vertex positions.

model.vertices[vertex_start_index + i].position = sponza_scale * pts_[i].yzx;
model.vertices[vertex_start_index + i].normal = normals_[i].yzx;

Background:

  • The Sponza includes rotation, but this is not taken into account when loading in this sample.
  • Therefore, rotation is hard-coded by swizzling of the vertex positions.
  • Furthermore, FrontFace is set to ClockWise to draw polygons that are inverted by this swizzling .

Fix:

  • Load taking into account the scene rotation (for simplicity, pre-multiply the vertices by a transform matrix).
  • Changed FrontFace to standard CounterClockWise.
  • The projection matrix is ​​changed with vkb::rendering::vulkan_style_projection().
  • Adjusted the camera translation and rotation.

Bonus:

  • Adjusted the light position to make the shadow effect easier to understand. (If it shouldn't be changed, please let me know and I'll revert it.)

Original lighting:

Vulkan.Samples_.Ray.queries.2024-10-26.13-10-08.mp4

Updated lighting:

Vulkan.Samples_.Ray.queries.2024-10-26.18-58-38.mp4
  • This PR has only been tested on Windows.
  • There are no related issues.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

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

Looks good to me.

And I like the light position better.

@SaschaWillems SaschaWillems self-requested a review October 28, 2024 18:07
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

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

LGTM. Always thought the lighting in that sample looked kinda off and any improvement to that part is welcome.

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.

3 participants