Here's the cursor I want to display: (Temporarily used from the code I found, for testing & learning)
Here's what it looks like at a close view, with and without wireframe mode on:
And this is what happens when you zoom out:
Basically the the cursor is rendered across the entire terrain but I'm clamping the coordinates, so I'm assuming when I zoom out the texture gets so small that the edges are yellow aswell. I've done it exactly how the sample that I looked in did it, and it works perfect in the sample. So I don't get whats wrong.
Here's the HLSL code:
// Variables
float4x4 View;
float4x4 Projection;
float4x4 World;
float3 LightDirection;
float Ambient;
bool EnableLighting;
// Cursor
float3 GroundCursorPosition;
texture GroundCursorTexture;
int GroundCursorSize;
bool ShowGroundCursor;
// Textures
texture t0;
float t0scale;
texture t1;
float t1scale;
sampler t0sampler = sampler_state {
Texture = (t0);
MagFilter = Linear;
MinFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler t1sampler = sampler_state {
Texture = (t1);
MagFilter = Linear;
MinFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler CursorSampler = sampler_state {
Texture = (GroundCursorTexture);
MagFilter = Linear;
MipFilter = Linear;
MinFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VS_INPUT {
float4 Position : POSITION0;
float3 Normal : NORMAL;
float2 TextureCoordinate : TEXCOORD0;
float2 Weights : TEXCOORD1;
};
struct VS_OUTPUT {
float4 Position : POSITION0;
float2 TextureCoordinate : TEXCOORD0;
float3 Position3D : TEXCOORD1;
float2 Weights : TEXCOORD2;
float3 Normal : TEXCOORD3;
float Depth : TEXCOORD4;
};
void Transform(in VS_INPUT Input, out VS_OUTPUT Output) {
Output.Position = mul(Input.Position, mul(World, mul(View, Projection)));
Output.Position3D = mul(Input.Position, World);
Output.TextureCoordinate = Input.TextureCoordinate;
Output.Normal = Input.Normal;
Output.Weights = Input.Weights;
Output.Depth = Output.Position.z / Output.Position.w;
}
struct PS_INPUT {
float3 Position : POSITION0;
float2 TextureCoordinate : TEXCOORD0;
float3 Position3D : TEXCOORD1;
float2 Weights : TEXCOORD2;
float3 Normal : TEXCOORD3;
float Depth : TEXCOORD4;
};
struct PS_OUTPUT {
float4 Color : COLOR0;
};
void Texture(in PS_INPUT Input, out PS_OUTPUT Output) {
float blendDistance = 0.96f;
float blendWidth = 0.040f;
float blendFactor = clamp((Input.Depth - blendDistance) / blendWidth, 0, 1);
float4 farColor;
farColor = tex2D(t0sampler, Input.TextureCoordinate * t0scale) * Input.Weights[0];
farColor += tex2D(t1sampler, Input.TextureCoordinate * t1scale) * Input.Weights[1];
float4 nearColor;
float2 nearTexCoord = Input.TextureCoordinate * 3;
nearColor = tex2D(t0sampler, nearTexCoord * t0scale) * Input.Weights[0];
nearColor += tex2D(t1sampler, nearTexCoord * t1scale) * Input.Weights[1];
float4 a = tex2D(t0sampler, Input.TextureCoordinate * t0scale);
float4 b = tex2D(t1sampler, Input.TextureCoordinate * t1scale);
float4 first = a * Input.Weights[0];
float4 second = b * Input.Weights[1];
float4 color = first + second;
Output.Color = color;
if (ShowGroundCursor) {
float cursorScale = 1.0;
float4 cursorColor = tex2D(CursorSampler, (Input.TextureCoordinate * (cursorScale / GroundCursorSize)) - (GroundCursorPosition.xz * (cursorScale / GroundCursorSize)) + 0.5);
Output.Color.rgb += cursorColor.rgb;
}
Output.Color.a = 1;
//Output.Color = lerp(nearColor, farColor, blendFactor);
}
void Wireframe(in VS_INPUT Input, out VS_OUTPUT Output) {
Output.Position = mul(Input.Position, mul(World, mul(View, Projection)));
Output.Position.y += 0.005;
}
float4 White() : COLOR0 {
return 1;
}
technique TransformTexture {
pass P0 {
VertexShader = compile vs_2_0 Transform();
PixelShader = compile ps_2_0 Texture();
}
}
technique TransformTextureWireframe {
pass P0 {
VertexShader = compile vs_2_0 Transform();
PixelShader = compile ps_2_0 Texture();
}
pass P1 {
VertexShader = compile vs_2_0 Wireframe();
PixelShader = compile ps_2_0 White();
FillMode = Wireframe;
}
}
Any help is appreciated!
Thanks in advance!