scale3x...
This commit is contained in:
parent
004e22e3b5
commit
762205b006
2 changed files with 130 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=35 format=2]
|
||||
[gd_scene load_steps=37 format=2]
|
||||
|
||||
[ext_resource path="res://objects/enemy/constant_bleed.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://graphics/enemy/boss/scrump_gore/tentacle5.png" type="Texture" id=2]
|
||||
|
@ -16,10 +16,15 @@
|
|||
[ext_resource path="res://graphics/enemy/boss/scrump_gore/tentacle4.png" type="Texture" id=14]
|
||||
[ext_resource path="res://graphics/enemy/boss/scrump_gore/tentacle2.png" type="Texture" id=15]
|
||||
[ext_resource path="res://scripts/launch_rigid.gd" type="Script" id=16]
|
||||
[ext_resource path="res://shaders/scale3x.gdshader" type="Shader" id=17]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id=21]
|
||||
bounce = 0.3
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=22]
|
||||
shader = ExtResource( 17 )
|
||||
shader_param/pixel_scale = 1.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=17]
|
||||
radius = 7.26425
|
||||
height = 4.59118
|
||||
|
@ -91,6 +96,7 @@ height = 14.0
|
|||
physics_material_override = SubResource( 21 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Brain1"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 27, 27 )
|
||||
texture = ExtResource( 9 )
|
||||
|
||||
|
@ -115,6 +121,7 @@ position = Vector2( 48, 11 )
|
|||
position = Vector2( 37, 29 )
|
||||
|
||||
[node name="Sprite2" type="Sprite" parent="Brain2"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 27, 27 )
|
||||
texture = ExtResource( 12 )
|
||||
|
||||
|
@ -133,6 +140,7 @@ position = Vector2( 44, 7 )
|
|||
position = Vector2( 32, 25 )
|
||||
|
||||
[node name="Sprite3" type="Sprite" parent="Brain3"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 27, 27 )
|
||||
texture = ExtResource( 11 )
|
||||
|
||||
|
@ -148,6 +156,7 @@ physics_material_override = SubResource( 21 )
|
|||
position = Vector2( 49, 23 )
|
||||
|
||||
[node name="Sprite3" type="Sprite" parent="Brain4"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 27, 27 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
|
@ -165,6 +174,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 1, -6 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Eye"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 21, 12 )
|
||||
texture = ExtResource( 6 )
|
||||
|
||||
|
@ -182,6 +192,7 @@ position = Vector2( 6, 8 )
|
|||
position = Vector2( 25, 5 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Eyestalk"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
|
@ -217,6 +228,7 @@ position = Vector2( 42, 26 )
|
|||
position = Vector2( 33, 28 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="UpperHead"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 13 )
|
||||
|
||||
|
@ -248,6 +260,7 @@ position = Vector2( 35, 37 )
|
|||
position = Vector2( 44, 37 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="LowerHead"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 10 )
|
||||
|
||||
|
@ -264,6 +277,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 19, 37 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Tentacle1"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
|
@ -280,6 +294,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 23, 38 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Tentacle2"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 15 )
|
||||
|
||||
|
@ -296,6 +311,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 27, 38 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Tentacle3"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 7 )
|
||||
|
||||
|
@ -311,6 +327,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 33, 38 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Tentacle4"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 14 )
|
||||
|
||||
|
@ -326,6 +343,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 38, 38 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Tentacle5"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
|
@ -341,6 +359,7 @@ script = ExtResource( 16 )
|
|||
position = Vector2( 43, 38 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Tentacle6"]
|
||||
material = SubResource( 22 )
|
||||
position = Vector2( 26, 27 )
|
||||
texture = ExtResource( 8 )
|
||||
|
||||
|
|
110
shaders/scale3x.gdshader
Normal file
110
shaders/scale3x.gdshader
Normal file
|
@ -0,0 +1,110 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
const vec4 background = vec4(1., 1., 1., 0.);
|
||||
|
||||
uniform float pixel_scale: hint_range(0.0, 1.0) = 1.0;
|
||||
|
||||
float dist(vec4 c1, vec4 c2) {
|
||||
return (c1 == c2) ? 0.0 : abs(c1.r - c2.r) + abs(c1.g - c2.g) + abs(c1.b - c2.b);
|
||||
}
|
||||
|
||||
bool similar(vec4 c1, vec4 c2, vec4 input) {
|
||||
return (c1 == c2 || (dist(c1, c2) <= dist(input, c2) && dist(c1, c2) <= dist(input, c1)));
|
||||
}
|
||||
|
||||
bool different(vec4 c1, vec4 c2, vec4 input) {
|
||||
return !similar(c1, c2, input);
|
||||
}
|
||||
|
||||
// rotsprite 3x enlargement algorithm:
|
||||
// suppose we are looking at input pixel cE which is surrounded by 8 other
|
||||
// pixels:
|
||||
// cA cB cC
|
||||
// cD cE cF
|
||||
// cG cH cI
|
||||
// and for that 1 input pixel cE we want to output 4 pixels oA, oB, oC, and oD:
|
||||
// E0 E1 E2
|
||||
// E3 E4 E5
|
||||
// E6 E7 E8
|
||||
vec4 scale3x(sampler2D tex, vec2 uv, vec2 pixel_size) {
|
||||
vec4 cE = texture(tex, uv);
|
||||
cE = cE.a == 0.0 ? background : cE;
|
||||
|
||||
vec4 cD = texture(tex, uv + pixel_size * vec2(-1., .0));
|
||||
cD = cD.a == 0.0 ? background : cD;
|
||||
vec4 cF = texture(tex, uv + pixel_size * vec2(1., .0));
|
||||
cF = cF.a == 0.0 ? background : cF;
|
||||
vec4 cH = texture(tex, uv + pixel_size * vec2(.0, 1.));
|
||||
cH = cH.a == 0.0 ? background : cH;
|
||||
vec4 cB = texture(tex, uv + pixel_size * vec2(.0, -1.));
|
||||
cB = cB.a == 0.0 ? background : cB;
|
||||
vec4 cA = texture(tex, uv + pixel_size * vec2(-1., -1.));
|
||||
cA = cA.a == 0.0 ? background : cA;
|
||||
vec4 cI = texture(tex, uv + pixel_size * vec2(1., 1.));
|
||||
cI = cI.a == 0.0 ? background : cI;
|
||||
vec4 cG = texture(tex, uv + pixel_size * vec2(-1., 1.));
|
||||
cG = cG.a == 0.0 ? background : cG;
|
||||
vec4 cC = texture(tex, uv + pixel_size * vec2(1., -1.));
|
||||
cC = cC.a == 0.0 ? background : cC;
|
||||
|
||||
if (different(cD,cF, cE)
|
||||
&& different(cH,cB, cE)
|
||||
&& ((similar(cE, cD, cE) || similar(cE, cH, cE) || similar(cE, cF, cE) || similar(cE, cB, cE) ||
|
||||
((different(cA, cI, cE) || similar(cE, cG, cE) || similar(cE, cC, cE)) &&
|
||||
(different(cG, cC, cE) || similar(cE, cA, cE) || similar(cE, cI, cE))))))
|
||||
{
|
||||
vec2 unit = uv - (floor(uv / pixel_size) * pixel_size);
|
||||
vec2 pixel_3_size = pixel_size / 3.0;
|
||||
|
||||
// E0
|
||||
if (unit.x < pixel_3_size.x && unit.y < pixel_3_size.y) {
|
||||
return similar(cB, cD, cE) ? cB : cE;
|
||||
}
|
||||
|
||||
|
||||
// E1
|
||||
if (unit.x < pixel_3_size.x * 2.0 && unit.y < pixel_3_size.y) {
|
||||
return (similar(cB, cD, cE) && different(cE, cC, cE))
|
||||
|| (similar(cB, cF, cE) && different(cE, cA, cE)) ? cB : cE;
|
||||
}
|
||||
|
||||
// E2
|
||||
if (unit.y < pixel_3_size.y) {
|
||||
return similar(cB, cF, cE) ? cB : cE;
|
||||
}
|
||||
|
||||
// E3
|
||||
if (unit.x < pixel_3_size.x && unit.y < pixel_3_size.y * 2.0) {
|
||||
return (similar(cB, cD, cE) && different(cE, cG, cE)
|
||||
|| (similar(cH, cD, cE) && different(cE, cA, cE))) ? cD : cE;
|
||||
}
|
||||
|
||||
// E5
|
||||
if (unit.x >= pixel_3_size.x * 2.0 && unit.x < pixel_3_size.x * 3.0 && unit.y < pixel_3_size.y * 2.0) {
|
||||
return (similar(cB, cF, cE) && different(cE, cI, cE))
|
||||
|| (similar(cH, cF, cE) && different(cE, cC, cE)) ? cF : cE;
|
||||
}
|
||||
|
||||
// E6
|
||||
if (unit.x < pixel_3_size.x && unit.y >= pixel_3_size.y * 2.0) {
|
||||
return similar(cH, cD, cE) ? cH : cE;
|
||||
}
|
||||
|
||||
// E7
|
||||
if (unit.x < pixel_3_size.x * 2.0 && unit.y >= pixel_3_size.y * 2.0) {
|
||||
return (similar(cH, cD, cE) && different(cE, cI, cE))
|
||||
|| (similar(cH, cF, cE) && different(cE, cG, cE)) ? cH : cE;
|
||||
}
|
||||
|
||||
// E8
|
||||
if (unit.y >= pixel_3_size.y * 2.0) {
|
||||
return similar(cH, cF, cE) ? cH : cE;
|
||||
}
|
||||
}
|
||||
|
||||
return cE;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
COLOR = scale3x(TEXTURE, UV, TEXTURE_PIXEL_SIZE * pixel_scale);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue