Browse Source

Fix `SCREEN_TEXTURE` in "Screen Space Shaders" demo

Danil Alexeev 2 years ago
parent
commit
faee000550

+ 3 - 4
2d/screen_space_shaders/art/filmgrain.png.import

@@ -4,23 +4,22 @@ importer="texture"
 type="CompressedTexture2D"
 uid="uid://c5jxxypesp0k5"
 path.s3tc="res://.godot/imported/filmgrain.png-8b1c9d8b22a2ffa8f94b1e004d5eddc9.s3tc.ctex"
-path.etc2="res://.godot/imported/filmgrain.png-8b1c9d8b22a2ffa8f94b1e004d5eddc9.etc2.ctex"
 metadata={
-"imported_formats": ["s3tc", "etc2"],
+"imported_formats": ["s3tc_bptc"],
 "vram_texture": true
 }
 
 [deps]
 
 source_file="res://art/filmgrain.png"
-dest_files=["res://.godot/imported/filmgrain.png-8b1c9d8b22a2ffa8f94b1e004d5eddc9.s3tc.ctex", "res://.godot/imported/filmgrain.png-8b1c9d8b22a2ffa8f94b1e004d5eddc9.etc2.ctex"]
+dest_files=["res://.godot/imported/filmgrain.png-8b1c9d8b22a2ffa8f94b1e004d5eddc9.s3tc.ctex"]
 
 [params]
 
 compress/mode=2
+compress/high_quality=false
 compress/lossy_quality=0.7
 compress/hdr_compression=1
-compress/bptc_ldr=0
 compress/normal_map=0
 compress/channel_pack=0
 mipmaps/generate=true

+ 3 - 4
2d/screen_space_shaders/art/vignette.png.import

@@ -4,23 +4,22 @@ importer="texture"
 type="CompressedTexture2D"
 uid="uid://c7uiamx2smpx5"
 path.s3tc="res://.godot/imported/vignette.png-993dbe0a69e475ef62cba692d80d947d.s3tc.ctex"
-path.etc2="res://.godot/imported/vignette.png-993dbe0a69e475ef62cba692d80d947d.etc2.ctex"
 metadata={
-"imported_formats": ["s3tc", "etc2"],
+"imported_formats": ["s3tc_bptc"],
 "vram_texture": true
 }
 
 [deps]
 
 source_file="res://art/vignette.png"
-dest_files=["res://.godot/imported/vignette.png-993dbe0a69e475ef62cba692d80d947d.s3tc.ctex", "res://.godot/imported/vignette.png-993dbe0a69e475ef62cba692d80d947d.etc2.ctex"]
+dest_files=["res://.godot/imported/vignette.png-993dbe0a69e475ef62cba692d80d947d.s3tc.ctex"]
 
 [params]
 
 compress/mode=2
+compress/high_quality=false
 compress/lossy_quality=0.7
 compress/hdr_compression=1
-compress/bptc_ldr=0
 compress/normal_map=0
 compress/channel_pack=0
 mipmaps/generate=true

+ 4 - 4
2d/screen_space_shaders/screen_shaders.tscn

@@ -58,17 +58,17 @@ shader_parameter/saturation = 1.8
 
 [sub_resource type="ShaderMaterial" id="10"]
 shader = ExtResource("17")
-shader_parameter/depth = 0.005
 shader_parameter/frequency = 60.0
+shader_parameter/depth = 0.005
 
 [sub_resource type="ShaderMaterial" id="11"]
 shader = ExtResource("18")
 shader_parameter/base = Color(0.941176, 0.647059, 0.356863, 1)
-shader_parameter/flashing = 0.1
-shader_parameter/fps = 15.0
-shader_parameter/grain = ExtResource("19_mg7oc")
 shader_parameter/grain_strength = 0.5
+shader_parameter/fps = 15.0
 shader_parameter/stretch = 0.5
+shader_parameter/flashing = 0.1
+shader_parameter/grain = ExtResource("19_mg7oc")
 shader_parameter/vignette = ExtResource("7")
 
 [node name="ScreenShaders" type="Control"]

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

@@ -1,11 +1,12 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform float brightness = 0.8;
 uniform float contrast = 1.5;
 uniform float saturation = 1.8;
 
 void fragment() {
-	vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
 
 	c.rgb = mix(vec3(0.0), c.rgb, brightness);
 	c.rgb = mix(vec3(0.5), c.rgb, contrast);

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

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

+ 3 - 1
2d/screen_space_shaders/shaders/contrasted.gdshader

@@ -1,7 +1,9 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
+
 void fragment() {
-	vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
 	c = mod(c + vec3(0.5), vec3(1.0));
 	COLOR.rgb = c;
 }

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

@@ -1,5 +1,6 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform float frequency = 60;
 uniform float depth = 0.005;
 
@@ -7,7 +8,7 @@ void fragment() {
 	vec2 uv = SCREEN_UV;
 	uv.x += sin(uv.y * frequency + TIME) * depth;
 	uv.x = clamp(uv.x, 0.0, 1.0);
-	vec3 c = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, uv, 0.0).rgb;
 
 	COLOR.rgb = c;
 }

+ 3 - 1
2d/screen_space_shaders/shaders/negative.gdshader

@@ -1,7 +1,9 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
+
 void fragment() {
-	vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
 	c = vec3(1.0) - c;
 	COLOR.rgb = c;
 }

+ 3 - 1
2d/screen_space_shaders/shaders/normalized.gdshader

@@ -1,6 +1,8 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
+
 void fragment() {
-	vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
 	COLOR.rgb = normalize(c);
 }

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

@@ -1,5 +1,6 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform vec4 base: source_color;
 uniform sampler2D grain;
 uniform float grain_strength = 0.3;
@@ -14,7 +15,7 @@ float make_grain(float time, vec2 uv) {
 }
 
 void fragment() {
-	vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
 
 	//float v = max(c.r, max(c.g, c.b));
 	float v = dot(c, vec3(0.33333, 0.33333, 0.33333));

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

@@ -1,5 +1,6 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform float size_x = 0.008;
 uniform float size_y = 0.008;
 
@@ -7,5 +8,5 @@ void fragment() {
 	vec2 uv = SCREEN_UV;
 	uv -= mod(uv, vec2(size_x, size_y));
 
-	COLOR.rgb = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb;
+	COLOR.rgb = textureLod(screen_texture, uv, 0.0).rgb;
 }

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

@@ -1,9 +1,10 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform vec4 base : source_color;
 
 void fragment() {
-	vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
+	vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
 	float v = dot(c, vec3(0.33333, 0.33333, 0.33333));
 	v = sqrt(v);
 	COLOR.rgb = base.rgb * v;

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

@@ -1,10 +1,11 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform sampler2D vignette;
 
 void fragment() {
 	vec3 vignette_color = texture(vignette, UV).rgb;
 	// Screen texture stores gaussian blurred copies on mipmaps.
-	COLOR.rgb = textureLod(SCREEN_TEXTURE, SCREEN_UV, (1.0 - vignette_color.r) * 4.0).rgb;
+	COLOR.rgb = textureLod(screen_texture, SCREEN_UV, (1.0 - vignette_color.r) * 4.0).rgb;
 	COLOR.rgb *= texture(vignette, UV).rgb;
 }

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

@@ -1,5 +1,6 @@
 shader_type canvas_item;
 
+uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
 uniform float rotation = 3.0;
 
 void fragment() {
@@ -9,5 +10,5 @@ void fragment() {
 	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));
-	COLOR.rgb = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb;
+	COLOR.rgb = textureLod(screen_texture, uv, 0.0).rgb;
 }