Skip to content

Find a better system to handle empty texture properties (bindless textures?) #575

@adriengivry

Description

@adriengivry

Problem this feature should fix

Right now when a texture isn't provided on a material, a default texture is attached instead.

  • 2D texture: white pixel (255, 255, 255, 255)
  • Cubemap texture: black pixel (0, 0, 0, 0) for each face

Expected solution

We should implement a system to provide more options to shaders to choose what the default "no-texture set" behaviour should be.

We could either:

  • Not provide any texture, and let the shader check if a texture is passed using textureQueryLod(). If textureQueryLod() returns 0, no texture is bound, so a backup color/behaviour can be selected.
  • Let shader uniforms specify what type of default texture they require (similar to unity, were properties can define the color of the default texture): _MainTex("Texture",2D)="white"{}.

It could look like:

uniform sampler2D albedo; [default = "white"]

I'm leaning toward using textureQueryLod(), since the overhead should be minimal, and would give more control to the user. With the other method, we would need to define a fixed set of preset textures, while using textureQueryLod will let the user choose anything, or even branch out and skip a code-block completely. This would also reduce the amount of textures binds, which could potentially improve performance.

Edit: I think we should look into bindless textures!

Metadata

Metadata

Assignees

No one assigned

    Labels

    GraphicsGraphical feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions