skyrim-community-shaders
skyrim-community-shaders copied to clipboard
feat: add Extended Translucency
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:
Anisotropic Fabric model:
Settings UI:
Future work:
- Allow per geometry to override the settings (Not sure about how to do this right now, using a used flag?)
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
👍 I'll be working on the new nif flags, thanks for the reference!
@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.
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.
Looks really good so far. Just a few minor performance related things and I think then it's probably good to go.
@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?
@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.
Please see https://github.com/doodlum/skyrim-community-shaders/blob/dev/package/Shaders/Common/Permutation.hlsli
Please see https://github.com/doodlum/skyrim-community-shaders/blob/dev/package/Shaders/Common/Permutation.hlsli
Updated for the refactored light flag :)
@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?
@doodlum @FlayaN @Jonahex Mind to re-review this :)
@doodlum @FlayaN @Jonahex Mind to re-review this :)
I will just busy atm
@doodlum
Back to Skyrim after Oblivion Re :)
This feature now just use 2 extra bit in Permutation::ExtraFeatureDescriptor, nolonger spawning extra graphs objects.
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.
This effect currently applies for any translucent materials by default, you can see the effect when you change the settings.
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:
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
Let me know if you have any questions or need any file for testing ;)
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.hlslis 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.
🪧 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
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
✅ A pre-release build is available for this PR: Download
@doodlum Fixed minor issues found by AI, and added support for UI refactoring.
✅ A pre-release build is available for this PR: Download
@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
@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 :)
Please also sync with the latest.
@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
@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 :)
✅ A pre-release build is available for this PR: Download
nice, also consider adding feature desc
😂 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 ;)
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 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 😭)
Ahh I remember now. We also simplified the format so all you need now is modid but this should be fine too.
@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.