mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Now passing material index + buffer
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
[[vk::binding(0, 3)]]
|
||||
Texture2D<float3> myTexture : register(t1); // Texture binding at slot t0
|
||||
Texture2D<float3> albedo : register(t1); // Texture binding at slot t0
|
||||
|
||||
[[vk::binding(0, 4)]]
|
||||
SamplerState mySampler : register(s0); // Sampler binding at slot s0
|
||||
|
||||
struct Material
|
||||
{
|
||||
float hasAlbedo;
|
||||
float3 albedo;
|
||||
int hasNormal;
|
||||
int hasMetalness;
|
||||
int hasRoughness;
|
||||
int hasAO;
|
||||
float metalnessValue;
|
||||
float roughnessValue;
|
||||
float aoValue;
|
||||
};
|
||||
[[vk::binding(0, 5)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
struct PSInput {
|
||||
float4 Position : SV_Position;
|
||||
float3 Color : TEXCOORD0;
|
||||
@@ -14,13 +29,26 @@ struct PSInput {
|
||||
struct PSOutput {
|
||||
float4 oColor0 : SV_TARGET;
|
||||
float4 oNormal : SV_TARGET1;
|
||||
float4 oMaterial : SV_TARGET2;
|
||||
};
|
||||
|
||||
struct ModelPushConstant
|
||||
{
|
||||
int modelIndex; // Push constant data
|
||||
int materialIndex;
|
||||
};
|
||||
|
||||
[[vk::push_constant]]
|
||||
ModelPushConstant pushConstants;
|
||||
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
PSOutput output;
|
||||
float3 textureColor = myTexture.Sample(mySampler, input.UV);
|
||||
Material inMaterial = material[pushConstants.materialIndex];
|
||||
float3 textureColor = albedo.Sample(mySampler, input.UV);
|
||||
output.oColor0 = float4(textureColor, 1.0f);
|
||||
output.oNormal = float4(input.Normal, 1.0f);
|
||||
//output.oMaterial = float4(inMaterial.metalnessValue, inMaterial.aoValue, inMaterial.roughnessValue, 1.0f);
|
||||
output.oMaterial = float4(inMaterial.albedo.xyz, 1.0f);
|
||||
return output;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ StructuredBuffer<Vertex> vertexBuffer : register(t2);
|
||||
struct ModelPushConstant
|
||||
{
|
||||
int modelIndex; // Push constant data
|
||||
int materialIndex;
|
||||
};
|
||||
|
||||
[[vk::push_constant]]
|
||||
|
||||
Reference in New Issue
Block a user