- // a vertex buffer
- state.bind.vertex_buffers[0] = sg.makeBuffer(.{
- .data = sg.asRange(&[_]f32{
- // positions colors
- -0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0,
- 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
- 0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0,
- -0.5, -0.5, 0.5, 1.0, 1.0, 0.0, 1.0,
- }),
+ // initial clear color
+ state.shaders.tex.pass.action.colors[0] = sg.ColorAttachmentAction{
+ .load_action = .CLEAR,
+ .store_action = .STORE,
+ .clear_value = .{ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 },
+ };
+ state.shaders.shadow.pass.action.colors[0] = sg.ColorAttachmentAction{
+ .load_action = .CLEAR,
+ .store_action = .STORE,
+ .clear_value = .{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 0.0 },
+ };
+ state.shaders.light.pass.action.colors[0] = sg.ColorAttachmentAction{
+ .load_action = .CLEAR,
+ .store_action = .STORE,
+ .clear_value = .{ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 },
+ };
+
+ // combining pass
+ state.shaders.tex.img = sg.makeImage(.{
+ .usage = .{ .color_attachment = true },
+ .width = state.OffscreenWidth,
+ .height = state.OffscreenHeight,
+ .sample_count = state.OffscreenSampleCount,
+ .pixel_format = .RGBA8,
+ });
+ state.shaders.tex.depth = sg.makeImage(.{
+ .usage = .{ .depth_stencil_attachment = true },
+ .width = state.OffscreenWidth,
+ .height = state.OffscreenHeight,
+ .sample_count = state.OffscreenSampleCount,
+ .pixel_format = .DEPTH,
+ });
+ state.shaders.shadow.img = sg.makeImage(.{
+ .usage = .{ .color_attachment = true },
+ .width = state.OffscreenWidth,
+ .height = state.OffscreenHeight,
+ .sample_count = state.OffscreenSampleCount,
+ .pixel_format = .RGBA8,
+ });
+ state.shaders.shadow.depth = sg.makeImage(.{
+ .usage = .{ .depth_stencil_attachment = true },
+ .width = state.OffscreenWidth,
+ .height = state.OffscreenHeight,
+ .sample_count = state.OffscreenSampleCount,
+ .pixel_format = .DEPTH,
+ });
+ state.shaders.light.img = sg.makeImage(.{
+ .usage = .{ .color_attachment = true },
+ .width = state.OffscreenWidth,
+ .height = state.OffscreenHeight,
+ .sample_count = state.OffscreenSampleCount,
+ .pixel_format = .RGBA8,
+ });
+ state.shaders.light.depth = sg.makeImage(.{
+ .usage = .{ .depth_stencil_attachment = true },
+ .width = state.OffscreenWidth,
+ .height = state.OffscreenHeight,
+ .sample_count = state.OffscreenSampleCount,
+ .pixel_format = .DEPTH,