skyrim-community-shaders icon indicating copy to clipboard operation
skyrim-community-shaders copied to clipboard

feat: add Extended Translucency

Open ArcEarth opened this issue 1 year ago • 11 comments
trafficstars

Hi, everyone, I am super excited to contribute to this great project! Please correct me if I got anything wrong :) I am a little constraint on time so may reply to things late.

Adding a new feature to control translucent material's opacity. The core changes is all in the HLSL side, where cpp changes just provide 3 setting variables.

Vanilla: vanilla Anisotropic Fabric model: fabric

Settings UI: settings

Future work:

  • Allow per geometry to override the settings (Not sure about how to do this right now, using a used flag?)

ArcEarth avatar Oct 21 '24 06:10 ArcEarth

This looks really interesting. It would be best to include this as an option in the JSON configs for True PBR like we did with the glints PR https://github.com/doodlum/skyrim-community-shaders/pull/413 that way different materials can have different translucency types, rather than every alpha effect getting this. Otherwise random translucent objects could look incorrect which would cause issues. True PBR actually has fabric models too, so could maybe implement that without even needed new config options. You would however need to convert assets to PBR to be able to test the model.

@Jonahex is in charge of all that

doodlum avatar Oct 21 '24 13:10 doodlum

👍 I'll be working on the new nif flags, thanks for the reference!

ArcEarth avatar Oct 21 '24 16:10 ArcEarth

@doodlum The settings are now detected from ExtraData node in the mesh's NIF. I find this being much stable than reusing a shading flag. image

Also, I kept the option to apply this effect to everything, so that existing assets can be improved from this feature immediately. People can use the setting to make it only apply to the opt-in mesh with the extra data :) Similarly, mesh can opt-out by setting the extra data to 0.

One future improvement is to make some TESForm based selection like using KID or alkies.

Besides, added another option 'Stregth' to the setting, which is essentially the blending weight (alpha) of this effect.

ArcEarth avatar Oct 27 '24 07:10 ArcEarth

Looks really good so far. Just a few minor performance related things and I think then it's probably good to go.

doodlum avatar Oct 27 '24 10:10 doodlum

@doodlum @Jonahex @FlayaN The new update make use of the cbuffer on slot 7 with immutable buffers that never update/map-unmap after creation. And we only have 5 of them in total. This design can avoid the expensive GPU resources update and synchronization and should be very performant. (DX11 will create new GPU buffer when mapped to write, if the current constant buffer is in use with the GPU, which looks like a common case in the codebase: the same constant buffer seems reused for different geometries and mapped to CPU to udpate before the draw) Wondering if you like the design or prefer merging this into the per-geometry buffer? And anything else I should address?

ArcEarth avatar Oct 29 '24 04:10 ArcEarth

@doodlum @Jonahex @FlayaN The new update make use of the cbuffer on slot 7 with immutable buffers that never update/map-unmap after creation. And we only have 5 of them in total. Wondering if you like the design or prefer merging this into the per-geometry buffer? And anything else I should address?

It is probably fine for now. Soon we will probably scrap all additional constant buffers. State switching and updates need to be minimised but it only matters when it affects a significant number of calls.

So two more things: Use fake enums in HLSL where possible, like we now do with shader flags. Link to any references used in the code.

doodlum avatar Oct 29 '24 04:10 doodlum

Please see https://github.com/doodlum/skyrim-community-shaders/blob/dev/package/Shaders/Common/Permutation.hlsli

doodlum avatar Oct 29 '24 11:10 doodlum

Please see https://github.com/doodlum/skyrim-community-shaders/blob/dev/package/Shaders/Common/Permutation.hlsli

Updated for the refactored light flag :)

ArcEarth avatar Oct 30 '24 04:10 ArcEarth

@doodlum Anything else to be addressed before we can merge? :)

Beside, wondering if we have some detail about the mod release process, if I or the team should upload the feature mod?

