Tuesday, April 10, 2007

Prototype Camera Mapping Shader!

Spent the friggin' weekend learning vex, and today, happily came across a light projection tutorial in vex. I then re-implemented it as a surface shader, and it allows me to BAKE OUT TEXTURES! Woot! Will do more testing tomorrow to ensure it works perfectly.

#pragma hint map image
#pragma hint camera oppath

surface
GW_camera_map_per_pixel(
string map = "";
vector uv = 0; // For debug
)

{

float uu,vv;
vector pos;

if (map != "")
{
//pos = wo_space(P);
pos = toNDC(P);

uu = pos.x;
vv = pos.y;


Cf = texture(map, uu,vv);
}

else
{
//Cf = {0,1,0};
Cf = texture(map, uv.x,uv.y); // Debug purposes
}
}

No comments: