Vulkan sampler coordinates

Started by darkyellow, December 11, 2018, 06:28:32

Previous topic - Next topic

darkyellow

Hi

Vulkan uses U,V,W as sampler coordinates and opengl uses R,S,T. Would I be correct in saying the translation from one to the other is?

S -> U
T -> V
R - W

KaiHH

Vulkan itself has no notion of how the texture coordinates are called/named/accessed. Even SPIR-V does not have names for the texture coordinates components.
See for example: https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html#OpImageSampleImplicitLod
It is just a vector where the first component is the x dimension (however you'd like to call that dimension) and the second the y dimension and any further components depending on whether a 2D/3D or array texture is accessed and whether explicit LOD is used.
How the coordinates are actually named is specified via the frontend language you define your shaders in. If you use GLSL (which you can use for both OpenGL and SPIR-V/Vulkan) then you can use either xyzw or stpq or even rgba, it does not matter. They are all translated to the first, second, third and fourth vector component and just alias themselves.

darkyellow

Kai

Thanks for the reply, I am not sure I made myself clear though as it wasn't the answer I was looking for.

In opengl I set the wrap mode as follows

            GL33.glSamplerParameteri(samplerId, GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE);
            GL33.glSamplerParameteri(samplerId, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT;);
            GL33.glSamplerParameteri(samplerId, GL11.GL_TEXTURE_WRAP_T, GL13.GL_CLAMP_TO_BORDER);


in vulkan there is an equivilent part of the creation process

                 VkSamplerCreateInfo createInfoSampler = VkSamplerCreateInfo.calloc()
                     .sType(VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO)
                     .addressModeU(getWrapMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
                     .addressModeV(getWrapMode(VK_SAMPLER_ADDRESS_MODE_REPEAT)
                     .addressModeW(getWrapMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)


My question is how do I map the 2 so they are equivilent. I haven't applied any logical mappings in my examples above except for putting them in the same order which is arbitary.

KaiHH

Oh, I see. Yeah, OpenGL's S (first component), T (second component) and R (third component) maps to Vulkan's U (first component), V (second component), W (third component).

darkyellow

Thanks, this is exactly what I needed