Vulkan Texture Coordinate on the spec

Hi. I tried to find the specification on Vulkan Texture Coordinate.

I think the specification is not clear.

At first, I tried to look over the latest specification of Vulkan 1.1, here.
Chapter 15.1 is “Image Operations Overview”, and it has 15.1.1 “Texel Coordinate System” part.

the spec said that

Normalized texel coordinates:

  • The s coordinate goes from 0.0 to 1.0.
  • The t coordinate goes from 0.0 to 1.0.


it does not specify the origin of the texture coordinate. I mean the direction of ‘s’ and ‘t’.
the graph in the part shows the arrow direction.

However, When I found the old specification of Vulkan

it does specify the directions like :
Normalized texel coordinates:

  • The s coordinate goes from 0.0 to 1.0, left to right.
  • The t coordinate goes from 0.0 to 1.0, top to bottom.

and the graph shows the arrows of ‘t’ coordinate with the inverted direction compared to 1.1 spec.
So, This make me confused with texture coordinate.

I experimented my vulkan application to verify the texture coordinate by myself.
I found The result is the texture coordinate origin of the Vulkan is Top-left.
s coordinate goes from 0.0 to 1.0, left to right
t coordinate goes from 0.0 to 1.0, top to bottom.

the experiment consists of a simple offscreen rendering and swap chain buffer with screen quad.

I construct the positions and texture coordinate of the screen quad based on GL coordinates like:

float vertices[] =
	// positions  texCoords
	-1.0f,  1.0f, 0.0f, 1.0f,
	-1.0f, -1.0f, 0.0f, 0.0f,
	 1.0f,  1.0f, 1.0f, 1.0f,
	 1.0f, -1.0f, 1.0f, 0.0f,

uint16 indices[] =
	0, 1, 2,
	2, 1, 3

and the vulkan vertex shader is…

#version 310 es
precision mediump float;

// Screen Quad Vertex Shader

layout (location = 0) in vec2 a_Position;
layout (location = 1) in vec2 a_TexCoord;

layout (location = 0) out vec2 v_TexCoord;

void main()
	gl_Position = vec4(a_Position.x, a_Position.y, 0.0, 1.0);
	gl_Position.y = -gl_Position.y;
	gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;

	v_TexCoord = a_TexCoord;

    // When I comment out this line, the offscreen texture become upside down
	v_TexCoord.y = 1.0 - v_TexCoord.y; 

So, I have questions…:

  1. Is the texture coordinate which i found with my experiment right?
  2. If so, why does the spec 1.1 show upward ‘t’ coordinate direction?

I always appreciate the ones who help me…

IIRC it was rewriten in the spec, because I mean, which way is “up”?

It is obvious for a Monitor. But if you only have stream of bytes in the memory?
Coordinates simply go from 0 to width\height. There’s no left-right direction, there’s no up-down direction. I mean, does C++ array index go from “left to right”, or “right to left”? The question itself would not make sense.

1 Like

But that doesn’t explain the picture.

1 Like

The diagram uses scientific\math conventions?
It would be equally valid no matter which direction the axis span on the page, no?

1 Like

PS: I found the discussions if curious. Here goes: Vulkan-Docs#876

1 Like

Sorry for being late. I got the summer vacation.

My background on using Graphics API is based on OpenGL. And I learned that the OpenGL has Left-Bottom Texture Coordinate Origin. That’s the reason why I thought there would be a texture coordinate on Vulkan too. But after contemplating your advice, you’re right. Texture colors are just memories. Texture Coordinate also memories. I didn’t even think about the basic of texturing. and that made me confused with this topic.

Plus, Thank you for sharing the spec history!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.