Skip to content

Introducing V1 of the Material System #195

Description

@mrparmesan01

Task Overview

When vulkan-cpp V6 gets released, we can move over to descriptor indexing for fetching our images. This way we can have a huge storage for loading textures for variety of objects in a given scene.

GLSL Code

Rather then having sampler2D take up a descriptor slot or binding slot. We would have huge storage for loading our textures.

This is example shader pseudo-code in GLSL where I demonstrate some very basic usage for retrieving textures from the shaders.

#extension GL_EXT_nonuniform_qualifier : require

layout(set = 1, binding = 0) uniform sampler2D textures[];

// retrieve object specific properties
layout(push_constant) uniform GlobalUniform {
   mat4 model;
   int specular_index;
   int diffuse_index;
   int normal_index;
} ubo;


int main() {
   sampler2D specular = textures[ubo.specular_index];
   sampler2D diffuse = texture(ubo.diffuse_index];
   sampler2D normal = texture(ubo.normal_index];
   
   vec3 result = vec3(specular) * vec3(diffuse) * vec3(normal) ;

   result *= materialColor;

   outColor = vec4(result, 1.0); 
}

Task Completion Objective

We should be able to utilize indices to retrieve our textures without needing to perform any bindings to retrieve specific textures. Rather we use an index value to retrieve specific textures already loaded to the GPU.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementimproving something to be better💠coreCore architectural task with system-wide impacts.💳 Tech DebtTasks that have some kind of user API tech debt📐designDefine public API interfaces

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions