!!ARBvp1.0
#**************************************************
# www.UltimateGameProgramming.com
# Basic Vertex Shader in OpenGL (ARBvp1.0)
# Created by the Programming Ace
#**************************************************
# Original Input...
ATTRIB OriginalPos = vertex.position;
ATTRIB OriginalColor = vertex.color;
# Vertex Output...
OUTPUT OutPos = result.position;
OUTPUT OutColor = result.color;
# Constant variables...
PARAM ModelViewProj[4] = { state.matrix.mvp }; # Modelview Projection Matrix.
PARAM InputTranslation = program.env[0]; # Translation value sent in from the application.
TEMP temp; # Just a temporary variable.
#**************************************************
# BODY
#**************************************************
# Here each axis is transformed into clip space. Basically we are storing the correct position
# that the vertex would normally be in. Since this is a shader OpenGL cant do this for us.
# So don't be scared, this is just positioning the vertex without any translation or rotation.
DP4 temp.x, ModelViewProj[0], OriginalPos;
DP4 temp.y, ModelViewProj[1], OriginalPos;
DP4 temp.z, ModelViewProj[2], OriginalPos;
DP4 temp.w, ModelViewProj[3], OriginalPos;
# Now here we will add the translation to the position before setting it to the output.
# I figured we could just use the ADD instruction to just add the x, y, z positions
# and get an accurate look.
ADD temp, temp, InputTranslation;
# Set the final Output position.
MOV OutPos, temp;
# We will use the some color that the vertex come in with.
MOV OutColor, OriginalColor;
END |