Any ideas? Updated the shader code to this but still not getting the desired result.
float dist = 92.77443083f;
//--------------------------------------------------------------------------------------
// VERTEX SHADER
//--------------------------------------------------------------------------------------
PS_INPUT VS( SPRITE_INPUT input )
{
PS_INPUT vert;
float offset = dist*-39.0f;
vert.t.x = (input.pos.x *0.0125f);
vert.t.y = 1.0f-(input.pos.y *0.0125f);
vert.p = float4((input.pos.x*dist)+offset, 0, (input.pos.y*dist)+offset, 1);
vert.p.y = (float)HMap.SampleLevel(linearSampler, vert.t, 0);
float3 vsum = {0, 0, 0};
float count = 0;
if(vert.t.x + 0.0125f <= 1.0f && vert.t.y + 0.0125f <= 1.0f)//Bottom Right
{
float3 vert2 = float3(vert.p.x+dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(1, 0)), vert.p.z);
float3 vert3 = float3(vert.p.x, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(0, 1)), vert.p.z-dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x - 0.0125f >= 0 && vert.t.y + 0.0125f <= 1.0f)//Bottom Left
{
float3 vert2 = float3(vert.p.x-dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(-1, 0)), vert.p.z);
float3 vert3 = float3(vert.p.x, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(0, 1)), vert.p.z-dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x - 0.0125f >= 0 && vert.t.y - 0.0125f >= 0)//Top Left
{
float3 vert2 = float3(vert.p.x-dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(-1, 0)), vert.p.z);
float3 vert3 = float3(vert.p.x, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(0, -1)), vert.p.z+dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x + 0.0125f <= 1.0f && vert.t.y - 0.0125f >= 0)//Top Right
{
float3 vert2 = float3(vert.p.x+dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(1, 0)), vert.p.z);
float3 vert3 = float3(vert.p.x, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(0, -1)), vert.p.z+dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x + 0.0125f <= 1.0f && vert.t.y + 0.0125f <= 1.0f && vert.t.y - 0.0125f >= 0)//Right
{
float3 vert2 = float3(vert.p.x+dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(1, -1)), vert.p.z+dist);
float3 vert3 = float3(vert.p.x+dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(1, 1)), vert.p.z-dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x - 0.0125f >= 0 && vert.t.x + 0.0125f <= 1.0f && vert.t.y + 0.0125f <= 1.0f)//Bottom
{
float3 vert2 = float3(vert.p.x+dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(1, 1)), vert.p.z-dist);
float3 vert3 = float3(vert.p.x-dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(-1, 1)), vert.p.z-dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x - 0.0125f >= 0 && vert.t.y + 0.0125f <= 1.0f && vert.t.y - 0.0125f >= 0)//Left
{
float3 vert2 = float3(vert.p.x-dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(-1, -1)), vert.p.z+dist);
float3 vert3 = float3(vert.p.x-dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(-1, 1)), vert.p.z-dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
if(vert.t.x - 0.0125f >= 0 && vert.t.x + 0.0125f <= 1.0f && vert.t.y - 0.0125f >= 0)//Top
{
float3 vert2 = float3(vert.p.x+dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(1, -1)), vert.p.z+dist);
float3 vert3 = float3(vert.p.x-dist, (float)HMap.SampleLevel(linearSampler, vert.t, 0, int2(-1, -1)), vert.p.z+dist);
float3 vec1 = vert2 - (float3)vert.p;
float3 vec2 = vert3 - (float3)vert.p;
vsum += (vec1+vec2);
count ++;
}
float3 total = vsum/count;
vert.n = normalize(total);
vert.p = mul(vert.p, view);
vert.p = mul(vert.p, prj);
return vert;
}