This topic is now archived and is closed to further replies.


Object Outlining - Vertex Program

Recommended Posts

JulianSpillane    122
Hey all. I''m having a bit of an annoying problem. See, I''m trying to get the outline of an object for a bit of toon shading by extruding an object along its normals a given amount through a vertex shader, but am getting realllly odd results. [img][/img] This is sans vertex program. [img][/img] This is what''s happening with the program. Here''s the code I''m using (btw, it''s ARB_vertex_program):
ATTRIB iPos         = vertex.position;
ATTRIB iColor		= vertex.color;
ATTRIB iNormal      = vertex.normal;
PARAM  mvp[4]       = { state.matrix.mvp };
PARAM  extrude      = { 2.0, 2.0, 2.0, 0.0 };
TEMP   xfNormal, tempResize;
OUTPUT oPos         = result.position;
OUTPUT oColor       = result.color;

DP3 xfNormal.w, iNormal, iNormal;
RSQ xfNormal.w, xfNormal.w;
MUL, xfNormal.w, iNormal;
MUL xfNormal, xfNormal, extrude.xyzw;

ADD tempResize.x, iPos.x, xfNormal.x;
ADD tempResize.y, iPos.y, xfNormal.y;
ADD tempResize.z, iPos.z, xfNormal.z;
ADD tempResize.w, iPos.w, xfNormal.w;

# Transform the vertex to clip coordinates.
# We transform succesively through the modelview matrix, then the projection matrix.
DP4 oPos.x, mvp[0], tempResize;
DP4 oPos.y, mvp[1], tempResize;
DP4 oPos.z, mvp[2], tempResize;
DP4 oPos.w, mvp[3], tempResize;

# Write our color out directly
MOV oColor, iColor;
Can anyone tell me where I''ve gone wrong? Thanks, Julian

Share this post

Link to post
Share on other sites