How is UV data represented in the shader?
Asked Answered
M

2

0

I notice that the vertex shader has a UV property, but I cant find any documentation about it. In the vertex shader is UV a vector2 that represents the x, y position of the current pixel in the texture?

Meanie answered 7/2, 2022 at 19:0 Comment(0)
A
0

https://mcmap.net/q/21957/-about-opengl-texture-coordinates

http://www.glprogramming.com/red/chapter09.html


Godots shader language is essentially just a subset of openGL with a simpler syntax. Where there are caps in documentation, for godot 3.x at least, you can essentially just fall back on the openGL documentation, Red book for an example.

Anderegg answered 7/2, 2022 at 19:28 Comment(0)
P
0

Vertex and fragment function both have built-in UV property. In vertex function it represents vertex position in the texture space while in fragment function it's pixel position in the texture space. UV in fragment shader is in fact interpolation of three UV coordinates belonging to shaded triangle's vertices. So if you manipulate UV value in the vertex shader, it'll affect UV value in the fragment shader.

Permissive answered 7/2, 2022 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.