I need something like SV_VertexId (added in Shader Model 4) in HLSL shader to determine which vertex is currently handled. Unfortunatelly, I can compile only vs_3_0 or lower.

The objective is to change position of one specific vertex using HLSL. I can't edit the mesh and can't pass any data from game engine, my capabilities are limited by HLSL shader.

Shader is writing only for one mesh (humain face), I need to change it's shape a bit (for example, close an eye or make it smiling). I already tried to locate vertex by TEXCOORD, but had no idea how to separate it from other triangles verticles connected to it (placed at the same point where many triangles are met).

if ( VS.TC[0] > 0.8828125 && VS.TC[1] > 0.6328125  && VS.TC[1] < 0.671875 ) {
    // Upper lip center
    VS.Position += VS.Normal * uUpLip;

Could you, please, give me any advice how to identify / move only one specific verticle in HLSL? I need something like moving verticle in Blender's Edit Mode (wytn neighbour triangles are still connected in one point), but my attempt with TEXTCOORD makes them moving in different directions



1 Answer 1


You can easily add custom fields to your vertex data, one of which could be a vertex ID. You could also place those IDs in a separate vertex stream so you can use them with any mesh.

The standard way to animate a face (or any other 3D model) would be to use some sort of skeletal animation (also called skinning) which generally means that each vertex stores the index of one or more bones, along with some weights.

There are also other techniques like morphing available.

Note that without a geometry shader you can only move existing vertices. You can't change the way the vertices are connected to each other.

  • \$\begingroup\$ I can't edit the mesh and can't pass any data from game engine, my capabilities are limited by HLSL. I wrote this on the second line of my question. I can't create vertex streams, can't use skeleton. \$\endgroup\$ Sep 23, 2015 at 5:57
  • \$\begingroup\$ With those restrictions, it's not possible. \$\endgroup\$
    – Adam
    Sep 24, 2015 at 23:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .