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

[ShaderSwapper] Material name inclusion and exclusion rules based resolution #288

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

Petraller
Copy link
Contributor

Added new feature to ShaderSwapper for swapping a shader to different shaders depending on the material name. Backward compatibility with old config file is maintained.

Example config file snippet:

<ShaderSwapper>
  <!-- Old structure for "Mapping" element, still supported -->
  <Mapping From="Shader Forge/main_skin" To="xukmi/SkinPlus">

  <!-- New structure for "Mapping" element, keep the old "From" attribute... -->
  <Mapping From="Shader Forge/main_skin">
    <!-- ...but introduce a "Rule" element to replace the "To" attribute -->
    <Rule Name="xukmi/SkinPlus" />
  </Mapping>

  <!-- Advanced usage, with includes and excludes -->
  <Mapping From="original_shader">
    <!-- Change to shader_0 if the material name is material_0 or material_1... -->
    <Rule Name="shader_0">
      <Include>
        <Entry>material_0</Entry>
        <Entry>material_1</Entry>
      </Include>
    </Rule>

    <!-- ...else, change to shader_1 if the material name is NOT material_2 or material_3... -->
    <Rule Name="shader_1">
      <Exclude>
        <Entry>material_2</Entry>
        <Entry>material_3</Entry>
      </Exclude>
    </Rule>

    <!-- ...else, change to shader_2 -->
    <Rule Name="shader_2" />
  </Mapping>
</ShaderSwapper>

Copy link
Contributor

@ManlyMarco ManlyMarco left a comment

Choose a reason for hiding this comment

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

Code looks good, maybe just needs some summary comments on a few methods.

The kinds of rules could be expanded a lot but it's fine if you don't want to do it for this PR.

src/ShaderSwapper.Core/ShaderSwapper.cs Outdated Show resolved Hide resolved
src/ShaderSwapper.Core/ShaderSwapper.cs Show resolved Hide resolved
src/ShaderSwapper.Core/ShaderSwapper.cs Outdated Show resolved Hide resolved
@ManlyMarco
Copy link
Contributor

@Njaecha

Petraller and others added 3 commits September 29, 2024 14:43
Copy link
Contributor

@Njaecha Njaecha left a comment

Choose a reason for hiding this comment

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

LGTM and back to BG3...
Jokes aside: Tested and approved!
The configuration might be a bit complicated to understand for the common Koi user though. But I don't have any improvement ideas for that except maybe a tool that helps you write the config.

@ManlyMarco ManlyMarco merged commit c3411d6 into IllusionMods:master Sep 30, 2024
@ManlyMarco
Copy link
Contributor

Thanks for the PR! I guess the readme should be updated too now.

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