Skip to content

Commit 5731459

Browse files
committed
Use implicit bindings
1 parent 4af4b34 commit 5731459

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

Content/core/shaders/pbr.mshdr

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,11 @@ Fragment
108108
{
109109
#define PI 3.14159265359
110110

111-
[[vk::binding(0, 0)]]
112-
[SrgbRead]
113-
Texture2D diffuseTexture;
114-
115-
[[vk::binding(1, 0)]]
116-
[Default(0.5f, 0.5f, 1.0f, 1.0f)]
117-
Texture2D normalTexture;
118-
119-
[[vk::binding(2, 0)]]
120-
[Default(1.0f, 1.0f, 1.0f, 1.0f)]
121-
Texture2D ambientOcclusionTexture;
122-
123-
[[vk::binding(3, 0)]]
124-
[Default(0.0f, 0.0f, 0.0f, 1.0f)]
125-
Texture2D metalnessTexture;
126-
127-
[[vk::binding(4, 0)]]
128-
[Default(1.0f, 1.0f, 1.0f, 1.0f)]
129-
Texture2D roughnessTexture;
130-
131-
[[vk::binding(5, 0)]]
111+
[SrgbRead, Default(1.0f, 0.0f, 1.0f, 1.0f)] Texture2D diffuseTexture;
112+
[Default(0.5f, 0.5f, 1.0f, 1.0f)] Texture2D normalTexture;
113+
[Default(1.0f, 1.0f, 1.0f, 1.0f)] Texture2D ambientOcclusionTexture;
114+
[Default(0.0f, 0.0f, 0.0f, 1.0f)] Texture2D metalnessTexture;
115+
[Default(1.0f, 1.0f, 1.0f, 1.0f)] Texture2D roughnessTexture;
132116
SamplerState samplerState;
133117

134118
float3 fresnelSchlick(float cosTheta, float3 F0)

Source/Mocha.Engine/Render/Assets/Material.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ public Material( string path )
4242
// load textures
4343
foreach ( var binding in requiredBindings )
4444
{
45-
if ( !Textures.ContainsKey( binding.Name ) && textureBindings.Data.ContainsKey( binding.Name ) )
45+
if ( !Textures.ContainsKey( binding.Name ) && textureBindings.Data.TryGetValue( binding.Name, out string? value ) )
4646
{
4747
bool isSrgb = binding.Attributes.Any( a => a.Type == ShaderReflectionAttributeType.SrgbRead );
4848

49-
Textures.Add( binding.Name, new Texture( textureBindings.Data[binding.Name], isSrgb ) );
49+
Textures.Add( binding.Name, new Texture( value, isSrgb ) );
5050
}
5151
}
5252

0 commit comments

Comments
 (0)