@@ -27,49 +27,43 @@ layout (location = 3) out vec2 velocityTarget;
2727
2828layout (set = 1 , binding = 0 ) uniform Addresses
2929{
30- MaterialData materialBufferDeviceAddress;
31- ModelData modelBufferDeviceAddress;
30+ Instances instances;
31+ Models models;
32+ PrimitiveData primitives;
33+ Materials materials;
34+
3235} bufferAddresses;
3336
3437layout (set = 2 , binding = 0 ) uniform sampler samplers[];
3538layout (set = 2 , binding = 1 ) uniform texture2D textures[];
3639
3740void main() {
38- Material m = bufferAddresses.materialBufferDeviceAddress. materials[inMaterialIndex];
41+ Material material = bufferAddresses.materials.materialArray [inMaterialIndex];
3942 vec4 albedo = vec4 (1 .0f);
4043
41- int colorSamplerIndex = m .textureSamplerIndices.x;
42- int colorImageIndex = m .textureImageIndices.x;
44+ int colorSamplerIndex = material .textureSamplerIndices.x;
45+ int colorImageIndex = material .textureImageIndices.x;
4346 if (colorSamplerIndex > - 1 && colorImageIndex > - 1 ) {
44- vec2 colorUv = inUV * m .colorUvTransform.xy + m .colorUvTransform.zw;
47+ vec2 colorUv = inUV * material .colorUvTransform.xy + material .colorUvTransform.zw;
4548 albedo = texture(sampler2D (textures[nonuniformEXT(colorImageIndex)], samplers[nonuniformEXT(colorSamplerIndex)]), colorUv);
4649 }
47- // albedo = albedo * inColor * m.colorFactor;
48-
49- // Look into custom shaders specifically for these? More draw commands vs branching...
50- // 1 is transparent blend type
51- if (m.alphaProperties.y == 1 ) {
52- // Draw only if alpha is close enough to 1
53- if (albedo.w <= 1.0 - TRANSPARENT_ALPHA_EPSILON) {
54- discard ;
55- }
56- }
50+ albedo = albedo * inColor * material.colorFactor;
5751
5852 // 2 is "mask" (cutout) blend type
59- if (m .alphaProperties.y == 2 ){
60- // 2 is "mask" blend type
61- if (albedo.w < m .alphaProperties.x){
53+ if (material .alphaProperties.y == 2 ){
54+ // x is the cutout value (if any)
55+ if (albedo.w < material .alphaProperties.x){
6256 discard ;
6357 }
6458 }
6559
66- int metalSamplerIndex = int (m .textureSamplerIndices.y);
67- int metalImageIndex = int (m .textureImageIndices.y);
60+ int metalSamplerIndex = int (material .textureSamplerIndices.y);
61+ int metalImageIndex = int (material .textureImageIndices.y);
6862
69- float metallic = m .metalRoughFactors.x;
70- float roughness = m .metalRoughFactors.y;
63+ float metallic = material .metalRoughFactors.x;
64+ float roughness = material .metalRoughFactors.y;
7165 if (metalSamplerIndex > - 1 && metalImageIndex > - 1 ) {
72- vec2 metalRoughUv = inUV * m .metalRoughUvTransform.xy + m .metalRoughUvTransform.zw;
66+ vec2 metalRoughUv = inUV * material .metalRoughUvTransform.xy + material .metalRoughUvTransform.zw;
7367 vec4 metalRoughSample = texture(sampler2D (textures[nonuniformEXT(metalImageIndex)], samplers[nonuniformEXT(metalSamplerIndex)]), metalRoughUv);
7468 metallic *= metalRoughSample.b;
7569 roughness *= metalRoughSample.g;
0 commit comments