├── README.md ├── default_env.tres ├── icon.png ├── icon.png.import ├── main.tscn ├── noise.png ├── noise.png.import ├── preview.gif └── project.godot /README.md: -------------------------------------------------------------------------------- 1 | # godot3-shaders-samples 2 | Godot 3 shaders samples 3 | 4 | Here are some shader examples for Godot 3 5 | Check shader comment (in source) for more details 6 | (Go in sprite>material>shader) 7 | 8 | ![preview](https://raw.githubusercontent.com/Guaranapps/godot3-shaders-samples/master/preview.gif) 9 | 10 | ### Source code made by Guaranapps : 11 | - [Website](http://guaranapps.com) 12 | - [Facebook](https://www.facebook.com/Guaranapps/) 13 | - [Twitter](https://twitter.com/guaranapps) 14 | - [Youtube](https://www.youtube.com/channel/UCw1piXgMgeX6sr3W679sRBg) 15 | - [Google play](https://play.google.com/store/apps/developer?id=Guaranapps) 16 | - [Linkedin](https://www.linkedin.com/company/guaranapps/) 17 | 18 | -------------------------------------------------------------------------------- /default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | radiance_size = 4 6 | sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) 7 | sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) 8 | sky_curve = 0.25 9 | sky_energy = 1.0 10 | ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) 11 | ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) 12 | ground_curve = 0.01 13 | ground_energy = 1.0 14 | sun_color = Color( 1, 1, 1, 1 ) 15 | sun_latitude = 35.0 16 | sun_longitude = 0.0 17 | sun_angle_min = 1.0 18 | sun_angle_max = 100.0 19 | sun_curve = 0.05 20 | sun_energy = 16.0 21 | texture_size = 2 22 | 23 | [resource] 24 | 25 | background_mode = 2 26 | background_sky = SubResource( 1 ) 27 | background_sky_custom_fov = 0.0 28 | background_color = Color( 0, 0, 0, 1 ) 29 | background_energy = 1.0 30 | background_canvas_max_layer = 0 31 | ambient_light_color = Color( 0, 0, 0, 1 ) 32 | ambient_light_energy = 1.0 33 | ambient_light_sky_contribution = 1.0 34 | fog_enabled = false 35 | fog_color = Color( 0.5, 0.6, 0.7, 1 ) 36 | fog_sun_color = Color( 1, 0.9, 0.7, 1 ) 37 | fog_sun_amount = 0.0 38 | fog_depth_enabled = true 39 | fog_depth_begin = 10.0 40 | fog_depth_curve = 1.0 41 | fog_transmit_enabled = false 42 | fog_transmit_curve = 1.0 43 | fog_height_enabled = false 44 | fog_height_min = 0.0 45 | fog_height_max = 100.0 46 | fog_height_curve = 1.0 47 | tonemap_mode = 0 48 | tonemap_exposure = 1.0 49 | tonemap_white = 1.0 50 | auto_exposure_enabled = false 51 | auto_exposure_scale = 0.4 52 | auto_exposure_min_luma = 0.05 53 | auto_exposure_max_luma = 8.0 54 | auto_exposure_speed = 0.5 55 | ss_reflections_enabled = false 56 | ss_reflections_max_steps = 64 57 | ss_reflections_fade_in = 0.15 58 | ss_reflections_fade_out = 2.0 59 | ss_reflections_depth_tolerance = 0.2 60 | ss_reflections_roughness = true 61 | ssao_enabled = false 62 | ssao_radius = 1.0 63 | ssao_intensity = 1.0 64 | ssao_radius2 = 0.0 65 | ssao_intensity2 = 1.0 66 | ssao_bias = 0.01 67 | ssao_light_affect = 0.0 68 | ssao_color = Color( 0, 0, 0, 1 ) 69 | ssao_quality = 0 70 | ssao_blur = 3 71 | ssao_edge_sharpness = 4.0 72 | dof_blur_far_enabled = false 73 | dof_blur_far_distance = 10.0 74 | dof_blur_far_transition = 5.0 75 | dof_blur_far_amount = 0.1 76 | dof_blur_far_quality = 1 77 | dof_blur_near_enabled = false 78 | dof_blur_near_distance = 2.0 79 | dof_blur_near_transition = 1.0 80 | dof_blur_near_amount = 0.1 81 | dof_blur_near_quality = 1 82 | glow_enabled = false 83 | glow_levels/1 = false 84 | glow_levels/2 = false 85 | glow_levels/3 = true 86 | glow_levels/4 = false 87 | glow_levels/5 = true 88 | glow_levels/6 = false 89 | glow_levels/7 = false 90 | glow_intensity = 0.8 91 | glow_strength = 1.0 92 | glow_bloom = 0.0 93 | glow_blend_mode = 2 94 | glow_hdr_threshold = 1.0 95 | glow_hdr_scale = 2.0 96 | glow_bicubic_upscale = false 97 | adjustment_enabled = false 98 | adjustment_brightness = 1.0 99 | adjustment_contrast = 1.0 100 | adjustment_saturation = 1.0 101 | 102 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Guaranapps/godot3-shaders-samples/76504d15d8d41fe411deb087f38b199f624a9bb5/icon.png -------------------------------------------------------------------------------- /icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | 7 | [deps] 8 | 9 | source_file="res://icon.png" 10 | source_md5="ae7e641067601e2184afcade49abd283" 11 | 12 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 13 | dest_md5="84511021bbc8c9d37c7f0f4d181de883" 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/normal_map=0 21 | flags/repeat=0 22 | flags/filter=true 23 | flags/mipmaps=false 24 | flags/anisotropic=false 25 | flags/srgb=2 26 | process/fix_alpha_border=true 27 | process/premult_alpha=false 28 | process/HDR_as_SRGB=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=true 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=25 format=2] 2 | 3 | [ext_resource path="res://icon.png" type="Texture" id=1] 4 | [ext_resource path="res://noise.png" type="Texture" id=2] 5 | 6 | [sub_resource type="Shader" id=1] 7 | 8 | code = "shader_type canvas_item; 9 | 10 | //call for each pixels 11 | void fragment() { 12 | //- COLOR is output pixel 13 | //- TEXTURE is default sprite texture 14 | //- UV is mapping coordinates 15 | //texture(sampler2D,vec2) read interpolated value of texture (1st parameter) on coordinates UV (normalize between 0 and 1) 16 | COLOR = texture(TEXTURE,UV); 17 | }" 18 | 19 | [sub_resource type="ShaderMaterial" id=2] 20 | 21 | render_priority = 0 22 | shader = SubResource( 1 ) 23 | 24 | [sub_resource type="Shader" id=3] 25 | 26 | code = "shader_type canvas_item; 27 | 28 | //Number of texture repetition 29 | uniform float repeat_factor=2.0; 30 | 31 | void fragment() { 32 | //We use \"mod\" function to repeat texture. 33 | //UV will go from 0 to repeat_factor, as texture function expects values between [0-1] we modulate result to repeat 34 | COLOR = texture(TEXTURE,mod(UV*repeat_factor,vec2(1.0,1.0))); 35 | }" 36 | 37 | [sub_resource type="ShaderMaterial" id=4] 38 | 39 | render_priority = 0 40 | shader = SubResource( 3 ) 41 | shader_param/repeat_factor = 2.0 42 | _sections_unfolded = [ "shader_param" ] 43 | 44 | [sub_resource type="Shader" id=5] 45 | 46 | code = "shader_type canvas_item; 47 | 48 | uniform float frequency=5.0; 49 | uniform float speed=1.0; 50 | 51 | void fragment() { 52 | //sinus function give values between [-1;1] so (sin(..)+1)/2 give values between [0;1] 53 | //basically we will display function y=sin(x) 54 | //here TIME is use as offset with speed variable control 55 | float limit_val=(sin(UV.x*frequency+TIME*speed)+1.0)/2.0; 56 | if(UV.y