-
Notifications
You must be signed in to change notification settings - Fork 54
Developers
This is the base package that loads all the custom shaders.
This is the main dll in the repo that enables the replacement of vanilla shaders with new shaders.
Can be found primarily in https://github.com/doodlum/skyrim-community-shaders/tree/main/src
The default shaders will be found in https://github.com/doodlum/skyrim-community-shaders/tree/main/package/Shaders.
These default shaders should be overwritten by feature specific shaders.
These are custom features that are loaded after the default CS install.
To add a new feature, the DLL needs to be modified. See prior examples of adding new features for the full list. https://github.com/doodlum/skyrim-community-shaders/pull/83
The main features should live here: https://github.com/doodlum/skyrim-community-shaders/tree/dev/src/Features
- GetName
- Used in ImGui feature list and json entry per feature
- GetShortName
- Used for ini loading (No spaces usually)
- SetupResources
- Called once in startup
- Reset
- Called once per frame
- DrawSettings
- Used for rendering imgui
- Draw
- Normal rendering code here
- Save
- Serialize settings to json
- RestoreDefaultSettings
- Reset feature settings to default value
- Load
- Deserialize settings from json, also need to call
Feature::Load
after loading
- Deserialize settings from json, also need to call
These are already default defined in Feature.h but can be overriden if you need to do something extra like defined below
- GetShaderDefineName
- used as an additional macro added when compiling shaders specified by HasShaderDefine, if the feature is loaded
- HasShaderDefine
- if a shader type returns true, then GetShaderDefineName macro is added to its compilation, if the feature is loaded
- DrawDeferred
- This one is not called yet, that is in the subsurface-scattering branch
- DataLoaded
- Called by SKSE
kDataLoaded
event
- Called by SKSE
- PostPostLoad
- Called by SKSE
kPostPostLoad
event
- Called by SKSE
- ClearShaderCache
- Called by imgui clear shader cache button
Shaders are stored in https://github.com/doodlum/skyrim-community-shaders/tree/dev/features
To debug CS you will need to be able to debug both the cpp dll and the hlsl shader files.
- Save a copy of the original exe so you can replace it.
- Use Steamless to strip the SteamDRM from the Skyrim.exe. This is required for a debugger to attach.
Make sure to check
Keep Bind Section
in steamless, game will not boot without it.
To ensure addresses don't move, disable ASLR. This can be done with CFF Explorer. Optional Header
-> DLL Characteristics
-> DLL can move
. Disable this.
Renderdoc can be used to debug shaders.
- Disable incompatible features:
- Skyrim Upscaler
- reshade
- Frame Generation - Advanced -> Disable At Boot
-
Optional Enable Global Hooking. Make sure to
Enable Global Hook
which will grey out all settings. This also will prevent closing renderdoc until you disable the setting. - Set up
Launch Application
so it will find the skse.exe (or Skyrim.exe if global hooking) when it launches.
- Launch Skyrim. You will know RenderDoc has connected because of the message in the top left of Skyrim
Capturing D3D11
. If it doesn't show, try toggling the global hook and launching again.
- Enable Developer Mode. Developer Mode can be enabled by setting the
Advanced Settings
->Log Level
toTRACE
orDEBUG
.
- Enable
Advanced
->Extended Frame Annotations
to help populate info in the rendering process.
-
Clear Shader Cache and Disk Cache. This is necessary to save debug information in the shaders to access named buffers/hlsl in renderdoc.
-
In game, press
F12
to capture the scene. -
In Renderdoc,
File
->Attach to Running Instance
. Select Skyrim andConnect to App
.
- Once attached, a new tab will appear. Double click any captures to load.
- You can verify you are seeing debug information by opening up the Pipeline tab and checking the Vertex or Pixel shaders. The resources should be named. In this case, we're getting
water.hlsl
data.
It is possible to block individual shaders in game to find a faulty shader.
- Find the faulty mesh in game. Confirm the mesh is caused by CS by toggling CS using the
Toggle Effects Key
(defaultNumpad *
). The faulty mesh should disappear. If it doesn't, it's a Vanilla bug. This is an example with CS disabled:
CS Enabled showing faulty mesh (note texture is missing in red circle):
- Enable Developer Mode. Developer Mode can be enabled by setting the
Advanced Settings
->Log Level
toTRACE
orDEBUG
.
- Hit the
PageUp
orPageDown
to cycle all active shaders until the faulty mesh disappears. This should match the vanilla shader.
- [Optional] Stop blocking shaders by clicking on the
Advanced Settings
->Stop Blocking Shaders
button. This should also flush the log and also provide a noticeable log entry to identify the last shader blocked. This button only appears when shaders are being blocked.
- Review the CommunityShaders.log file. The blocked shader should be the last entry before
Stopped blocking shaders
(from step 4). In the example below, the ID/descriptor is12000004
and it is a Lighting/Vertex shader, with the compile options ofWETNESS_EFFECTS LIGHT_LIMIT_FIX COMPLEX_PARALLAX_MATERIALS DYNAMIC_CUBEMAPS LODLANDNOISE LODLANDSCAPE MODELSPACENORMALS SHADOWSPLITCOUNT=3
. With this information, we can look atlighting.hlsl
to figure out what hlsl is active.
[2023-11-20 19:09:59.451] [debug] [33112] [ShaderCache.cpp:1557] Blocking shader (6/93) Lighting:Vertex:WETNESS_EFFECTS LIGHT_LIMIT_FIX COMPLEX_PARALLAX_MATERIALS DYNAMIC_CUBEMAPS LODLANDNOISE LODLANDSCAPE MODELSPACENORMALS SHADOWSPLITCOUNT=3
[2023-11-20 19:09:59.451] [debug] [33112] [ShaderCache.cpp:1209] Skipping blocked shader 12000004:Lighting:Vertex:WETNESS_EFFECTS LIGHT_LIMIT_FIX COMPLEX_PARALLAX_MATERIALS DYNAMIC_CUBEMAPS LODLANDNOISE LODLANDSCAPE MODELSPACENORMALS SHADOWSPLITCOUNT=3 total: 1
[2023-11-20 19:10:10.734] [debug] [33112] [ShaderCache.cpp:1568] Stopped blocking shaders
For comparison, if we block the corresponding Pixel shader, the coloring will be distorted instead which is revealed to be ID/descriptor 12000005
which is the Lighting:Pixel shader.
[2023-11-20 23:07:17.546] [debug] [70860] [ShaderCache.cpp:1537] Blocking shader (24/97) Lighting:Pixel:WETNESS_EFFECTS LIGHT_LIMIT_FIX COMPLEX_PARALLAX_MATERIALS DYNAMIC_CUBEMAPS LODLANDNOISE LODLANDSCAPE MODELSPACENORMALS SHADOWSPLITCOUNT=3 VC
[2023-11-20 23:07:17.564] [debug] [74308] [ShaderCache.cpp:1243] Skipping blocked shader 12000005:Lighting:Pixel:WETNESS_EFFECTS LIGHT_LIMIT_FIX COMPLEX_PARALLAX_MATERIALS DYNAMIC_CUBEMAPS LODLANDNOISE LODLANDSCAPE MODELSPACENORMALS SHADOWSPLITCOUNT=3 VC total: 1