Original Post
Hello all, I am trying to do dynamic lightmapping using vertex programs.
I am using OpenGL''s Vertex Program and I wish to implement this using its scripting language:
I have this so far:
Unfortunatley the whole area is dark, but I can make out some things so its not completley black. Any help as to what I did wrong would be greatly appriciated.
Thanks.
- Weasalmongler
texCoords.pos[0] = ((vert.pos[0]-m_lightPos.pos[0])/(m_brightness*2.0f))+0.5f; texCoords.pos[1] = ((vert.pos[1]-m_lightPos.pos[1])/(m_brightness*2.0f))+0.5f; texCoords.pos[2] = ((vert.pos[2]-m_lightPos.pos[2])/(m_brightness*2.0f))+0.5f; glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texCoords.pos[0], texCoords.pos[1]); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, texCoords.pos[2], 0.0f);
unsigned char transform_pplight [] =
"!!VP1.0\n"
"#Simple transform and calculating Lightmap positions\n"
"#Params:\n"
"#c[32] = Light Position\n"
"#c[33] = Brightness * 2.0\n"
"#c[34] = Constant +0.5\n"
"\n"
"DP4 o[HPOS].x, c[0], v[OPOS] ; # object x MVP -> clip\n"
"DP4 o[HPOS].y, c[1], v[OPOS] ;\n"
"DP4 o[HPOS].z, c[2], v[OPOS] ;\n"
"DP4 o[HPOS].w, c[3], v[OPOS] ;\n"
"\n"
"MOV o[COL0], v[COL0] ; # col = primary colour\n"
"\n"
"#Calculate Texture Coordinates of lightmap\n"
"MOV R0, v[OPOS]; #Vertex Pos\n"
"MOV R1, c[32]; #Light Pos\n"
"ADD R2, R0, -R1; #Get Distance Vector\n"
"RCP R3, c[33] #1/(Brightness*2)\n"
"MUL R4, R2, R3 #Distance/(Brightness*2)\n"
"ADD R5, R4, c[34] #(Distance/(Brightness*2)+0.5\n"
"MOV o[TEX0].xy, R5.xy\n"
"MOV o[TEX1].x, R5.z\n"
"END";