42 lines
1.2 KiB
HLSL
42 lines
1.2 KiB
HLSL
struct VSInput
|
|
{
|
|
float3 position : POSITION;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
struct VSOutput
|
|
{
|
|
float4 position : SV_POSITION;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
VSOutput mainVS(VSInput input)
|
|
{
|
|
VSOutput output;
|
|
|
|
// Standard transform
|
|
float4 worldPos = mul(float4(input.position, 1.0), gWorldViewProj);
|
|
|
|
// Simulate wobble by snapping coordinates to a lower precision grid.
|
|
// For a PS1-style effect, we can quantize the projected coordinates.
|
|
// For instance, if wobbleIntensity is something small like 1.0 or 0.5,
|
|
// multiply, floor, and divide back:
|
|
float factor = 1.0 / wobbleIntensity;
|
|
worldPos.x = floor(worldPos.x * factor) / factor;
|
|
worldPos.y = floor(worldPos.y * factor) / factor;
|
|
worldPos.z = floor(worldPos.z * factor) / factor;
|
|
worldPos.w = floor(worldPos.w * factor) / factor;
|
|
|
|
// Output position
|
|
output.position = worldPos;
|
|
|
|
// Pass through texture coordinate as-is.
|
|
// We do not do perspective correction here intentionally (PS1 didn't).
|
|
// PS1 essentially did affine mapping in screen space. To simulate this,
|
|
// we can just pass the original texcoords and let the pixel shader
|
|
// treat them linearly.
|
|
output.texcoord = input.texcoord;
|
|
|
|
return output;
|
|
}
|