Vulkan sampler coordinates

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

Previous topic - Next topic



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


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:
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.



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()

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.


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).


Thanks, this is exactly what I needed