41 lines
1.0 KiB
Plaintext
41 lines
1.0 KiB
Plaintext
#define NEAR_PLANE (0.01f)
|
|
|
|
|
|
[[vk::binding(0, 1)]]
|
|
cbuffer camera {
|
|
row_major float4x4 view_projection_matrix;
|
|
};
|
|
|
|
[[vk::binding(1, 1)]]
|
|
cbuffer constants {
|
|
int2 drag_start;
|
|
int2 mouse;
|
|
int map_width;
|
|
};
|
|
|
|
extension<T: ITexelElement, int format> Sampler2D<T, 0, format> {
|
|
T PixelArtSample(float2 location) {
|
|
float2 texture_size;
|
|
this.GetDimensions(texture_size.x, texture_size.y);
|
|
|
|
float2 uv = location * texture_size;
|
|
uv = floor(uv) + min(fract(uv) / fwidth(uv), 1.0) - 0.5;
|
|
uv /= texture_size;
|
|
|
|
return this.Sample(uv);
|
|
}
|
|
}
|
|
|
|
extension<T: ITexelElement, int format> Sampler2DArray<T, 0, format> {
|
|
T PixelArtSample(float3 location) {
|
|
float3 texture_size;
|
|
this.GetDimensions(texture_size.x, texture_size.y, texture_size.z);
|
|
|
|
float2 uv = location.xy * texture_size.xy;
|
|
uv = floor(uv) + min(fract(uv) / fwidth(uv), 1.0) - 0.5;
|
|
uv /= texture_size.xy;
|
|
|
|
return this.Sample(float3(uv, location.z));
|
|
}
|
|
}
|