Browse Source

ported over 2d sprite shaders to 3.0

jaggygames 7 years ago
parent
commit
b24ee4a44a

+ 101 - 0
2d/sprite_shaders/default_env.tres

@@ -0,0 +1,101 @@
+[gd_resource type="Environment" load_steps=2 format=2]
+
+[sub_resource type="ProceduralSky" id=1]
+
+radiance_size = 4
+sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
+sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
+sky_curve = 0.25
+sky_energy = 1.0
+ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
+ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
+ground_curve = 0.01
+ground_energy = 1.0
+sun_color = Color( 1, 1, 1, 1 )
+sun_latitude = 35.0
+sun_longitude = 0.0
+sun_angle_min = 1.0
+sun_angle_max = 100.0
+sun_curve = 0.05
+sun_energy = 16.0
+texture_size = 2
+
+[resource]
+
+background_mode = 2
+background_sky = SubResource( 1 )
+background_sky_custom_fov = 0.0
+background_color = Color( 0, 0, 0, 1 )
+background_energy = 1.0
+background_canvas_max_layer = 0
+ambient_light_color = Color( 0, 0, 0, 1 )
+ambient_light_energy = 1.0
+ambient_light_sky_contribution = 1.0
+fog_enabled = false
+fog_color = Color( 0.5, 0.6, 0.7, 1 )
+fog_sun_color = Color( 1, 0.9, 0.7, 1 )
+fog_sun_amount = 0.0
+fog_depth_enabled = true
+fog_depth_begin = 10.0
+fog_depth_curve = 1.0
+fog_transmit_enabled = false
+fog_transmit_curve = 1.0
+fog_height_enabled = false
+fog_height_min = 0.0
+fog_height_max = 100.0
+fog_height_curve = 1.0
+tonemap_mode = 0
+tonemap_exposure = 1.0
+tonemap_white = 1.0
+auto_exposure_enabled = false
+auto_exposure_scale = 0.4
+auto_exposure_min_luma = 0.05
+auto_exposure_max_luma = 8.0
+auto_exposure_speed = 0.5
+ss_reflections_enabled = false
+ss_reflections_max_steps = 64
+ss_reflections_fade_in = 0.15
+ss_reflections_fade_out = 2.0
+ss_reflections_depth_tolerance = 0.2
+ss_reflections_roughness = true
+ssao_enabled = false
+ssao_radius = 1.0
+ssao_intensity = 1.0
+ssao_radius2 = 0.0
+ssao_intensity2 = 1.0
+ssao_bias = 0.01
+ssao_light_affect = 0.0
+ssao_color = Color( 0, 0, 0, 1 )
+ssao_quality = 0
+ssao_blur = 3
+ssao_edge_sharpness = 4.0
+dof_blur_far_enabled = false
+dof_blur_far_distance = 10.0
+dof_blur_far_transition = 5.0
+dof_blur_far_amount = 0.1
+dof_blur_far_quality = 1
+dof_blur_near_enabled = false
+dof_blur_near_distance = 2.0
+dof_blur_near_transition = 1.0
+dof_blur_near_amount = 0.1
+dof_blur_near_quality = 1
+glow_enabled = false
+glow_levels/1 = false
+glow_levels/2 = false
+glow_levels/3 = true
+glow_levels/4 = false
+glow_levels/5 = true
+glow_levels/6 = false
+glow_levels/7 = false
+glow_intensity = 0.8
+glow_strength = 1.0
+glow_bloom = 0.0
+glow_blend_mode = 2
+glow_hdr_threshold = 1.0
+glow_hdr_scale = 2.0
+glow_bicubic_upscale = false
+adjustment_enabled = false
+adjustment_brightness = 1.0
+adjustment_contrast = 1.0
+adjustment_saturation = 1.0
+

BIN
2d/sprite_shaders/godotea.png


+ 32 - 0
2d/sprite_shaders/godotea.png.import

@@ -0,0 +1,32 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/godotea.png-418ef4f4be671d254e4230569960266a.stex"
+
+[deps]
+
+source_file="res://godotea.png"
+source_md5="2aff20dcb71d855c595ac3520425109f"
+
+dest_files=[ "res://.import/godotea.png-418ef4f4be671d254e4230569960266a.stex" ]
+dest_md5="d8cfb53d0f75ac9996988654b4ee71d3"
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=true
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+stream=false
+size_limit=0
+detect_3d=true
+svg/scale=1.0

BIN
2d/sprite_shaders/icon.png


+ 32 - 0
2d/sprite_shaders/icon.png.import

