So i have this shader that is used to draw an overlay wireframe on 3d objects, which looks very nice but as soon as i move the object the wireframe stays in position even though the same World/View/Projection is applied,im not great with HLSL if someone could help.
The Offset input is to move it out slightly from the object which looks tons better than using a Basiceffect shader.
float4x4 World;
float4x4 View;
float4x4 Projection;
float4 tint = float4(1,1,1,1);
float Offset = 0.1;
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
float4 Normal : NORMAL;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
};
//------------------------------------
// Vertex Shader
//------------------------------------
VertexShaderOutput LineRenderingVS(VertexShaderInput input)
{
VertexShaderOutput Output;
float4 normal = normalize(input.Normal);
input.Position.xyz += normal * Offset;
// Figure out the position of the vertex in view space and clip space
float4x4 WorldViewProj = mul(World, View);
Output.Position = mul(input.Position, WorldViewProj);
float4 viewPosition = mul(input.Position, View);
Output.Position = mul(viewPosition, Projection);
Output.Color = input.Color;
return Output;
}
//------------------------------------
// Pixel Shader
//------------------------------------
float4 LineRenderingPS(VertexShaderOutput input) : COLOR0
{
//return tint;
return input.Color;
}
//------------------------------------
// Technique
//------------------------------------
technique LineRendering3D
{
pass PassFor3D
{
VertexShader = compile vs_4_0_level_9_1 LineRenderingVS();
PixelShader = compile ps_4_0_level_9_1 LineRenderingPS();
}
}