MainComputersProgrammingLanguages › Basic Vertex Shader

Basic Vertex Shader

Edit Page
Report
Scan day: 07 February 2014 UTC
23
Virus safety - good
Description: A clean example of a no-frills vertex shader. demonstrates input/output semantics, application variables and state values.
i get garbage at the end of my buffer somehow.... by godecho !!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
Size: 1745 chars

Contact Information

Email:
Phone&Fax:
Address:
Extended:

WEBSITE Info

Page title:GLProgramming.com
Keywords:
Description:
IP-address:162.144.5.3

WHOIS Info

NS
Name Server: NS1435.HOSTGATOR.COM
Name Server: NS1436.HOSTGATOR.COM
WHOIS
Status: clientTransferProhibited
Date
Creation Date: 08-sep-2002
Expiration Date: 08-sep-2014