Jump to content

Textures in Vulkan


Josh

4,285 views

 Share

I finally got a textured surface rendering in Vulkan so we now have officially surpassed StarFox (SNES) graphics:

Untitled.thumb.png.f83d2ea65e0813ef1a46bf0f81032968.png

Although StarFox did have distance fog. ?

Star-Fox-Banner.jpg.45d228161bb92b6016a5557b43c7fc21.jpg

Vulkan uses a sort of "baked" graphics pipeline. Each surface you want to render uses an object you have to create in code that contains all material, texture, shader, and other settings. There is no concept of "just change this one setting" like in OpenGL. Consequently, the new renderer may be a bit more rigid than what Leadwerks 4 uses, in the interest of speed. For example, the idea of 2D drawing commands you call each frame is absolutely a no-go. (This was likely anyways, due to the multithreaded design.) A better approach for that would be to use persistent 2D primitive objects you create and destroy. I won't lose any sleep over this because our overarching design goal is performance.

Right now I have everything hard-coded and am using only one shader and one texture, in a single graphics pipeline object. Next I need to make this more dynamic so that a new graphics pipeline can be created whenever a new combination of settings is needed. A graphics pipeline object corresponds pretty closely to a material. I am leaning towards storing a lot of settings we presently store in texture files in material files instead. This does also resolve the problem of storing these extra settings in a DDS file. Textures become more of a dumb image format while material settings are used to control them. Vulkan is a "closer to the metal" API and that may pull the engine in that direction a bit. That's not bad.

I like using JSON data for file formats, so the new material files might look something like this:

{
    "material": {
        "color": "1.0, 1.0, 1.0, 1.0",
        "albedoMap": {
            "file": "brick01_albedo.dds",
            "addressModeU": "repeat",
            "addressModeV": "repeat",
            "addressModeW": "repeat",
            "filter": "linear"
        },
        "normalMap": {
            "file": "brick01_normal.dds",
            "addressModeU": "repeat",
            "addressModeV": "repeat",
            "addressModeW": "repeat",
            "filter": "linear"
        },
        "metalRoughnessMap": {
            "file": "brick01_metalRoughness.dds",
            "addressModeU": "repeat",
            "addressModeV": "repeat",
            "addressModeW": "repeat",
            "filter": "linear"
        },
        "emissiveMap": {
            "file": "brick01_emissive.dds",
            "addressModeU": "repeat",
            "addressModeV": "repeat",
            "addressModeW": "repeat",
            "filter": "linear"
        }
    }
}

Of course getting this to work in Vulkan required another mountain of code, but I am starting to get the hang of it.

  • Like 4
  • Upvote 1
 Share

5 Comments


Recommended Comments

5 minutes ago, Thirsty Panther said:

Are you still going to add PBR files to the new Engine?

What exactly are "PBR files"? 

  • Confused 1
Link to comment

Yes. Once I get the basics done all the work I did in OpenGL will transfer over easily because the same shaders can be used.

  • Like 3
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...