Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the coordinate system used in metal?

Tags:

metal

metalkit

In metal what coordinate system to use inside shader (in and out)? and when we render to texture is it the same? with the z buffer also? Are there any inconsistencies? finally what are the difference between metal, opengl and directX ?

like image 804
zeus Avatar asked Nov 04 '19 22:11

zeus


People also ask

How is a coordinate system used?

A coordinate system is a method for identifying the location of a point on the earth. Most coordinate systems use two numbers, a coordinate, to identify the location of a point. Each of these numbers indicates the distance between the point and some fixed reference point, called the origin.

What is the coordinate system for OpenGL?

The coordinate system used in OpenGL is right hand coordinate. Different from the 3D coordinate that we learned from math, the y axis is up and the positive z axis points towards the viewer.

Which co ordinate system is known as camera coordinate system?

Viewpoint Coordinate System - Also known as the "camera" coordinate system.


1 Answers

Metal Coordinate Systems

Metal defines several standard coordinate systems to represent transformed graphics data at different stages along the rendering pipeline.


1) NDC (Normalized Device Coordinate): this coordinates is used by developers to construct their geometries and transform the geometries in vertex shader via model and view matrices.
Point(-1, -1) in NDC is located at the the bottom left corner (Y up).. enter image description here


2) Framebuffer Coordinate (Viewport coordinate): when we write into attachment or read from attachment or copy/blit between attachments, we use framebuffer coordiante to specify the location. The origin(0, 0) is located at the top-left corner (Y down). enter image description here


3) Texture Coordinate: when we upload texture into memory or sample from texture, we use texture coordinate. The origin(0, 0) is located at the top-left corner (Y down). enter image description here


D3D12 and Metal

NDC: +Y is up. Point(-1, -1) is at the bottom left corner.
Framebuffer coordinate: +Y is down. Origin(0, 0) is at the top left corner.
Texture coordinate: +Y is down. Origin(0, 0) is at the top left corner.


OpenGL, OpenGL ES and WebGL

NDC: +Y is up. Point(-1, -1) is at the bottom left corner.
Framebuffer coordinate: +Y is up. Origin(0, 0) is at the bottom left corner.
Texture coordinate: +Y is up. Origin(0, 0) is at the bottom left corner.


Vulkan

NDC: +Y is down. Point(-1, -1) is at the top left corner.
Framebuffer coordinate: +Y is down. Origin(0, 0) is at the bottom left corner.
Texture coordinate: +Y is up. Origin(0, 0) is at the bottom left corner.


like image 197
Hamid Yusifli Avatar answered Oct 31 '22 05:10

Hamid Yusifli