Also, the raw Lighting.hlsl edit can be release as a replacer for the current stable version of CS (without settings or nif settings), wondering if we should release it now or release it with the next version?

ArcEarth avatar Oct 31 '24 05:10 ArcEarth

@doodlum @FlayaN @Jonahex Mind to re-review this :)

ArcEarth avatar Nov 02 '24 04:11 ArcEarth

@doodlum @FlayaN @Jonahex Mind to re-review this :)

I will just busy atm

doodlum avatar Nov 04 '24 15:11 doodlum

@doodlum Back to Skyrim after Oblivion Re :) This feature now just use 2 extra bit in Permutation::ExtraFeatureDescriptor, nolonger spawning extra graphs objects.

ArcEarth avatar May 16 '25 04:05 ArcEarth

Nice, I'll review very soon. Ideally I'd have something I can use to test to see the feature works as stated, if anything just to show authors how to use it.

doodlum avatar May 17 '25 01:05 doodlum

This effect currently applies for any translucent materials by default, you can see the effect when you change the settings. image

Nif meshes can opt-in or opt-out of this effect with ExtraData AnisotropicAlphaMaterial. I added the extra data for one leg in Outfit studio: image

The testing equipment I am using is from Cosplay Pack Here is a prebuilt mesh with the extra data edit (it may be clipping depending on body slide settings). ExtendTranslucencyTest.zip Skyrim Special Edition 2025-05-17 10_18_02 AM

Let me know if you have any questions or need any file for testing ;)

ArcEarth avatar May 17 '25 17:05 ArcEarth

Walkthrough

This update introduces a new "Extended Translucency" feature to the rendering pipeline. It adds shader utilities, configuration, and runtime logic for handling advanced translucency effects, including anisotropic alpha materials. The implementation includes new shader code, configuration files, global integration, feature registration, buffer updates, UI controls, serialization support, and integration with the rendering pipeline via hooks.

Changes

File(s) Change Summary
features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli Added shader header with material model constants and functions for view-dependent alpha handling.
features/Extended Translucency/Shaders/Features/ExtendedTranslucency.ini Added configuration file specifying version for the new feature.
package/Shaders/Common/SharedData.hlsli Added ExtendedTranslucencySettings struct and integrated it into the shader feature data buffer.
src/Feature.cpp Registered ExtendedTranslucency in the feature list.
src/FeatureBuffer.cpp Included ExtendedTranslucency settings in the feature buffer data aggregation.
src/Features/ExtendedTranslucency.cpp, src/Features/ExtendedTranslucency.h Implemented and declared the ExtendedTranslucency feature class, with UI, serialization, and hooks.
src/Globals.cpp, src/Globals.h Declared and initialized a global pointer for ExtendedTranslucency.
src/State.h Added ETMaterialModel flag to the ExtraFeatureDescriptors enum.
src/Features/TerrainHelper.cpp Added a comment about updating texture slot constants if changed.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant ExtendedTranslucency
    participant State
    participant Shader

    User->>UI: Adjust translucency settings (ImGui)
    UI->>ExtendedTranslucency: Update MaterialParams
    ExtendedTranslucency->>State: Update global feature descriptor
    State->>Shader: Pass updated settings via buffer
    Shader->>Shader: Use new alpha/material model logic in rendering

Suggested reviewers

  • doodlum

Poem

In the world of glass and light,
A rabbit tweaks translucency just right.
With sliders and hooks,
And shader-bound looks,
Fabrics and rims now shimmer so bright!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b368cac9b08a9722aac883f800788a6cc5984012 and 1754485d3acdf4226594b40e77bd242520e32e83.

