Migrate GLSL to Slang, text shader
This commit is contained in:
47
src/Game.zig
47
src/Game.zig
@@ -55,6 +55,14 @@ const chunk_descriptor_pool = 1024;
|
||||
|
||||
const camera_near_plane = 0.1;
|
||||
|
||||
const point_lights_data = [_]shaders.PointLight{};
|
||||
const directional_lights_data = [_]shaders.DirectionalLight{
|
||||
.{
|
||||
.directionWS = .unit_nz,
|
||||
.color = .init(0.3, 0.3, 0.3),
|
||||
},
|
||||
};
|
||||
|
||||
pub fn init() !Game {
|
||||
const allocator_general = ctx.allocator_general;
|
||||
const allocator_frame = ctx.allocator_frame;
|
||||
@@ -158,13 +166,9 @@ pub fn init() !Game {
|
||||
errdefer engine.destroyPipelineLayout(pipeline_layout);
|
||||
engine.setObjectName(pipeline_layout, "PL Main", .{});
|
||||
|
||||
const vertex_shader = try engine.createShaderModule(.{ .code = &shaders.main_vert_spv });
|
||||
defer engine.destroyShaderModule(vertex_shader);
|
||||
engine.setObjectName(vertex_shader, "SM main_vert", .{});
|
||||
|
||||
const fragment_shader = try engine.createShaderModule(.{ .code = &shaders.main_frag_spv });
|
||||
defer engine.destroyShaderModule(fragment_shader);
|
||||
engine.setObjectName(fragment_shader, "SM main_frag", .{});
|
||||
const shader = try engine.createShaderModule(.{ .code = &shaders.main_spv });
|
||||
defer engine.destroyShaderModule(shader);
|
||||
engine.setObjectName(shader, "SM main", .{});
|
||||
|
||||
var vertex_buffer = try shaders.VertexBuffer.init(.{
|
||||
.usage = .vertex,
|
||||
@@ -267,13 +271,13 @@ pub fn init() !Game {
|
||||
.stages = &.{
|
||||
.{
|
||||
.stage = .{ .vertex_bit = true },
|
||||
.module = vertex_shader,
|
||||
.name = "main",
|
||||
.module = shader,
|
||||
.name = "vertexMain",
|
||||
},
|
||||
.{
|
||||
.stage = .{ .fragment_bit = true },
|
||||
.module = fragment_shader,
|
||||
.name = "main",
|
||||
.module = shader,
|
||||
.name = "fragmentMain",
|
||||
},
|
||||
},
|
||||
.vertex_input_state = .{
|
||||
@@ -609,22 +613,8 @@ pub fn init() !Game {
|
||||
});
|
||||
}
|
||||
|
||||
const point_lights_data: []const shaders.PointLight = &.{};
|
||||
try point_lights.write(.{
|
||||
.header = @intCast(point_lights_data.len),
|
||||
.elements = point_lights_data,
|
||||
});
|
||||
|
||||
const directional_lights_data: []const shaders.DirectionalLight = &.{
|
||||
.{
|
||||
.directionWS = .unit_nz,
|
||||
.color = .init(0.3, 0.3, 0.3),
|
||||
},
|
||||
};
|
||||
try directional_lights.write(.{
|
||||
.header = @intCast(directional_lights_data.len),
|
||||
.elements = directional_lights_data,
|
||||
});
|
||||
try point_lights.write(.{ .elements = &point_lights_data });
|
||||
try directional_lights.write(.{ .elements = &directional_lights_data });
|
||||
|
||||
var skybox = try Skybox.load("skybox.hdr", 512, global_uniforms.buffer);
|
||||
errdefer skybox.deinit();
|
||||
@@ -857,6 +847,9 @@ fn render(self: *Game) !void {
|
||||
.matrixWStoVS = matrix_ws_to_vs,
|
||||
.matrixVStoCS = matrix_vs_to_cs,
|
||||
.matrixSSPXtoCS = matrix_sspx_to_cs,
|
||||
|
||||
.pointLightCount = point_lights_data.len,
|
||||
.directionalLightCount = directional_lights_data.len,
|
||||
.ambientLight = ambient_light,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user