   Projective texturing via vertex shaders
  I've got projective texturing for plane reflections working just fine using the fixed function pipeline, by using cameraspace texcoord generation, and setting my texture matrix to: projection * translate(1.0, 1.0, 0.0) * scale(0.5, 0.5, 1.0)   where the translation and scale matrices are to account for the fact the post-perspective space is in the range [-1, 1].Now, I want to move this to a vertex shader so I can distort the texcoords based on the surface normal. This is the HLSL code for the shader (simple projection, no distortion):   float4x4clipMatrix;float4x4texMatrix;struct VertexIn{float4pos:POSITION;float4norm :NORMAL;float2tex0 :TEXCOORD0;};struct VertexOut{float4pos:POSITION;float4diff:COLOR;float4tex0:TEXCOORD0;};VertexOut main( VertexIn inVert ){VertexOut outVert;// Transform vertex positionfloat4 projSpace = mul(clipMatrix, inVert.pos);outVert.pos = projSpace;//Transform projection space position by the texture matrix//and set as texture coordinateoutVert.tex0 = mul(texMatrix, projSpace);//Emit diffuse coloroutVert.diff = float4(1.0, 1.0, 1.0, 1.0);return outVert;}If texMatrix is set to identity, it behaves as expected (that is, it produces exactly the same output as the fixed function pipeline does, with the texture matrix set just to my projection matrix). However as soon as i try to add the translation and scale components to the texMatrix i get terrible artifacts and the projection goes all wrong.Here is the scene as it should look (using the ffp). Excuse the overzealous jpeg compression and programmer art:And here is how it looks using the shader version (the camera angle has changed to more clearly show the artifacts):Anyone got any suggestions or ideas?EDIT: for formatting and images[edited by - Thraddash on May 23, 2004 10:00:46 PM]
  I''m gonna bump this sucker, because I''m still stumped almost a week later. ;  this site...http://realtimecg.gamedev-pt.net/index.htmlhave in the DOC section a tutorial about projective texture using vertex shader...-----------------------------------My Site