Skip to content

Commit 02b4ed0

Browse files
authored
Merge pull request #31 from StereoKit/feature/readable_depth
Shadow maps
2 parents 45d30c8 + 01041b2 commit 02b4ed0

10 files changed

Lines changed: 511 additions & 164 deletions

File tree

examples/common/app.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ bool app_init() {
202202
colors[i] = { c8,c8,c8,c8 };
203203
} }
204204
app_tex = skg_tex_create(skg_tex_type_image, skg_use_static, skg_tex_fmt_rgba32, skg_mip_generate);
205-
skg_tex_settings (&app_tex, skg_tex_address_clamp, skg_tex_sample_linear, 0);
205+
skg_tex_settings (&app_tex, skg_tex_address_clamp, skg_tex_sample_linear, skg_sample_compare_none, 0);
206206
skg_tex_set_contents(&app_tex, colors, w, h);
207207
skg_tex_name (&app_tex, "checker_tex");
208208
free(colors);
@@ -237,7 +237,7 @@ bool app_init() {
237237
colors[i] = { c8,c8,c8,c8 };
238238
} }
239239
app_particle = skg_tex_create(skg_tex_type_image, skg_use_static, skg_tex_fmt_rgba32_linear, skg_mip_generate);
240-
skg_tex_settings (&app_particle, skg_tex_address_clamp, skg_tex_sample_linear, 0);
240+
skg_tex_settings (&app_particle, skg_tex_address_clamp, skg_tex_sample_linear, skg_sample_compare_none, 0);
241241
skg_tex_set_contents(&app_particle, colors, w, h);
242242
skg_tex_name (&app_particle, "particle_tex");
243243
free(colors);
@@ -262,8 +262,8 @@ bool app_init() {
262262
} }
263263
app_tex_gradient_srgb = skg_tex_create(skg_tex_type_image, skg_use_static, skg_tex_fmt_rgba32, skg_mip_generate);
264264
app_tex_gradient_linear = skg_tex_create(skg_tex_type_image, skg_use_static, skg_tex_fmt_rgba32_linear, skg_mip_generate);
265-
skg_tex_settings (&app_tex_gradient_srgb, skg_tex_address_clamp, skg_tex_sample_linear, 0);
266-
skg_tex_settings (&app_tex_gradient_linear, skg_tex_address_clamp, skg_tex_sample_linear, 0);
265+
skg_tex_settings (&app_tex_gradient_srgb, skg_tex_address_clamp, skg_tex_sample_linear, skg_sample_compare_none, 0);
266+
skg_tex_settings (&app_tex_gradient_linear, skg_tex_address_clamp, skg_tex_sample_linear, skg_sample_compare_none, 0);
267267
skg_tex_set_contents(&app_tex_gradient_srgb, colors, gw, gh);
268268
skg_tex_set_contents(&app_tex_gradient_linear, colors, gw, gh);
269269
skg_tex_name (&app_tex_gradient_srgb, "gradient_srgb_tex");
@@ -296,21 +296,21 @@ bool app_init() {
296296
}
297297
}
298298
app_tex_colspace[c] = skg_tex_create(skg_tex_type_image, skg_use_dynamic, skg_tex_fmt_rgba32, skg_mip_none);
299-
skg_tex_settings (&app_tex_colspace[c], skg_tex_address_clamp, skg_tex_sample_linear, 1);
299+
skg_tex_settings (&app_tex_colspace[c], skg_tex_address_clamp, skg_tex_sample_linear, skg_sample_compare_none, 1);
300300
skg_tex_set_contents(&app_tex_colspace[c], space_colors, grad_size, grad_size);
301301
bmp_write(app_col_name[c], grad_size, grad_size, (uint8_t*)space_colors);
302302
}
303303
free(space_colors);
304304

305305
app_target = skg_tex_create(skg_tex_type_rendertarget, skg_use_static, skg_tex_fmt_rgba32_linear, skg_mip_none);
306-
app_target_depth = skg_tex_create(skg_tex_type_depth, skg_use_static, skg_tex_fmt_depth16, skg_mip_none);
306+
app_target_depth = skg_tex_create(skg_tex_type_zbuffer, skg_use_static, skg_tex_fmt_depth16, skg_mip_none);
307307
skg_tex_set_contents(&app_target, nullptr, 512, 512);
308308
skg_tex_set_contents(&app_target_depth, nullptr, 512, 512);
309309
skg_tex_attach_depth(&app_target, &app_target_depth);
310310
skg_tex_name (&app_target, "main_rtex");
311311
skg_tex_name (&app_target_depth, "depth_rtex");
312312

313-
app_cubemap = skg_tex_create(skg_tex_type_cubemap, skg_use_static, skg_tex_fmt_rgba32, skg_mip_none);
313+
app_cubemap = skg_tex_create(skg_tex_type_image, (skg_use_)(skg_use_static | skg_use_cubemap), skg_tex_fmt_rgba32, skg_mip_none);
314314
skg_color32_t *cube_cols[6];
315315
const int32_t cube_face_size = 64;
316316
for (size_t f = 0; f < 6; f++) {

examples/sk_gpu_flat/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void resize_swapchain(int width, int height) {
9595
if (skg_tex_is_valid(&app_surface )) skg_tex_destroy(&app_surface);
9696
if (skg_tex_is_valid(&app_surface_depth)) skg_tex_destroy(&app_surface_depth);
9797
app_surface = skg_tex_create(skg_tex_type_rendertarget, skg_use_static, skg_tex_fmt_rgba32, skg_mip_none);
98-
app_surface_depth = skg_tex_create(skg_tex_type_depth, skg_use_static, skg_tex_fmt_depthstencil, skg_mip_none);
98+
app_surface_depth = skg_tex_create(skg_tex_type_zbuffer, skg_use_static, skg_tex_fmt_depthstencil, skg_mip_none);
9999
skg_tex_set_contents_arr(&app_surface, nullptr, 1, 1, width, height, 8);
100100
skg_tex_set_contents_arr(&app_surface_depth, nullptr, 1, 1, width, height, 8);
101101
skg_tex_attach_depth(&app_surface, &app_surface_depth);
@@ -244,6 +244,7 @@ int main_step(double t, void *) {
244244
hmm_mat4 proj = HMM_Perspective(90, app_swapchain.width / (float)app_swapchain.height, 0.01f, 1000);
245245

246246
app_render((float)t, view, proj);
247+
skg_tex_target_discard(&app_surface_depth);
247248

248249
skg_tex_copy_to_swapchain(&app_surface, &app_swapchain);
249250
skg_swapchain_present(&app_swapchain);

0 commit comments

Comments
 (0)