diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-18 10:56:22 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-18 10:58:14 +0200 |
commit | c74d65cec84532d14d39be970438516c2b9f6c0e (patch) | |
tree | c574cf78035c205a5e0ebc247f28d01a3c64b4bd /modules | |
parent | 0187cdae9ae34b762501b0e6b8da61b3986d079b (diff) |
GLSL: Change shader type specifier from [vertex] to #[vertex]
The added `#` prevents clang-format from misinterpreting the meaning
of this statement and thus messing up the formatting of the next
lines up until the first `layout` statement.
Similarly, a semicolon is now enforced on `versions` defines to
prevent clang-format from messing up formatting and putting them
all on a single line. Note: In its current state the code will
ignore chained statements on a single line separated by a semicolon.
Also removed some extraneous lines missed in previous style changes
or added by mistake with said changes (e.g. after uniform definitions
that clang-format messes up somewhat too, but we live with it).
Diffstat (limited to 'modules')
-rw-r--r-- | modules/lightmapper_rd/lm_blendseams.glsl | 53 | ||||
-rw-r--r-- | modules/lightmapper_rd/lm_common_inc.glsl | 7 | ||||
-rw-r--r-- | modules/lightmapper_rd/lm_compute.glsl | 22 | ||||
-rw-r--r-- | modules/lightmapper_rd/lm_raster.glsl | 22 |
4 files changed, 35 insertions, 69 deletions
diff --git a/modules/lightmapper_rd/lm_blendseams.glsl b/modules/lightmapper_rd/lm_blendseams.glsl index 8a9ea91311..e47e5fcc51 100644 --- a/modules/lightmapper_rd/lm_blendseams.glsl +++ b/modules/lightmapper_rd/lm_blendseams.glsl @@ -1,10 +1,9 @@ -/* clang-format off */ -[versions] +#[versions] -lines = "#define MODE_LINES" -triangles = "#define MODE_TRIANGLES" +lines = "#define MODE_LINES"; +triangles = "#define MODE_TRIANGLES"; -[vertex] +#[vertex] #version 450 @@ -12,22 +11,20 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - /* clang-format on */ - - layout(push_constant, binding = 0, std430) uniform Params { - uint base_index; - uint slice; - vec2 uv_offset; - bool debug; - float blend; - uint pad[2]; - } params; +layout(push_constant, binding = 0, std430) uniform Params { + uint base_index; + uint slice; + vec2 uv_offset; + bool debug; + float blend; + uint pad[2]; +} +params; layout(location = 0) out vec3 uv_interp; void main() { #ifdef MODE_TRIANGLES - uint triangle_idx = params.base_index + gl_VertexIndex / 3; uint triangle_subidx = gl_VertexIndex % 3; @@ -42,7 +39,6 @@ void main() { uv_interp = vec3(uv, float(params.slice)); gl_Position = vec4((uv + params.uv_offset) * 2.0 - 1.0, 0.0001, 1.0); - #endif #ifdef MODE_LINES @@ -71,12 +67,10 @@ void main() { uv_interp = vec3(src_uv, float(params.slice)); gl_Position = vec4(dst_uv * 2.0 - 1.0, 0.0001, 1.0); - ; #endif } -/* clang-format off */ -[fragment] +#[fragment] #version 450 @@ -84,16 +78,15 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - /* clang-format on */ - - layout(push_constant, binding = 0, std430) uniform Params { - uint base_index; - uint slice; - vec2 uv_offset; - bool debug; - float blend; - uint pad[2]; - } params; +layout(push_constant, binding = 0, std430) uniform Params { + uint base_index; + uint slice; + vec2 uv_offset; + bool debug; + float blend; + uint pad[2]; +} +params; layout(location = 0) in vec3 uv_interp; diff --git a/modules/lightmapper_rd/lm_common_inc.glsl b/modules/lightmapper_rd/lm_common_inc.glsl index 15946d5327..0ff455936e 100644 --- a/modules/lightmapper_rd/lm_common_inc.glsl +++ b/modules/lightmapper_rd/lm_common_inc.glsl @@ -11,7 +11,6 @@ struct Vertex { layout(set = 0, binding = 1, std430) restrict readonly buffer Vertices { Vertex data[]; } - vertices; struct Triangle { @@ -22,7 +21,6 @@ struct Triangle { layout(set = 0, binding = 2, std430) restrict readonly buffer Triangles { Triangle data[]; } - triangles; struct Box { @@ -35,13 +33,11 @@ struct Box { layout(set = 0, binding = 3, std430) restrict readonly buffer Boxes { Box data[]; } - boxes; layout(set = 0, binding = 4, std430) restrict readonly buffer GridIndices { uint data[]; } - grid_indices; #define LIGHT_TYPE_DIRECTIONAL 0 @@ -70,7 +66,6 @@ struct Light { layout(set = 0, binding = 5, std430) restrict readonly buffer Lights { Light data[]; } - lights; struct Seam { @@ -81,13 +76,11 @@ struct Seam { layout(set = 0, binding = 6, std430) restrict readonly buffer Seams { Seam data[]; } - seams; layout(set = 0, binding = 7, std430) restrict readonly buffer Probes { vec4 data[]; } - probe_positions; layout(set = 0, binding = 8) uniform utexture3D grid; diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index a442016969..56976bd623 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -1,13 +1,12 @@ -/* clang-format off */ -[versions] +#[versions] -primary = "#define MODE_DIRECT_LIGHT" -secondary = "#define MODE_BOUNCE_LIGHT" -dilate = "#define MODE_DILATE" -unocclude = "#define MODE_UNOCCLUDE" -light_probes = "#define MODE_LIGHT_PROBES" +primary = "#define MODE_DIRECT_LIGHT"; +secondary = "#define MODE_BOUNCE_LIGHT"; +dilate = "#define MODE_DILATE"; +unocclude = "#define MODE_UNOCCLUDE"; +light_probes = "#define MODE_LIGHT_PROBES"; -[compute] +#[compute] #version 450 @@ -29,14 +28,11 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; #include "lm_common_inc.glsl" -/* clang-format on */ - #ifdef MODE_LIGHT_PROBES layout(set = 1, binding = 0, std430) restrict buffer LightProbeData { vec4 data[]; } - light_probes; layout(set = 1, binding = 1) uniform texture2DArray source_light; @@ -94,7 +90,6 @@ layout(push_constant, binding = 0, std430) uniform Params { mat3x4 env_transform; } - params; //check it, but also return distance and barycentric coords (for uv lookup) @@ -123,7 +118,6 @@ bool trace_ray(vec3 p_from, vec3 p_to out float r_distance, out vec3 r_normal #endif ) { - /* world coords */ vec3 rel = p_to - p_from; @@ -149,7 +143,6 @@ bool trace_ray(vec3 p_from, vec3 p_to while (all(greaterThanEqual(icell, ivec3(0))) && all(lessThan(icell, ivec3(params.grid_size))) && iters < 1000) { uvec2 cell_data = texelFetch(usampler3D(grid, linear_sampler), icell, 0).xy; if (cell_data.x > 0) { //triangles here - bool hit = false; #if defined(MODE_UNOCCLUDE) bool hit_backface = false; @@ -211,7 +204,6 @@ bool trace_ray(vec3 p_from, vec3 p_to r_triangle = tidx; r_barycentric = barycentric; } - #endif } } diff --git a/modules/lightmapper_rd/lm_raster.glsl b/modules/lightmapper_rd/lm_raster.glsl index 36b706bcd5..6c2904192b 100644 --- a/modules/lightmapper_rd/lm_raster.glsl +++ b/modules/lightmapper_rd/lm_raster.glsl @@ -1,5 +1,4 @@ -/* clang-format off */ -[vertex] +#[vertex] #version 450 @@ -7,9 +6,7 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - /* clang-format on */ - - layout(location = 0) out vec3 vertex_interp; +layout(location = 0) out vec3 vertex_interp; layout(location = 1) out vec3 normal_interp; layout(location = 2) out vec2 uv_interp; layout(location = 3) out vec3 barycentric; @@ -26,11 +23,8 @@ layout(push_constant, binding = 0, std430) uniform Params { ivec3 grid_size; uint pad2; } - params; -/* clang-format on */ - void main() { uint triangle_idx = params.base_triangle + gl_VertexIndex / 3; uint triangle_subidx = gl_VertexIndex % 3; @@ -56,12 +50,9 @@ void main() { face_normal = -normalize(cross((vertices.data[vertex_indices.x].position - vertices.data[vertex_indices.y].position), (vertices.data[vertex_indices.x].position - vertices.data[vertex_indices.z].position))); gl_Position = vec4((uv_interp + params.uv_offset) * 2.0 - 1.0, 0.0001, 1.0); - ; } -/* clang-format off */ - -[fragment] +#[fragment] #version 450 @@ -69,7 +60,6 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - layout(push_constant, binding = 0, std430) uniform Params { vec2 atlas_size; vec2 uv_offset; @@ -79,9 +69,8 @@ layout(push_constant, binding = 0, std430) uniform Params { float bias; ivec3 grid_size; uint pad2; -} params; - -/* clang-format on */ +} +params; layout(location = 0) in vec3 vertex_interp; layout(location = 1) in vec3 normal_interp; @@ -100,7 +89,6 @@ void main() { { // smooth out vertex position by interpolating its projection in the 3 normal planes (normal plane is created by vertex pos and normal) // because we don't want to interpolate inwards, normals found pointing inwards are pushed out. - vec3 pos_a = vertices.data[vertex_indices.x].position; vec3 pos_b = vertices.data[vertex_indices.y].position; vec3 pos_c = vertices.data[vertex_indices.z].position; |