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

More options for min filter in game.project->Graphics->Default Texture Min Filter #8528

Merged
merged 10 commits into from Feb 23, 2024

Conversation

AGulev
Copy link
Contributor

@AGulev AGulev commented Feb 11, 2024

Now, the field Default Texture Min Filter in game.project -> Graphics has the same options as materials do.
This is a breaking change for projects that use mipmaps on their textures and the OpenGL graphics backend.

Old behavior was:

  • Options linear and nearest as Default Texture Min Filter meant TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST and TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST respectively.
  • If a texture without mipmaps was used with a material where Min Filter was specified with mipmaps, it used the Mag Filter option instead.

Current behavior:

  • Options linear and nearest as Default Texture Min Filter mean TEXTURE_FILTER_LINEAR and TEXTURE_FILTER_NEAREST respectively.
  • If a texture without mipmaps is used with a material where Min Filter is specified with mipmaps, it simply ignores the mipmaps part of the filter. For example, for TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST, it will be TEXTURE_FILTER_LINEAR, etc.

Fix #8443

PR checklist

  • Code
    • Add engine and/or editor unit tests.
    • New and changed code follows the overall code style of existing code
    • Add comments where needed
  • Documentation
    • Make sure that API documentation is updated in code comments
    • Make sure that manuals are updated (in github.com/defold/doc)
  • Prepare pull request and affected issue for automatic release notes generator
    • Pull request - Write a message that explains what this pull request does. What was the problem? How was it solved? What are the changes to APIs or the new APIs introduced? This message will be used in the generated release notes. Make sure it is well written and understandable for a user of Defold.
    • Pull request - Write a pull request title that in a sentence summarises what the pull request does. Do not include "Issue-1234 ..." in the title. This text will be used in the generated release notes.
    • Pull request - Link the pull request to the issue(s) it is closing. Use on of the approved closing keywords.
    • Affected issue - Assign the issue to a project. Do not assign the pull request to a project if there is an issue which the pull request closes.
    • Affected issue - Assign the "breaking change" label to the issue if introducing a breaking change.
    • Affected issue - Assign the "skip release notes" is the issue should not be included in the generated release notes.

Example of a well written PR description:

  1. Start with the user facing changes. This will end up in the release notes.
  2. Add one of the GitHub approved closing keywords
  3. Optionally also add the technical changes made. This is information that might help the reviewer. It will not show up in the release notes. Technical changes are identified by a line starting with one of these:
    1. ### Technical changes
    2. Technical changes:
    3. Technical notes:
There was a anomaly in the carbon chroniton propeller, introduced in version 8.10.2. This fix will make sure to reset the phaser collector on application startup.

Fixes #1234

### Technical changes
* Pay special attention to line 23 of phaser_collector.clj as it contains some interesting optimizations
* The propeller code was not taking into account a negative phase.

@AGulev AGulev added the breaking change Issue introducing a breaking change label Feb 11, 2024
@AGulev AGulev requested a review from Jhonnyg February 11, 2024 11:14
@AGulev
Copy link
Contributor Author

AGulev commented Feb 11, 2024

editor/resources/meta.edn Outdated Show resolved Hide resolved
matgis
matgis previously approved these changes Feb 12, 2024
Copy link
Contributor

@matgis matgis left a comment

Choose a reason for hiding this comment

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

Editor changes look good!

Jhonnyg
Jhonnyg previously approved these changes Feb 21, 2024
Copy link
Contributor

@Jhonnyg Jhonnyg left a comment

Choose a reason for hiding this comment

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

LGTM, have you tested this on vulkan?

@AGulev
Copy link
Contributor Author

AGulev commented Feb 21, 2024

LGTM, have you tested this on vulkan?

No, but In vulkan we have this logic which is right:

// Convert minfilter to Vulkan type, the conversions are
// taken from https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkSamplerCreateInfo.html
// and should match the OpenGL functionality.
if (minfilter == TEXTURE_FILTER_NEAREST)
{
vk_min_filter = VK_FILTER_NEAREST;
max_lod = 0.25f;
}
else if (minfilter == TEXTURE_FILTER_LINEAR)
{
vk_min_filter = VK_FILTER_LINEAR;
max_lod = 0.25f;
}
else if (minfilter == TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST)
{
vk_min_filter = VK_FILTER_NEAREST;
}
else if (minfilter == TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST)
{
vk_min_filter = VK_FILTER_LINEAR;
}
else if (minfilter == TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR)
{
vk_min_filter = VK_FILTER_NEAREST;
vk_mipmap_mode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
}
else if (minfilter == TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR)
{
vk_min_filter = VK_FILTER_LINEAR;
vk_mipmap_mode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
}
else
{
assert(0 && "Unsupported type for min filter");
}

(.equalsIgnoreCase "nearest_mipmap_nearest" s) gl/nearest-mipmap-nearest
(.equalsIgnoreCase "nearest_mipmap_linear" s) gl/nearest-mipmap-linear
(.equalsIgnoreCase "linear_mipmap_nearest" s) gl/linear-mipmap-nearest
(.equalsIgnoreCase "linear_mipmap_linear" s) gl/linear-mipmap-linear
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed that the same logic should be added for the editor. I added new filter types in filter parser, but now Editor should behave the same as runtime:
if mipmaps turned off for the atlas, non-mipmap filter should be picked autimatically.

@AGulev
Copy link
Contributor Author

AGulev commented Feb 22, 2024

I 99% sure that this one fixed as well now #4055
At least now I see the difference depend on if I turn mipmaps on and off, but without this fix (current released version) if I turn mipmaps on once - it is always on

@AGulev AGulev merged commit 079e7dd into dev Feb 23, 2024
22 checks passed
@AGulev AGulev deleted the issue-8443 branch February 23, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Issue introducing a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing LINEAR min filter in game.project
3 participants