@@ -0,0 +1,32 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
+
+[deps]
+
+source_file="res://icon.png"
+source_md5="9830477e08637bb08b61910478973fcb"
+
+dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
+dest_md5="5b0e07992d64807655cea54b12c03c41"
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=true
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+stream=false
+size_limit=0
+detect_3d=true
+svg/scale=1.0

+ 19 - 0
2d/sprite_shaders/project.godot

@@ -0,0 +1,19 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+;   [section] ; section goes between []
+;   param=value ; assign values to parameters
+
+config_version=3
+
+[application]
+
+config/name="2D Shaders for Sprites"
+run/main_scene="res://sprite_shaders.tscn"
+config/icon="res://icon.png"
+
+[rendering]
+
+environment/default_environment="res://default_env.tres"

+ 420 - 0
2d/sprite_shaders/sprite_shaders.tscn

@@ -0,0 +1,420 @@
+[gd_scene load_steps=23 format=2]
+
+[ext_resource path="res://godotea.png" type="Texture" id=1]
+
+[sub_resource type="Shader" id=1]
+
+code = "shader_type canvas_item;
+uniform float outline_width=2.0;
+uniform vec4 outline_color: hint_color;
+
+void fragment(){
+vec4 col = texture(TEXTURE,UV);
+vec2 ps = TEXTURE_PIXEL_SIZE;
+float a;
+float maxa=col.a;
+float mina=col.a;
+a=texture(TEXTURE,UV+vec2(0,-outline_width)*ps).a;
+maxa=max(a,maxa); 
+mina=min(a,mina);
+a=texture(TEXTURE,UV+vec2(0,outline_width)*ps).a;
+maxa=max(a,maxa); 
+mina=min(a,mina);
+a=texture(TEXTURE,UV+vec2(-outline_width,0)*ps).a;
+maxa=max(a,maxa); 
+mina=min(a,mina);
+a=texture(TEXTURE,UV+vec2(outline_width,0)*ps).a;
+maxa=max(a,maxa); 
+mina=min(a,mina);
+
+COLOR=mix(col,outline_color,maxa-mina);
+}"
+
+[sub_resource type="ShaderMaterial" id=2]
+
+render_priority = 0
+shader = SubResource( 1 )
+shader_param/outline_width = null
+shader_param/outline_color = Color( 0, 1, 0.109375, 1 )
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="ShaderMaterial" id=3]
+
+render_priority = 0
+
+[sub_resource type="Shader" id=4]
+
+code = "shader_type canvas_item;
+uniform float outline_width = 2.0;
+uniform vec4 outline_color: hint_color;
+
+void fragment(){
+	vec4 col = texture(TEXTURE, UV);
+	vec2 ps = TEXTURE_PIXEL_SIZE;
+	float a;
+	float maxa = col.a;
+	float mina = col.a;
+
+	a = texture(TEXTURE, UV + vec2(0, -outline_width)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	a = texture(TEXTURE, UV + vec2(0, outline_width)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	a = texture(TEXTURE, UV + vec2(-outline_width,0)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	a = texture(TEXTURE, UV + vec2(outline_width, 0)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	COLOR = mix(col, outline_color, maxa-mina);
+	}"
+
+[sub_resource type="ShaderMaterial" id=5]
+
+render_priority = 0
+shader = SubResource( 4 )
+shader_param/outline_width = 4.0
+shader_param/outline_color = Color( 0, 0, 0, 1 )
+_sections_unfolded = [ "Resource", "shader_param" ]
+
+[sub_resource type="Shader" id=6]
+
+code = "shader_type canvas_item;
+render_mode blend_premul_alpha;
+
+//this shader only works properly with premultiplied alpha blend mode
+uniform float aura_width = 2.0;
+uniform vec4 aura_color:hint_color; 
+
+void fragment(){
+	vec4 col = texture(TEXTURE, UV);
+	vec2 ps = TEXTURE_PIXEL_SIZE;
+	float a;
+	float maxa = col.a;
+	float mina = col.a;
+	
+	a = texture(TEXTURE, UV + vec2(0, -aura_width)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	a = texture(TEXTURE, UV + vec2(0, aura_width)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	a = texture(TEXTURE, UV + vec2(-aura_width, 0)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	a = texture(TEXTURE, UV + vec2(aura_width, 0)*ps).a;
+	maxa = max(a, maxa); 
+	mina = min(a, mina);
+	
+	col.rgb *= col.a;
+	
+	COLOR = col;
+	float auraa = (maxa-mina);
+	
+	COLOR.rgb += aura_color.rgb*(auraa);
+	
+	}"
+
+[sub_resource type="ShaderMaterial" id=7]
+
+render_priority = 0
+shader = SubResource( 6 )
+shader_param/aura_width = 6.0
+shader_param/aura_color = Color( 0.143326, 0.33235, 0.677765, 0.442 )
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=8]
+
+code = "shader_type canvas_item;
+render_mode blend_mix;
+
+uniform float radius = 4.0;
+
+void fragment(){
+	vec4 col = texture(TEXTURE, UV);
+	vec2 ps = TEXTURE_PIXEL_SIZE;
+	
+	col += texture(TEXTURE, UV + vec2(0, -radius)*ps);
+	col += texture(TEXTURE, UV + vec2(0, radius)*ps);
+	col += texture(TEXTURE, UV + vec2(-radius, 0)*ps);
+	col += texture(TEXTURE, UV + vec2(radius, 0)*ps);
+	col /= 5.0;
+	
+	COLOR = col;
+	}"
+
+[sub_resource type="ShaderMaterial" id=9]
+
+render_priority = 0
+shader = SubResource( 8 )
+shader_param/radius = 4.0
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=10]
+
+code = "shader_type canvas_item;
+
+render_mode blend_mix;
+uniform float fattyness = 2.0;
+
+void fragment(){
+	vec2 ruv = UV - vec2(0.5,0.5);
+	vec2 dir = normalize(ruv);
+	float len = length(ruv);	
+	
+	len = pow(len*2.0, fattyness)*0.5;
+	ruv = len*dir;
+	
+	vec4 col = texture(TEXTURE, ruv + vec2(0.5, 0.5));
+	
+	COLOR = col;
+}"
+
+[sub_resource type="ShaderMaterial" id=11]
+
+render_priority = 0
+shader = SubResource( 10 )
+shader_param/fattyness = 3.0
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=12]
+
+code = "shader_type canvas_item;
+render_mode blend_mix;
+
+uniform float radius = 5.0;
+uniform vec4  modulate:hint_color;
+
+void fragment(){
+	vec2 ps = TEXTURE_PIXEL_SIZE;
+	
+	vec4 shadow = texture(TEXTURE, UV + vec2(-radius, -radius)*ps);
+	
+	shadow += texture(TEXTURE, UV + vec2(-radius, 0)*ps);
+	shadow += texture(TEXTURE, UV + vec2(-radius, radius)*ps);
+	shadow += texture(TEXTURE, UV + vec2(0, -radius)*ps);
+	shadow += texture(TEXTURE, UV + vec2(0, radius)*ps);
+	shadow += texture(TEXTURE, UV + vec2(radius, -radius)*ps);
+	shadow += texture(TEXTURE, UV + vec2(radius, 0)*ps);
+	shadow += texture(TEXTURE, UV + vec2(radius, radius)*ps);
+	shadow /= 8.0;
+	shadow *= modulate;
+	
+	vec4 col = texture(TEXTURE, UV);
+	COLOR = mix(shadow, col, col.a);
+	}"
+
+[sub_resource type="ShaderMaterial" id=13]
+
+render_priority = 0
+shader = SubResource( 12 )
+shader_param/radius = 8.0
+shader_param/modulate = Color( 0, 0, 0, 0.501961 )
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=14]
+
+code = "shader_type canvas_item;
+render_mode blend_mix;
+
+uniform vec2 offset = vec2(8,8);
+uniform vec4 modulate:hint_color;
+
+void fragment(){
+	vec2 ps = TEXTURE_PIXEL_SIZE;
+	
+	vec4 shadow = vec4(modulate.rgb, texture(TEXTURE, UV - offset*ps).a*modulate.a);
+	vec4 col = texture(TEXTURE, UV);
+	
+	COLOR = mix(shadow, col, col.a);
+	}"
+
+[sub_resource type="ShaderMaterial" id=15]
+
+render_priority = 0
+shader = SubResource( 14 )
+shader_param/offset = Vector2( 20, 20 )
+shader_param/modulate = Color( 0.90625, 0.269043, 0.746948, 1 )
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=16]
+
+code = "shader_type canvas_item;
+
+render_mode blend_mix;
+uniform vec4 modulate:hint_color;
+
+void fragment(){
+	
+	COLOR = vec4(modulate.rgb, texture(TEXTURE, UV).a*modulate.a);
+	
+	}"
+
+[sub_resource type="ShaderMaterial" id=17]
+
+render_priority = 0
+shader = SubResource( 16 )
+shader_param/modulate = Color( 1, 0.0234375, 0.481201, 0.596706 )
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=18]
+
+code = "shader_type canvas_item;
+render_mode blend_premul_alpha;
+
+uniform float radius = 2.0;
+uniform float amount = 0.6;
+
+void fragment(){
+	float r = radius;
+	vec2 ps = TEXTURE_PIXEL_SIZE;
+	vec4 col = texture(TEXTURE, UV);
+	vec4 glow = col;
+	
+	glow += texture(TEXTURE, UV + vec2(-r, -r)*ps);
+	glow += texture(TEXTURE, UV + vec2(-r, 0)*ps);
+	glow += texture(TEXTURE, UV + vec2(-r, r)*ps);
+	glow += texture(TEXTURE, UV + vec2(0, -r)*ps);
+	glow += texture(TEXTURE, UV + vec2(0, r)*ps);
+	glow += texture(TEXTURE, UV + vec2(r, -r)*ps);
+	glow += texture(TEXTURE, UV + vec2(r, 0)*ps);
+	glow += texture(TEXTURE, UV + vec2(r, r)*ps);
+	
+	r *= 2.0;
+	glow += texture(TEXTURE, UV + vec2(-r, -r)*ps);
+	glow += texture(TEXTURE, UV + vec2(-r, 0)*ps);
+	glow += texture(TEXTURE, UV + vec2(-r, r)*ps);
+	glow += texture(TEXTURE, UV + vec2(0, -r)*ps);
+	glow += texture(TEXTURE, UV + vec2(0, r)*ps);
+	glow += texture(TEXTURE, UV + vec2(r, -r)*ps);
+	glow += texture(TEXTURE, UV + vec2(r, 0)*ps);
+	glow += texture(TEXTURE, UV + vec2(r, r)*ps);
+	
+	glow /= 17.0;
+	glow *= amount;
+	col.rgb *= col.a;
+	
+	COLOR = glow + col;
+	
+	}"
+
+[sub_resource type="ShaderMaterial" id=19]
+
+render_priority = 0
+shader = SubResource( 18 )
+shader_param/radius = 12.0
+shader_param/amount = 0.5
+_sections_unfolded = [ "shader_param" ]
+
+[sub_resource type="Shader" id=20]
+
+code = "shader_type canvas_item;
+render_mode blend_mix;
+
+uniform float amount = 20.0;
+
+void fragment(){
+	
+	vec2 uv = UV*0.05;
+	float a = fract(sin(dot(UV, vec2(12.9898, 78.233)))*438.5453);
+	vec4 col = texture(TEXTURE, UV);
+	
+	col.a *= pow(a, amount);
+	
+	COLOR = col;
+	}"
+
+[sub_resource type="ShaderMaterial" id=21]
+
+render_priority = 0
+shader = SubResource( 20 )
+shader_param/amount = 4.0
+_sections_unfolded = [ "shader_param" ]
+
+[node name="shaders" type="Node2D" index="0"]
+
+material = SubResource( 2 )
+position = Vector2( 263.737, 179.444 )
+scale = Vector2( 0.3, 0.3 )
+_sections_unfolded = [ "Material", "Region", "Transform" ]
+
+[node name="normal" type="Sprite" parent="." index="0"]
+
+material = SubResource( 3 )
+position = Vector2( -2.16144, 0 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Offset" ]
+
+[node name="outline" type="Sprite" parent="." index="1"]
+
+material = SubResource( 5 )
+position = Vector2( 400, 0 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+[node name="aura" type="Sprite" parent="." index="2"]
+
+material = SubResource( 7 )
+position = Vector2( 800, 0 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Animation", "Material", "Offset", "Region", "Transform", "Visibility", "Z Index" ]
+
+[node name="blur" type="Sprite" parent="." index="3"]
+
+material = SubResource( 9 )
+position = Vector2( 1200, 0 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+[node name="fatty" type="Sprite" parent="." index="4"]
+
+material = SubResource( 11 )
+position = Vector2( 1600, 0 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+[node name="dropshadow" type="Sprite" parent="." index="5"]
+
+material = SubResource( 13 )
+position = Vector2( 0, 800 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+[node name="offsetshadow" type="Sprite" parent="." index="6"]
+
+material = SubResource( 15 )
+position = Vector2( 400, 800 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+[node name="silouette" type="Sprite" parent="." index="7"]
+
+material = SubResource( 17 )
+position = Vector2( 800, 800 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+[node name="glow" type="Sprite" parent="." index="8"]
+
+material = SubResource( 19 )
+position = Vector2( 1200, 800 )
+texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Transform", "Z Index" ]
+
+[node name="dissintegrate" type="Sprite" parent="." index="9"]
+
+material = SubResource( 21 )
+position = Vector2( 1600, 800 )
+texture = ExtResource( 1 )
+region_rect = Rect2( 141, 115, 39, 6 )
+_sections_unfolded = [ "Material", "Transform" ]
+
+