⛔ Files ignored due to path filters (1)
  • package/Shaders/Lighting.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (11)
  • features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli (1 hunks)
  • features/Extended Translucency/Shaders/Features/ExtendedTranslucency.ini (1 hunks)
  • package/Shaders/Common/SharedData.hlsli (2 hunks)
  • src/Feature.cpp (2 hunks)
  • src/FeatureBuffer.cpp (2 hunks)
  • src/Features/ExtendedTranslucency.cpp (1 hunks)
  • src/Features/ExtendedTranslucency.h (1 hunks)
  • src/Features/TerrainHelper.cpp (1 hunks)
  • src/Globals.cpp (3 hunks)
  • src/Globals.h (2 hunks)
  • src/State.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • features/Extended Translucency/Shaders/Features/ExtendedTranslucency.ini
  • src/Features/TerrainHelper.cpp
  • src/FeatureBuffer.cpp
  • src/State.h
  • src/Globals.h
  • package/Shaders/Common/SharedData.hlsli
  • src/Feature.cpp
  • src/Globals.cpp
  • features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli
  • src/Features/ExtendedTranslucency.cpp
  • src/Features/ExtendedTranslucency.h
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build plugin and addons
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar May 20 '25 06:05 coderabbitai[bot]

✅ A pre-release build is available for this PR: Download

github-actions[bot] avatar May 20 '25 06:05 github-actions[bot]

@doodlum Fixed minor issues found by AI, and added support for UI refactoring.

ArcEarth avatar May 24 '25 04:05 ArcEarth

✅ A pre-release build is available for this PR: Download

github-actions[bot] avatar May 24 '25 04:05 github-actions[bot]

@doodlum Here is a AIO package for testing. Please let me know if the one drive link does not work. https://1drv.ms/u/c/4a6ce604809201e9/ESNyIC6EYvNHhJIY5kGgS_gBW5_wM9zYivn5Mra5CzLfkw?e=uC4VTD

ArcEarth avatar May 25 '25 04:05 ArcEarth

@alandtse @doodlum Sorry for pinging, wondering if there are anything I can do to help the review process? I will need to travel around mid-June, and may not access the game for a month >_< Will be helpful if I can make changes before it :)

ArcEarth avatar Jun 06 '25 04:06 ArcEarth

Please also sync with the latest.

alandtse avatar Jun 06 '25 09:06 alandtse

@alandtse @doodlum Sorry for pinging, wondering if there are anything I can do to help the review process? I will need to travel around mid-June, and may not access the game for a month >_< Will be helpful if I can make changes before it :)

I am ill with COVID

doodlum avatar Jun 06 '25 11:06 doodlum

@alandtse Synched to the latest. Everything is still working. Sorry for replying late, was busy preparing my moving >_< @doodlum Hope you get a quick recovery! The community cannot go without you :)

ArcEarth avatar Jun 15 '25 18:06 ArcEarth

✅ A pre-release build is available for this PR: Download

github-actions[bot] avatar Jun 15 '25 19:06 github-actions[bot]

nice, also consider adding feature desc

jiayev avatar Jun 23 '25 15:06 jiayev

😂 Glad to see it's merged! Thank you a lot! 🎊 I'm travelling but will prepare the mod page and docs once I get a working pc ;)

ArcEarth avatar Jun 23 '25 20:06 ArcEarth

If you can get the link for the unpublished nexus page, we can update the link inside CS to cover it. We also can put in a short description if you provide some details.

alandtse avatar Jun 23 '25 20:06 alandtse

@alandtse That's amazing! Btw, I have already added the NexusURL/description in the feature's header file, following format in CS UI rework PR 😉 Let me know when you have a release schedule, I'll be preparing the mod page for it (hope i can find a PC soon 😭)

ArcEarth avatar Jun 23 '25 22:06 ArcEarth

Ahh I remember now. We also simplified the format so all you need now is modid but this should be fine too.

alandtse avatar Jun 23 '25 22:06 alandtse

@ArcEarth we've had a bug report https://github.com/doodlum/skyrim-community-shaders/issues/1230. We'd appreciate it if you did take a look. We're also on Discord if you're willing to join and we can speak there directly in the developers-only channel.

alandtse avatar Jul 03 '25 02:07 alandtse