What does #pragma vertex vert_img do in a Unity shader?
Asked Answered
A

2

7

While I built an idea of what vert_img does by observing results, I would like to read a more theoretical explanation that I couldn't find online.

For context, I found this vert_img in some shaders that use floating point textures to compute the dynamics of a particle system.

Edit: the confusing thing is that it's declared even if no vertex shaders are defined.

Ashleyashli answered 1/2, 2016 at 17:32 Comment(0)
A
11

As I just found out, vert_img is a minimal vertex shader that is defined in UnityCG.cginc

v2f_img vert_img( appdata_img v )
{
    v2f_img o;
    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    o.uv = v.texcoord;
    return o;
}

Its purpose is to forward the vertex data to the fragment shader. Handy!

Ashleyashli answered 1/2, 2016 at 21:46 Comment(0)
Z
2

#pragma vertex VERTEX_SHADER_NAME (vertex method)

#pragma vertex ____ represents the name of vertex shader in Shader code.

Either it is vert_img or any thing else.

shader example

Zelikow answered 1/2, 2016 at 19:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.