Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My models are stored as a set of meshes, each with a vertex list and normal list per key-frame, and indices for GL_TRIANGLES which is shared for all frames. Each frame I lerp between two adjacent key-frames to generate the vertices for that frame on the CPU and then draw it.

How can I move this into a GLSL vertex shader? Can a shader interpolate between two sets of vertices, and how can I store those vertices on the GPU?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

This could be easy. You can send another informations then X,Y,Z position with your vertex. If you are not using one of color, normal or texture coord, you can use them for adding there your second vertex list XYZ. It is very common to use texture coords etc. to something different than what its name says. (dont forget to comment it to dont get confused another programmers...)

On vertex shader you can use mix function. It does linear interpolation between two values (or vectors) based on third value between 0-1. mix(vec1,vec2,mixValue).

If you dont have any free space in your vertex desc, use mutlitexturing coords. And if you dont have this either - or you dont want to use this. Make your second vertex list array of floats, send it to the gpu and use gl_InstanceID for addresing in this array. It is vertex id... or index if you want.

share|improve this answer
add comment

In the vertex shader, you can use Texture too. This is the "VTF" tricks. This is used in GPU Particle engine.

Look this document: Nvidia VTF Introduction

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.