.
14
data/batch_frag.hlsl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Texture2D tex : register(t0);
|
||||
SamplerState smp : register(s0);
|
||||
|
||||
struct input_t {
|
||||
float4 pos : SV_Position;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 col : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 main(input_t input) : SV_Target0 {
|
||||
float4 col = input.col;
|
||||
float4 spr = tex.Sample(smp, input.uv);
|
||||
return spr * col;
|
||||
}
|
||||
72
data/batch_vert.hlsl
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
cbuffer renderer_data : register(b0) {
|
||||
float2 one_over_window_size;
|
||||
//float2 one_over_texture_size;
|
||||
float zoom;
|
||||
float padding;
|
||||
};
|
||||
|
||||
struct input_t {
|
||||
uint vtx_index : SV_VertexID;
|
||||
float4 quad : BATCH_QUAD;
|
||||
float4 tex_quad : BATCH_TEX_QUAD;
|
||||
float4 colour : BATCH_COLOUR;
|
||||
};
|
||||
|
||||
struct output_t {
|
||||
float4 pos : SV_Position;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 col : TEXCOORD2;
|
||||
};
|
||||
|
||||
static const int indices[6] = {
|
||||
0, 1, 2, 2, 3, 0,
|
||||
};
|
||||
|
||||
static const float3 positions[4] = {
|
||||
float3(0, 0, 0),
|
||||
float3(0, 1, 0),
|
||||
float3(1, 1, 0),
|
||||
float3(1, 0, 0),
|
||||
};
|
||||
|
||||
static const float2 uvs[4] = {
|
||||
float2(0.0f, 0.0f),
|
||||
float2(0.0f, 1.0f),
|
||||
float2(1.0f, 1.0f),
|
||||
float2(1.0f, 0.0f),
|
||||
};
|
||||
|
||||
output_t main(input_t input) {
|
||||
output_t output;
|
||||
|
||||
int vtx = indices[input.vtx_index];
|
||||
|
||||
float3 pos = positions[vtx];
|
||||
|
||||
pos.xy = ((pos.xy * input.quad.zw) + input.quad.xy) * zoom;
|
||||
pos.xy = (pos.xy * one_over_window_size) * 2.0 - 1.0;
|
||||
|
||||
pos.y = -pos.y;
|
||||
|
||||
/*
|
||||
x = ((x * ovws.x) * zoom * quad.w) - 1 + (quad.x * ovws.x * zoom);
|
||||
*/
|
||||
|
||||
// pos.xy *= one_over_window_size;
|
||||
// pos.xy *= zoom;
|
||||
// pos.xy *= input.quad.zw;
|
||||
// pos.x -= 1.0;
|
||||
// pos.y += 1.0;
|
||||
|
||||
// pos.xy += float2(input.quad.x, -input.quad.y) * one_over_window_size * zoom;
|
||||
|
||||
float2 uv = uvs[vtx];
|
||||
uv *= input.tex_quad.zw;
|
||||
uv += input.tex_quad.xy;
|
||||
|
||||
output.pos = float4(pos, 1.0);
|
||||
output.uv = uv;
|
||||
output.col = input.colour;
|
||||
|
||||
return output;
|
||||
}
|
||||
BIN
data/berkeley-mono.otf
Normal file
BIN
data/font.ttf
Normal file
BIN
data/metro.glb
Normal file
38
data/obj.glsl
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
@ctype mat4 mat4
|
||||
|
||||
@vs vs
|
||||
layout(binding=0) uniform vs_params {
|
||||
mat4 mvp;
|
||||
};
|
||||
|
||||
in vec4 position;
|
||||
in vec3 norm;
|
||||
in vec2 uv;
|
||||
|
||||
out vec3 fs_norm;
|
||||
out vec2 fs_uv;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * position;
|
||||
fs_norm = norm;
|
||||
fs_uv = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
layout(binding=0) uniform texture2D tex;
|
||||
layout(binding=0) uniform sampler smp;
|
||||
in vec3 fs_norm;
|
||||
in vec2 fs_uv;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = texture(sampler2D(tex, smp), fs_uv);
|
||||
// frag_color = vec4(fs_norm * 0.5 + 0.5, 1.0);
|
||||
// vec2 uv = fs_uv * 0.5 + 0.5;
|
||||
// frag_color = vec4(uv, 0.0, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program obj vs fs
|
||||
BIN
data/textures/Chair.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
data/textures/ConcreteBare.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
data/textures/Door.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
data/textures/Door_01.jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
data/textures/Floor.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
data/textures/TactilePaving.png
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
data/textures/Tiles.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
data/textures/Trains.png
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
data/textures/Trains_01.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
data/textures/Vending_machine.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
data/textures/metal.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
data/textures/metal_01.jpg
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
data/textures/metal_02.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
data/textures/metal_03.jpg
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
data/textures/metal_04.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
data/textures/metal_05.jpg
Normal file
|
After Width: | Height: | Size: 1,011 KiB |
BIN
data/textures/road_rails.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
data/textures/seats.png
Normal file
|
After Width: | Height: | Size: 119 KiB |
BIN
data/textures/tile_tile.jpg
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
data/textures/trash_can.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
22
data/triangle.glsl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
@vs vs
|
||||
in vec4 position;
|
||||
in vec4 color0;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
in vec4 color;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = color;
|
||||
}
|
||||
@end
|
||||
|
||||
@program triangle vs fs
|
||||