Some textures are treated as depths under MoltenVK

Denis

Member
Messages
13
Reaction score
5

Game Version​

v2026.7.9.5018

Operating System​

macOS

What Happened​

With textures and shadows stored together under globalTextures, SPIRV-Cross incorrectly identifies textures2d as depth2d, causing 3 out of 4 values in vec4 to be lost. This results in incorrect clouds, planet colors, and possible issues with ground clutter.

What Was Expected​

Potential fix is to separate globalTextures into globalTextures and globalShadows (same goes with the arrays). If I'm not mistaken, if done in a shader, they should still point to the same objects. SPIRV-Cross, used by MoltenVK and is the reason for incorrect determination, would correctly separate the two into texture2d<float> and depth2d<float>. The change, theoretically, should be transparent to Windows/Linux users

Diff​

Code
diff --git a/Shaders/Common/TextureSet.glsl b/Shaders/Common/TextureSet.glsl
index 261a89f..8442e57 100644
--- a/Shaders/Common/TextureSet.glsl
+++ b/Shaders/Common/TextureSet.glsl
@@ -8,17 +8,19 @@
 #endif
 
 layout (set = SET_TEXTURE, binding = 0) uniform texture2D globalTextures[];
+layout (set = SET_TEXTURE, binding = 0) uniform texture2D globalShadows[];
 layout (set = SET_TEXTURE, binding = 0) uniform texture2DArray globalTextureArrays[];
+layout (set = SET_TEXTURE, binding = 0) uniform texture2DArray globalShadowsArray[];
 layout (set = SET_TEXTURE, binding = 0) uniform textureCube globalTextureCubes[];
 layout (set = SET_TEXTURE, binding = 1) uniform sampler samplers[];
 
 #define TEXTURE_SAMPLER(texID, samplerID) sampler2D(globalTextures[texID], samplers[samplerID])
 #define TEXTURE_ARRAY_SAMPLER(texID, samplerID) sampler2DArray(globalTextureArrays[texID], samplers[samplerID])
-#define SHADOW_ARRAY_SAMPLER(texID, samplerID) sampler2DArrayShadow(globalTextureArrays[texID], samplers[samplerID])
-#define SHADOW_SAMPLER(texID, samplerID) sampler2DShadow(globalTextures[texID], samplers[samplerID])
+#define SHADOW_ARRAY_SAMPLER(texID, samplerID) sampler2DArrayShadow(globalShadowsArray[texID], samplers[samplerID])
+#define SHADOW_SAMPLER(texID, samplerID) sampler2DShadow(globalShadows[texID], samplers[samplerID])
 
 #define SAMPLE_TEXTURE(texID, samplerID, uv) texture(TEXTURE_SAMPLER(texID, samplerID), uv)
 #define SAMPLE_ARRAY_TEXTURE(texID, samplerID, uvLayer) texture(TEXTURE_ARRAY_SAMPLER(texID, samplerID), uvLayer)
 #define GATHER_TEXTURE(texID, samplerID, uv, comp) textureGather(TEXTURE_SAMPLER(texID, samplerID), uv, comp)
Including before and after change screenshots
 

Attachments

  • AfterTextureSetChange.png
    AfterTextureSetChange.png
    1.4 MB · Views: 0
  • BeforeTextureSetChange.png
    BeforeTextureSetChange.png
    1.6 MB · Views: 0
Upvote 2
Does this also fix the problem with the water?
I'm not completely sure which problem with the water you're observing. There used to be a problem with it with older MoltenVK versions. Just need to make sure you're compiling/building the latest MoltenVK from their main branch. With an apple chip Mac, and enough RAM, (aside from occasional ground clutter issues) everything should be looking pretty much the same as Windows/Linux currently
 
I'm not completely sure which problem with the water you're observing. There used to be a problem with it with older MoltenVK versions. Just need to make sure you're compiling/building the latest MoltenVK from their main branch. With an apple chip Mac, and enough RAM, (aside from occasional ground clutter issues) everything should be looking pretty much the same as Windows/Linux currently
Oh nice I will try it. Last time I have tried in August I was never able to get water rendered correctly. Thanks for the hint. May I ask are you running it with Crossover?
 
Oh nice I will try it. Last time I have tried in August I was never able to get water rendered correctly. Thanks for the hint. May I ask are you running it with Crossover?
I use Sikarugir. Can confirm that using the latest "Template/Wrapper" 1.0.21, with the WS11Sikarugir11.0_1 engine, the game is running decent. I use "Default Render: DirectX to Metal translation layer - (DXMT)". You want to take the libMoltenVK.dylib that you've built from the MVK repo with Xcode (don't forget to "fetchDependencies" first too), and replace the one in Contents/Frameworks of the wrapper with it. I also had to "fake" the Contents/Resources/vulkan/icd.d/kosmickrisp_mesa_icd.json to point to libMoltenVK.dylib instead of libvulkan_kosmickrisp.dylib in order for MVK to be used. Feel free to DM me on Discord (denis_k15 in KSA) if you run into any issues and I'll try to help!
 
Back
Top