Skip to content

Commit

Permalink
Use implicit bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
xezno committed Dec 23, 2024
1 parent 4af4b34 commit 5731459
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
26 changes: 5 additions & 21 deletions Content/core/shaders/pbr.mshdr
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,11 @@ Fragment
{
#define PI 3.14159265359

[[vk::binding(0, 0)]]
[SrgbRead]
Texture2D diffuseTexture;

[[vk::binding(1, 0)]]
[Default(0.5f, 0.5f, 1.0f, 1.0f)]
Texture2D normalTexture;

[[vk::binding(2, 0)]]
[Default(1.0f, 1.0f, 1.0f, 1.0f)]
Texture2D ambientOcclusionTexture;

[[vk::binding(3, 0)]]
[Default(0.0f, 0.0f, 0.0f, 1.0f)]
Texture2D metalnessTexture;

[[vk::binding(4, 0)]]
[Default(1.0f, 1.0f, 1.0f, 1.0f)]
Texture2D roughnessTexture;

[[vk::binding(5, 0)]]
[SrgbRead, Default(1.0f, 0.0f, 1.0f, 1.0f)] Texture2D diffuseTexture;
[Default(0.5f, 0.5f, 1.0f, 1.0f)] Texture2D normalTexture;
[Default(1.0f, 1.0f, 1.0f, 1.0f)] Texture2D ambientOcclusionTexture;
[Default(0.0f, 0.0f, 0.0f, 1.0f)] Texture2D metalnessTexture;
[Default(1.0f, 1.0f, 1.0f, 1.0f)] Texture2D roughnessTexture;
SamplerState samplerState;

float3 fresnelSchlick(float cosTheta, float3 F0)
Expand Down
4 changes: 2 additions & 2 deletions Source/Mocha.Engine/Render/Assets/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public Material( string path )
// load textures
foreach ( var binding in requiredBindings )
{
if ( !Textures.ContainsKey( binding.Name ) && textureBindings.Data.ContainsKey( binding.Name ) )
if ( !Textures.ContainsKey( binding.Name ) && textureBindings.Data.TryGetValue( binding.Name, out string? value ) )
{
bool isSrgb = binding.Attributes.Any( a => a.Type == ShaderReflectionAttributeType.SrgbRead );

Textures.Add( binding.Name, new Texture( textureBindings.Data[binding.Name], isSrgb ) );
Textures.Add( binding.Name, new Texture( value, isSrgb ) );
}
}

Expand Down

0 comments on commit 5731459

Please sign in to comment.