42 lines
1.3 KiB
HLSL
42 lines
1.3 KiB
HLSL
// Vertex shader that draws the game's pre-transformed (XYZRHW) interface vertices scaled by the HUD scale: the radar is drawn at
|
|
// the screen's native resolution instead of inside the smaller HUD layer. The fixed-function pixel stage stays in charge of
|
|
// texturing and blending (a vertex shader may feed it), so the radar looks exactly as the game draws it, only bigger.
|
|
// Our own code. Compiled by build_shaders.py into radar_shaders.h (vs_2_0); variants by define:
|
|
// HAS_DIFFUSE: the vertices carry D3DFVF_DIFFUSE, HAS_TEX: D3DFVF_TEX1.
|
|
// c0 = (2 * sx / viewportWidth, -2 * sy / viewportHeight, 0, 0): pixel coordinates of the layout (layer) -> clip space.
|
|
|
|
float4 g_scale : register(c0);
|
|
|
|
struct VSIn {
|
|
float4 pos : POSITION;
|
|
#ifdef HAS_DIFFUSE
|
|
float4 col : COLOR0;
|
|
#endif
|
|
#ifdef HAS_TEX
|
|
float2 tex : TEXCOORD0;
|
|
#endif
|
|
};
|
|
|
|
struct VSOut {
|
|
float4 pos : POSITION;
|
|
#ifdef HAS_DIFFUSE
|
|
float4 col : COLOR0;
|
|
#endif
|
|
#ifdef HAS_TEX
|
|
float2 tex : TEXCOORD0;
|
|
#endif
|
|
};
|
|
|
|
VSOut RadarVS(VSIn i) {
|
|
VSOut o;
|
|
// XYZRHW: x, y are render target pixels, z the depth, w = 1/rhw is the clip w (perspective-correct texturing)
|
|
float w = 1.0 / i.pos.w;
|
|
o.pos = float4((i.pos.x * g_scale.x - 1.0) * w, (i.pos.y * g_scale.y + 1.0) * w, i.pos.z * w, w);
|
|
#ifdef HAS_DIFFUSE
|
|
o.col = i.col;
|
|
#endif
|
|
#ifdef HAS_TEX
|
|
o.tex = i.tex;
|
|
#endif
|
|
return o;
|
|
}
|