Quellcode durchsuchen

Add `.clang-format` and use it to format shader files (#1249)

Hugo Locurcio vor 1 Tag
Ursprung
Commit
84eabb3cf7

+ 21 - 0
.clang-format

@@ -0,0 +1,21 @@
+BasedOnStyle: LLVM
+AlignAfterOpenBracket: DontAlign
+AlignOperands: DontAlign
+AlignTrailingComments:
+  Kind: Never
+  OverEmptyLines: 0
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortFunctionsOnASingleLine: Inline
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 0
+ContinuationIndentWidth: 8
+IndentCaseLabels: true
+IndentWidth: 4
+InsertBraces: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+RemoveSemicolon: true
+SpacesInLineCommentPrefix:
+  Minimum: 0 # We want a minimum of 1 for comments, but allow 0 for disabled code.
+  Maximum: -1
+TabWidth: 4
+UseTab: Always

+ 6 - 0
2d/screen_space_shaders/art/burano.jpg.import

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/burano.jpg-bbae3c5a81f8b6300cd944219dbbbc05.c
 compress/mode=0
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/art/filmgrain.png.import

@@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/filmgrain.png-8b1c9d8b22a2ffa8f94b1e004d5eddc
 compress/mode=2
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -26,6 +28,10 @@ mipmaps/generate=true
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/art/forest.jpg.import

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/forest.jpg-f2ce28f12b0871a15d1e9ebfcd24b47f.c
 compress/mode=0
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/art/mountains.jpg.import

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/mountains.jpg-fd51eb0e2a35878963804e860ef9d18
 compress/mode=0
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/art/platformer.jpg.import

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/platformer.jpg-ce18350247a11c58497c7e0d8e3be2
 compress/mode=0
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/art/vignette.png.import

@@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/vignette.png-993dbe0a69e475ef62cba692d80d947d
 compress/mode=2
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -26,6 +28,10 @@ mipmaps/generate=true
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/art/white.png.import

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/white.png-9cdc9524282ba2bce69b45edcd6ac827.ct
 compress/mode=0
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 6 - 0
2d/screen_space_shaders/icon.webp.import

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ct
 compress/mode=0
 compress/high_quality=false
 compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
 compress/hdr_compression=1
 compress/normal_map=0
 compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
 mipmaps/limit=-1
 roughness/mode=0
 roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
 process/fix_alpha_border=true
 process/premult_alpha=false
 process/normal_map_invert_y=false

+ 1 - 1
2d/screen_space_shaders/project.godot

@@ -15,7 +15,7 @@ config/description="Several examples of full screen 2D shader processing.
 Many common full-res effects are implemented here for reference."
 config/tags=PackedStringArray("2d", "demo", "official", "rendering", "shaders")
 run/main_scene="res://screen_shaders.tscn"
-config/features=PackedStringArray("4.4")
+config/features=PackedStringArray("4.5")
 config/icon="res://icon.webp"
 
 [debug]

+ 1 - 1
2d/screen_space_shaders/shaders/blur.gdshader

@@ -1,7 +1,7 @@
 shader_type canvas_item;
 
 uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
-uniform float amount: hint_range(0.0, 5.0);
+uniform float amount : hint_range(0.0, 5.0);
 
 void fragment() {
 	COLOR.rgb = textureLod(screen_texture, SCREEN_UV, amount).rgb;

+ 1 - 1
2d/screen_space_shaders/shaders/old_film.gdshader

@@ -1,7 +1,7 @@
 shader_type canvas_item;
 
 uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
-uniform vec4 base: source_color;
+uniform vec4 base : source_color;
 uniform sampler2D grain;
 uniform float grain_strength = 0.3;
 uniform sampler2D vignette;

+ 1 - 1
2d/screen_space_shaders/shaders/whirl.gdshader

@@ -9,6 +9,6 @@ void fragment() {
 	float angle = length(rel) * rotation;
 	mat2 rot = mat2(vec2(cos(angle), -sin(angle)), vec2(sin(angle), cos(angle)));
 	rel = rot * rel;
-	uv = clamp(rel + vec2(0.5,0.5), vec2(0.0, 0.0), vec2(1.0, 1.0));
+	uv = clamp(rel + vec2(0.5, 0.5), vec2(0.0, 0.0), vec2(1.0, 1.0));
 	COLOR.rgb = textureLod(screen_texture, uv, 0.0).rgb;
 }

+ 1 - 2
3d/sprites/shaders/paper_rainbow.gdshader

@@ -25,8 +25,7 @@ void fragment() {
 		vec3 rainbow = vec3(
 				0.5 + 0.5 * sin(t),
 				0.5 + 0.5 * sin(t + 2.0),
-				0.5 + 0.5 * sin(t + 4.0)
-		);
+				0.5 + 0.5 * sin(t + 4.0));
 		ALBEDO = rainbow;
 		ALPHA = 1.0;
 	} else {

+ 6 - 13
3d/tonemap_color_correction/gradients/gradient_steps.gdshader

@@ -9,35 +9,28 @@ void fragment() {
 	// Draw base color
 	ALBEDO = my_color;
 
-	if (UV.y > 0.25)
-	{
+	if (UV.y > 0.25) {
 		// Draw gradient
 		float scale = UV.x * float(steps);
 
-		if (exponential_view)
-		{
+		if (exponential_view) {
 			scale = (scale * scale) / float(steps);
 		}
 
 		ALBEDO *= scale;
-	}
-	else
-	{
+	} else {
 		// Draw step separation bars
-		for (int i = 1; i < steps; i++)
-		{
+		for (int i = 1; i < steps; i++) {
 			float threshold = 0.002; // Bar size
 			float target = float(i);
 
-			if (exponential_view)
-			{
+			if (exponential_view) {
 				target = sqrt(float(i) * float(steps));
 			}
 
 			target = target / float(steps);
 
-			if (UV.x < target + threshold && UV.x > target - threshold)
-			{
+			if (UV.x < target + threshold && UV.x > target - threshold) {
 				ALBEDO = vec3(0); // Bars are colored black
 			}
 		}

+ 12 - 30
3d/tonemap_color_correction/gradients/hues.gdshader

@@ -6,45 +6,33 @@ uniform bool exponential_view = true;
 
 void fragment() {
 	float top_bar = 0.01;
-	if (UV.y >= top_bar)
-	{
+	if (UV.y >= top_bar) {
 		float padding = 0.002;
 		float y = (UV.y - top_bar - padding) / (1.0 - top_bar - padding * 2.0);
 		y = clamp(y, 0.0, 1.0);
 		float segments = 1.0 / 6.0;
 		vec3 col = vec3(0);
-		if (y < segments)
-		{
+		if (y < segments) {
 			col.r = 1.0;
 			col.g = y / segments;
 			col.b = 0.0;
-		}
-		else if (y < segments * 2.0)
-		{
+		} else if (y < segments * 2.0) {
 			col.r = (y - segments * 2.0) / -segments;
 			col.g = 1.0;
 			col.b = 0.0;
-		}
-		else if (y < segments * 3.0)
-		{
+		} else if (y < segments * 3.0) {
 			col.r = 0.0;
 			col.g = 1.0;
 			col.b = (y - segments * 2.0) / segments;
-		}
-		else if (y < segments * 4.0)
-		{
+		} else if (y < segments * 4.0) {
 			col.r = 0.0;
 			col.g = (y - segments * 4.0) / -segments;
 			col.b = 1.0;
-		}
-		else if (y < segments * 5.0)
-		{
+		} else if (y < segments * 5.0) {
 			col.r = (y - segments * 4.0) / segments;
 			col.g = 0.0;
 			col.b = 1.0;
-		}
-		else
-		{
+		} else {
 			col.r = 1.0;
 			col.g = 0.0;
 			col.b = (y - segments * 6.0) / -segments;
@@ -52,31 +40,25 @@ void fragment() {
 
 		float scale = UV.x * float(steps);
 
-		if (exponential_view)
-		{
+		if (exponential_view) {
 			scale = (scale * scale) / float(steps);
 		}
 
 		ALBEDO = col * scale;
-	}
-	else
-	{
+	} else {
 		ALBEDO = vec3(1.0);
 		// Draw step separation bars
-		for (int i = 1; i < steps; i++)
-		{
+		for (int i = 1; i < steps; i++) {
 			float threshold = 0.002; // Bar size
 			float target = float(i);
 
-			if (exponential_view)
-			{
+			if (exponential_view) {
 				target = sqrt(float(i) * float(steps));
 			}
 
 			target = target / float(steps);
 
-			if (UV.x < target + threshold && UV.x > target - threshold)
-			{
+			if (UV.x < target + threshold && UV.x > target - threshold) {
 				ALBEDO = vec3(0); // Bars are colored black
 			}
 		}

+ 6 - 6
viewport/dynamic_split_screen/split_screen.gdshader

@@ -1,14 +1,14 @@
 shader_type canvas_item;
 render_mode unshaded;
 
-uniform vec2 viewport_size;          // size in pixels of the viewport
+uniform vec2 viewport_size; // size in pixels of the viewport
 uniform sampler2D viewport1 : source_color;
 uniform sampler2D viewport2 : source_color;
-uniform bool split_active;           // true: split screen, false: use view1
-uniform vec2 player1_position;       // position of player 1 un UV coordinates
-uniform vec2 player2_position;       // position of player 2 un UV coordinates
-uniform float split_line_thickness : hint_range(0, 10, 0.1);  // width of the split boder
-uniform vec3 split_line_color : source_color;       // color of the split border
+uniform bool split_active; // true: split screen, false: use view1
+uniform vec2 player1_position; // position of player 1 un UV coordinates
+uniform vec2 player2_position; // position of player 2 un UV coordinates
+uniform float split_line_thickness : hint_range(0, 10, 0.1); // width of the split boder
+uniform vec3 split_line_color : source_color; // color of the split border
 
 // from https://stackoverflow.com/questions/15276454/is-it-possible-to-draw-line-thickness-in-a-fragment-shader
 float distance_to_line(vec2 p1, vec2 p2, vec2 point) {

+ 1 - 1
xr/openxr_character_centric_movement/objects/black_out.gdshader

@@ -1,5 +1,5 @@
 shader_type spatial;
-render_mode blend_mix,depth_draw_opaque,cull_disabled,unshaded,depth_test_disabled;
+render_mode blend_mix, depth_draw_opaque, cull_disabled, unshaded, depth_test_disabled;
 uniform vec4 albedo : source_color;
 
 void vertex() {

+ 1 - 1
xr/openxr_composition_layers/cursor.gdshader

@@ -5,5 +5,5 @@ uniform vec3 color : source_color = vec3(1.0, 1.0, 1.0);
 void fragment() {
 	// Called for every pixel the material is visible on.
 	float dist = length(UV - vec2(0.5, 0.5));
-	COLOR.a = 1.0 - clamp(abs(0.4 - dist)/0.1, 0.0, 1.0);
+	COLOR.a = 1.0 - clamp(abs(0.4 - dist) / 0.1, 0.0, 1.0);
 }

+ 1 - 1
xr/openxr_origin_centric_movement/objects/black_out.gdshader

@@ -1,5 +1,5 @@
 shader_type spatial;
-render_mode blend_mix,depth_draw_opaque,cull_disabled,unshaded,depth_test_disabled;
+render_mode blend_mix, depth_draw_opaque, cull_disabled, unshaded, depth_test_disabled;
 uniform vec4 albedo : source_color;
 
 void vertex() {