Skip to content

Fix placeholder SMAA LUTs#24398

Open
redstrate wants to merge 1 commit into
bevyengine:mainfrom
redstrate:work/josh/bevy-fix-smaa-lut
Open

Fix placeholder SMAA LUTs#24398
redstrate wants to merge 1 commit into
bevyengine:mainfrom
redstrate:work/josh/bevy-fix-smaa-lut

Conversation

@redstrate
Copy link
Copy Markdown

@redstrate redstrate commented May 22, 2026

Objective

With the placeholder SMAA LUTs in place (for context that's without the smaa_luts feature) you couldn't actually use them because backends like Vulkan will scream things like:

Texture binding 2 expects dimension = D2, but given a view with dimension = D3

This is because the LUTs weren't generated within this crate, but re-uses the LUT placeholder function from the tonemapping crate. While that may work there, the SMAA LUTs aren't 3D (hence the mysterious third dimension entering the picture here.)

Solution

I moved a copy of this function instead, modifying it to provide a 2D image instead.

Testing

Enable the bevy_anti_alias feature (while NOT enabling the smaa_luts one), and then configure your Camera to add the Smaa type. I tested it on the Vulkan backend (Linux and Android) but I think the other ones fail too.

With the placeholder SMAA LUTs in place (for context that's without the
"smaa_luts" feature) you couldn't actually use them because backends
like Vulkan will scream things like:

Texture binding 2 expects dimension = D2, but given a view with dimension = D3

This is because the LUTs weren't generated within this crate, but
re-uses the LUT placeholder function from the tonemapping crate. While
that may work there, the SMAA LUTs aren't 3D (hence the mysterious third
dimension entering the picture here.) I moved a copy of this function
instead, modifying it to provide a 2D image instead.
@github-actions
Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering May 23, 2026
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

I tested this by running the anti_aliasing example after removing the smaa_luts feature from the 3d_api feature temporarily in Cargo.toml. I am able to reproduce on main (switching to SMAA results in a crash with 2d/3d error message). Using the logic in this PR prevents it from crashing.

Instead of copying and pasting, you could instead modify the lut_placeholder function to take a TextureDimension argument, and have smaa use D2 while tonemapping uses D3. That might be personal preference though, since I don’t really like copy-paste unless I have to.


let format = TextureFormat::Rgba8Unorm;
let data = vec![255, 0, 255, 255];
let handle = images.add(Image {
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 May 23, 2026

Choose a reason for hiding this comment

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

If you want to keep the copy/paste and to help prevent people from asking “why isn’t this using lut_placeholder"

Suggested change
let handle = images.add(Image {
// using lut_placeholder() instead would result in warnings
// the smaa placeholder needs to be a 2d texture
let handle = images.add(Image {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 23, 2026
@redstrate
Copy link
Copy Markdown
Author

redstrate commented May 24, 2026

Instead of copying and pasting, you could instead modify the lut_placeholder function to take a TextureDimension argument, and have smaa use D2 while tonemapping uses D3. That might be personal preference though, since I don’t really like copy-paste unless I have to.

I'll try that tomorrow, it did cross my mind but I didn't know if modifying that function made sense!

Copy link
Copy Markdown
Member

@beicause beicause left a comment

Choose a reason for hiding this comment

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

Instead of copying and pasting, you could instead modify the lut_placeholder function to take a TextureDimension argument, and have smaa use D2 while tonemapping uses D3. That might be personal preference though, since I don’t really like copy-paste unless I have to.

I don't think lut_placeholder function is meant to be reused. Creating Image here is OK as it is meant to be used for smaa.

size: Extent3d::default(),
format,
dimension: TextureDimension::D2,
label: None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Label it please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants