├── GIF.gif ├── Global_Illumination.zip ├── Global_Illumination ├── Global_Illumination.yyp ├── objects │ └── obj_gi │ │ ├── CleanUp_0.gml │ │ ├── Create_0.gml │ │ ├── Draw_73.gml │ │ ├── Draw_76.gml │ │ ├── Step_1.gml │ │ └── obj_gi.yy ├── options │ ├── linux │ │ └── options_linux.yy │ ├── mac │ │ └── options_mac.yy │ ├── main │ │ └── options_main.yy │ ├── operagx │ │ └── options_operagx.yy │ └── windows │ │ └── options_windows.yy ├── rooms │ └── room1 │ │ └── room1.yy ├── shaders │ ├── shd_denoise │ │ ├── shd_denoise.fsh │ │ ├── shd_denoise.vsh │ │ └── shd_denoise.yy │ ├── shd_distfld │ │ ├── shd_distfld.fsh │ │ ├── shd_distfld.vsh │ │ └── shd_distfld.yy │ ├── shd_gilight │ │ ├── shd_gilight.fsh │ │ ├── shd_gilight.vsh │ │ └── shd_gilight.yy │ ├── shd_jumpfld │ │ ├── shd_jumpfld.fsh │ │ ├── shd_jumpfld.vsh │ │ └── shd_jumpfld.yy │ └── shd_prejump │ │ ├── shd_prejump.fsh │ │ ├── shd_prejump.vsh │ │ └── shd_prejump.yy └── sprites │ ├── spr_bluenoise │ ├── e6b68fc2-ba7d-42b1-9485-01bd0548adda.png │ ├── layers │ │ └── e6b68fc2-ba7d-42b1-9485-01bd0548adda │ │ │ └── 4a0088c3-adb2-46d7-85a2-8a2b5bfcdc4d.png │ └── spr_bluenoise.yy │ └── spr_scenegi │ ├── 51e15803-6dc2-4d7e-a198-0d6a76c66511.png │ ├── layers │ └── 51e15803-6dc2-4d7e-a198-0d6a76c66511 │ │ └── 33e9aa65-0e7a-4e69-9a0f-25e73072f14a.png │ └── spr_scenegi.yy └── README.md /GIF.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yaazarai/2DGI/06660fb368133c026f05bf16d5f09e86e70f6975/GIF.gif -------------------------------------------------------------------------------- /Global_Illumination.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yaazarai/2DGI/06660fb368133c026f05bf16d5f09e86e70f6975/Global_Illumination.zip -------------------------------------------------------------------------------- /Global_Illumination/Global_Illumination.yyp: -------------------------------------------------------------------------------- 1 | { 2 | "resources": [ 3 | {"id":{"name":"Shd_DENOISE","path":"shaders/Shd_DENOISE/Shd_DENOISE.yy",},"order":7,}, 4 | {"id":{"name":"Shd_GILIGHT","path":"shaders/Shd_GILIGHT/Shd_GILIGHT.yy",},"order":6,}, 5 | {"id":{"name":"Shd_DISTFLD","path":"shaders/Shd_DISTFLD/Shd_DISTFLD.yy",},"order":2,}, 6 | {"id":{"name":"Shd_JUMPFLD","path":"shaders/Shd_JUMPFLD/Shd_JUMPFLD.yy",},"order":1,}, 7 | {"id":{"name":"Spr_SceneGI","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",},"order":0,}, 8 | {"id":{"name":"Shd_PREJUMP","path":"shaders/Shd_PREJUMP/Shd_PREJUMP.yy",},"order":0,}, 9 | {"id":{"name":"Obj_GI","path":"objects/Obj_GI/Obj_GI.yy",},"order":0,}, 10 | {"id":{"name":"Spr_Bluenoise","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",},"order":1,}, 11 | {"id":{"name":"Room1","path":"rooms/Room1/Room1.yy",},"order":0,}, 12 | ], 13 | "Options": [ 14 | {"name":"Linux","path":"options/linux/options_linux.yy",}, 15 | {"name":"macOS","path":"options/mac/options_mac.yy",}, 16 | {"name":"Main","path":"options/main/options_main.yy",}, 17 | {"name":"Windows","path":"options/windows/options_windows.yy",}, 18 | {"name":"operagx","path":"options/operagx/options_operagx.yy",}, 19 | ], 20 | "defaultScriptType": 1, 21 | "isEcma": false, 22 | "configs": { 23 | "name": "Default", 24 | "children": [], 25 | }, 26 | "RoomOrderNodes": [ 27 | {"roomId":{"name":"Room1","path":"rooms/Room1/Room1.yy",},}, 28 | ], 29 | "Folders": [ 30 | {"folderPath":"folders/Sprites.yy","order":1,"resourceVersion":"1.0","name":"Sprites","tags":[],"resourceType":"GMFolder",}, 31 | {"folderPath":"folders/Tile Sets.yy","order":2,"resourceVersion":"1.0","name":"Tile Sets","tags":[],"resourceType":"GMFolder",}, 32 | {"folderPath":"folders/Sounds.yy","order":3,"resourceVersion":"1.0","name":"Sounds","tags":[],"resourceType":"GMFolder",}, 33 | {"folderPath":"folders/Paths.yy","order":4,"resourceVersion":"1.0","name":"Paths","tags":[],"resourceType":"GMFolder",}, 34 | {"folderPath":"folders/Scripts.yy","order":5,"resourceVersion":"1.0","name":"Scripts","tags":[],"resourceType":"GMFolder",}, 35 | {"folderPath":"folders/Shaders.yy","order":6,"resourceVersion":"1.0","name":"Shaders","tags":[],"resourceType":"GMFolder",}, 36 | {"folderPath":"folders/Fonts.yy","order":7,"resourceVersion":"1.0","name":"Fonts","tags":[],"resourceType":"GMFolder",}, 37 | {"folderPath":"folders/Timelines.yy","order":8,"resourceVersion":"1.0","name":"Timelines","tags":[],"resourceType":"GMFolder",}, 38 | {"folderPath":"folders/Objects.yy","order":9,"resourceVersion":"1.0","name":"Objects","tags":[],"resourceType":"GMFolder",}, 39 | {"folderPath":"folders/Rooms.yy","order":10,"resourceVersion":"1.0","name":"Rooms","tags":[],"resourceType":"GMFolder",}, 40 | {"folderPath":"folders/Sequences.yy","order":11,"resourceVersion":"1.0","name":"Sequences","tags":[],"resourceType":"GMFolder",}, 41 | {"folderPath":"folders/Animation Curves.yy","order":12,"resourceVersion":"1.0","name":"Animation Curves","tags":[],"resourceType":"GMFolder",}, 42 | {"folderPath":"folders/Notes.yy","order":13,"resourceVersion":"1.0","name":"Notes","tags":[],"resourceType":"GMFolder",}, 43 | {"folderPath":"folders/Extensions.yy","order":14,"resourceVersion":"1.0","name":"Extensions","tags":[],"resourceType":"GMFolder",}, 44 | ], 45 | "AudioGroups": [ 46 | {"targets":-1,"resourceVersion":"1.3","name":"audiogroup_default","resourceType":"GMAudioGroup",}, 47 | ], 48 | "TextureGroups": [ 49 | {"isScaled":true,"compressFormat":"bz2","autocrop":true,"border":2,"mipsToGenerate":0,"groupParent":null,"targets":-1,"resourceVersion":"1.3","name":"Default","resourceType":"GMTextureGroup",}, 50 | ], 51 | "IncludedFiles": [], 52 | "MetaData": { 53 | "IDEVersion": "2022.6.1.26", 54 | }, 55 | "resourceVersion": "1.5", 56 | "name": "Global_Illumination", 57 | "tags": [], 58 | "resourceType": "GMProject", 59 | } -------------------------------------------------------------------------------- /Global_Illumination/objects/obj_gi/CleanUp_0.gml: -------------------------------------------------------------------------------- 1 | for(var i = 0; i < gistage_numb; i++) 2 | if (surface_exists(gistage_surf[i])) surface_free(gistage_surf[i]); 3 | 4 | for(var i = 0; i < gistage_tmpk; i++) 5 | if (surface_exists(gistage_temp[i])) surface_free(gistage_temp[i]); -------------------------------------------------------------------------------- /Global_Illumination/objects/obj_gi/Create_0.gml: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | GI STAGES: (surfaces) 4 | 1. [INITIAL] Initial Scene Render 5 | 2. [PREJUMP] Pre-Jump Flood 6 | 3. [JUMPFLD] Jump flood 7 | 3a. [JMPFLDA] Jump flood pass A 8 | 3b. [JMPFLDB] Jump flood pass B 9 | 4. [DISTFLD] DF from Jump Flood 10 | 5. [FASTNSE] Random noise texture 11 | 6. [GILIGHT] Scene Random Temporal Raymarch 12 | 7. [POSTPRC] Post-Process Bloom 13 | 8. [DENOISE] Denoise Post-Process GI scene. 14 | 15 | How this works: 16 | 1. Take an input scene [STAGE 1] as a surface and then feed the input scene into the current temporal GI surface. 17 | 2. Prepare input scene for jumpflooding [STAGE 2]. 18 | 3. Generate a jumpflood texture [STAGE 2] from the input scene. 19 | 3ab. Jumpflood iterates overitself, requiring two passes/surfaces. 20 | 4. Generate a distance field [STAGE 3] of the input scene from the jump flood. 21 | 5. Generate a texture for random noise [STAGE 4]. 22 | 6. Pass stages 4 & 5 surfaces to the GI shader along with the current temporal GI surface [STAGE 6]. 23 | 6a. Raymarch the scene and get emissive color surfaces. 24 | 6b. If no emissive color is found, check the nearest pixel outside the nearest emissive surface pixel. 25 | 6c. Tonemap the final color for displaying to the surface. 26 | 7. Apply bloom using additive blending [STAGE 7]. 27 | */ 28 | game_set_speed(120, gamespeed_fps); 29 | enum GISTAGES { INITIAL, PREJUMP, JMPFLDA, JMPFLDB, DISTFLD, FASTNSE, POSTPRC, DENOISE } 30 | enum GISHADER { 31 | PREJUMP = Shd_PREJUMP, /* Pre-JumpFlood Setup */ 32 | JUMPFLD = Shd_JUMPFLD, /* Jump Flood */ 33 | DISTFLD = Shd_DISTFLD, /* Distance Field */ 34 | GILIGHT = Shd_GILIGHT, /* Light bounce */ 35 | DENOISE = Shd_DENOISE /* Denoiser */ 36 | } 37 | 38 | gistage_resw = 1920 / 4; // GI resolution 39 | gistage_resh = 1080 / 4; // GI resolution 40 | gistage_rndw = 1920; // GI upscale resolution 41 | gistage_rndh = 1080; // GI upscale resolution 42 | gistage_numb = 9; // GI stages count 43 | gistage_iter = 0; // GI temporal iterator 44 | gistage_tmpk = 2; // GI temporal count 45 | gistage_time = 0; // GI time iterator 46 | gistage_dnse = 0; // Number of Denoise Samples 47 | gistage_curr = 0; // Current GI stage. 48 | /* 49 | The GI stage is cumulative so light bounces accumulate over real-time (see stage 7 draw event). 50 | However if the GI stage is calculated using a for-loop per frame rather than accumuilating 51 | over several frames then the temporal count >2 is necessary. 52 | */ 53 | 54 | 55 | // Grab shader variable uniforms for passing data to shaders. 56 | JUMPFLD_inJdist = shader_get_uniform(GISHADER.JUMPFLD, "in_Jdist"); 57 | JUMPFLD_inResol = shader_get_uniform(GISHADER.JUMPFLD, "in_Resol"); 58 | GILIGHT_inResol = shader_get_uniform(GISHADER.GILIGHT, "in_Resol"); 59 | GILIGHT_inDistfld = shader_get_sampler_index(GISHADER.GILIGHT, "in_Distfld"); 60 | GILIGHT_inFastnse = shader_get_sampler_index(GISHADER.GILIGHT, "in_Fastnse"); 61 | DENOISE_inResol = shader_get_uniform(GISHADER.DENOISE, "in_Resol"); 62 | 63 | // Initialize all GI stage surfaces and GI temporal surfaces. 64 | var i = 0; repeat(gistage_numb) { 65 | gistage_surf[i] = surface_create(gistage_resw, gistage_resh); 66 | i++; 67 | } 68 | var i = 0; repeat(gistage_tmpk) { 69 | gistage_temp[i] = surface_create(gistage_resw, gistage_resh); 70 | i++; 71 | } -------------------------------------------------------------------------------- /Global_Illumination/objects/obj_gi/Draw_73.gml: -------------------------------------------------------------------------------- 1 | /* 2 | STAGE 1: [INITIAL] Render the scene that GI will be rendered from. 3 | */ 4 | // Enable GPU blending to create the initialization surface and blend that with the first GI pass. 5 | gpu_set_blendenable(true); 6 | 7 | surface_set_target(gistage_surf[GISTAGES.INITIAL]); 8 | draw_clear_alpha(c_black, 0); 9 | draw_sprite(Spr_SceneGI,0,0,0); 10 | draw_set_color($F0018C); 11 | draw_circle(mouse_x*(gistage_resw/gistage_rndw), mouse_y*(gistage_resh/gistage_rndh), 16, false); 12 | draw_set_color(c_white); 13 | surface_reset_target(); 14 | 15 | surface_set_target(gistage_temp[gistage_iter mod gistage_tmpk]); 16 | draw_surface(gistage_surf[GISTAGES.INITIAL],0,0); 17 | surface_reset_target(); 18 | 19 | // Disable GPU blending for future stages to eliminate alpha component artifacts. 20 | gpu_set_blendenable(false); 21 | 22 | /* 23 | STAGE 2: [PREJUMP] Setup for Jump Flooding 24 | */ 25 | surface_set_target(gistage_surf[GISTAGES.PREJUMP]); 26 | draw_clear_alpha(c_black, 0); 27 | shader_set(GISHADER.PREJUMP); 28 | draw_surface(gistage_surf[GISTAGES.INITIAL],0,0); 29 | shader_reset(); 30 | surface_reset_target(); 31 | 32 | surface_set_target(gistage_surf[GISTAGES.JMPFLDA]); 33 | draw_clear_alpha(c_black, 0); 34 | surface_reset_target(); 35 | 36 | surface_set_target(gistage_surf[GISTAGES.JMPFLDB]); 37 | draw_clear_alpha(c_black, 0); 38 | draw_surface(gistage_surf[GISTAGES.PREJUMP],0,0); 39 | surface_reset_target(); 40 | 41 | /* 42 | STAGE 3: [JUMPFLD] Jump Flooding 43 | */ 44 | var passes = ceil(log2(max(gistage_resw, gistage_resh)) / log2(2.0)); 45 | 46 | shader_set(GISHADER.JUMPFLD); 47 | shader_set_uniform_f(JUMPFLD_inResol, gistage_resw, gistage_resh); 48 | var i = 0; repeat(passes) { 49 | var offset = power(2, passes - i - 1); 50 | shader_set_uniform_f(JUMPFLD_inJdist, offset); 51 | 52 | surface_set_target(gistage_surf[GISTAGES.JMPFLDA]); 53 | draw_surface(gistage_surf[GISTAGES.JMPFLDB],0,0); 54 | surface_reset_target(); 55 | 56 | surface_set_target(gistage_surf[GISTAGES.JMPFLDB]); 57 | draw_surface(gistage_surf[GISTAGES.JMPFLDA],0,0); 58 | surface_reset_target(); 59 | i++; 60 | } 61 | shader_reset(); 62 | 63 | /* 64 | STAGE 4: [DISTFLD] Distance Field from Jump Flood 65 | */ 66 | surface_set_target(gistage_surf[GISTAGES.DISTFLD]); 67 | draw_clear_alpha(c_black, 0); 68 | shader_set(GISHADER.DISTFLD); 69 | draw_surface(gistage_surf[GISTAGES.JMPFLDB],0,0); 70 | shader_reset(); 71 | surface_reset_target(); 72 | 73 | /* 74 | STAGE 5: [FASTNSE] Tile bluenoise texture across surface. 75 | * this shouldn't be necessary, but sprite_get_texture() causes render issues. 76 | */ 77 | 78 | surface_set_target(gistage_surf[GISTAGES.FASTNSE]); 79 | draw_sprite_tiled(Spr_Bluenoise, 0, 0, 0); 80 | surface_reset_target(); 81 | 82 | /* 83 | STAGE 6: [GILIGHT] Ray March the light scene. 84 | */ 85 | 86 | surface_set_target(gistage_temp[(gistage_iter+1) mod gistage_tmpk]); 87 | shader_set(GISHADER.GILIGHT); 88 | shader_set_uniform_f(GILIGHT_inResol, gistage_resw, gistage_resh); 89 | texture_set_stage(GILIGHT_inDistfld, surface_get_texture(gistage_surf[GISTAGES.DISTFLD])); 90 | texture_set_stage(GILIGHT_inFastnse, surface_get_texture(gistage_surf[GISTAGES.FASTNSE])); 91 | draw_surface(gistage_temp[gistage_iter mod gistage_tmpk],0,0); 92 | shader_reset(); 93 | surface_reset_target(); 94 | gistage_iter++; 95 | 96 | /* 97 | STAGE 7: [DENOISE] Remove noise from final scene. 98 | */ 99 | // Re-Enable color blending for bloom. 100 | gpu_set_blendenable(true); 101 | surface_set_target(gistage_surf[GISTAGES.DENOISE]); 102 | shader_set(GISHADER.DENOISE); 103 | shader_set_uniform_f(DENOISE_inResol, gistage_resw, gistage_resh); 104 | draw_surface(gistage_temp[gistage_iter mod gistage_tmpk],0,0); 105 | shader_reset(); 106 | surface_reset_target(); 107 | 108 | /* 109 | STAGE 8: [POSTPRC] additive blending for bloom. 110 | */ 111 | surface_set_target(gistage_surf[GISTAGES.POSTPRC]); 112 | draw_clear(c_black); 113 | gpu_set_blendmode(bm_add); 114 | repeat(2) { draw_surface(gistage_surf[GISTAGES.DENOISE],0,0); } 115 | gpu_set_blendmode(bm_normal); 116 | surface_reset_target(); 117 | 118 | if (gistage_curr == 0) 119 | /*STAGE 1*/draw_surface_ext(gistage_surf[GISTAGES.INITIAL],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 120 | 121 | if (gistage_curr == 1) 122 | /*STAGE 2*/draw_surface_ext(gistage_surf[GISTAGES.PREJUMP],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 123 | 124 | if (gistage_curr == 2) 125 | /*STAGE 3*/draw_surface_ext(gistage_surf[GISTAGES.JMPFLDB],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 126 | 127 | if (gistage_curr == 3) 128 | /*STAGE 4*/draw_surface_ext(gistage_surf[GISTAGES.DISTFLD],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 129 | 130 | if (gistage_curr == 4) 131 | /*STAGE 5*/draw_surface_ext(gistage_surf[GISTAGES.FASTNSE],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 132 | 133 | if (gistage_curr == 5) 134 | /*STAGE 6*/draw_surface_ext(gistage_temp[gistage_iter mod gistage_tmpk],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 135 | 136 | if (gistage_curr == 6) 137 | /*STAGE 8*/draw_surface_ext(gistage_surf[GISTAGES.DENOISE],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 138 | 139 | if (gistage_curr == 7) 140 | /*STAGE 7*/draw_surface_ext(gistage_surf[GISTAGES.POSTPRC],0,0,gistage_rndw/gistage_resw,gistage_rndh/gistage_resh,0,c_white,1); 141 | 142 | draw_set_color(c_black); 143 | draw_rectangle(0,0,88,135,false); 144 | draw_set_color(c_yellow); 145 | draw_text(5, 5, "FPS: " + string(fps)); 146 | draw_text(5, 45, "RSW: " + string(gistage_resw)); 147 | draw_text(5, 65, "RSH: " + string(gistage_resh)); 148 | draw_text(5, 85, "STG: " + string(gistage_curr)); 149 | draw_set_color(c_white); -------------------------------------------------------------------------------- /Global_Illumination/objects/obj_gi/Draw_76.gml: -------------------------------------------------------------------------------- 1 | // Recreate any surfaces that were cleared from VRAM (for whatever reason). 2 | 3 | //for(var i = 0; i < gistage_numb; i++) 4 | var i = 0; repeat(gistage_numb) { 5 | if (!surface_exists(gistage_surf[i])) gistage_surf[i] = surface_create(gistage_resw, gistage_resh); 6 | i++; 7 | } 8 | 9 | //for(var i = 0; i < gistage_tmpk; i++) 10 | var i = 0; repeat(gistage_tmpk) { 11 | if (!surface_exists(gistage_temp[i])) gistage_temp[i] = surface_create(gistage_resw, gistage_resh); 12 | i++; 13 | } -------------------------------------------------------------------------------- /Global_Illumination/objects/obj_gi/Step_1.gml: -------------------------------------------------------------------------------- 1 | gistage_time += keyboard_check(vk_space); 2 | 3 | gistage_curr += keyboard_check_pressed(vk_right) - keyboard_check_pressed(vk_left); 4 | gistage_curr = clamp(gistage_curr, 0, 7); -------------------------------------------------------------------------------- /Global_Illumination/objects/obj_gi/obj_gi.yy: -------------------------------------------------------------------------------- 1 | { 2 | "spriteId": null, 3 | "solid": false, 4 | "visible": true, 5 | "managed": true, 6 | "spriteMaskId": null, 7 | "persistent": false, 8 | "parentObjectId": null, 9 | "physicsObject": false, 10 | "physicsSensor": false, 11 | "physicsShape": 1, 12 | "physicsGroup": 1, 13 | "physicsDensity": 0.5, 14 | "physicsRestitution": 0.1, 15 | "physicsLinearDamping": 0.1, 16 | "physicsAngularDamping": 0.1, 17 | "physicsFriction": 0.2, 18 | "physicsStartAwake": true, 19 | "physicsKinematic": false, 20 | "physicsShapePoints": [], 21 | "eventList": [ 22 | {"isDnD":false,"eventNum":0,"eventType":0,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 23 | {"isDnD":false,"eventNum":76,"eventType":8,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 24 | {"isDnD":false,"eventNum":0,"eventType":12,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 25 | {"isDnD":false,"eventNum":73,"eventType":8,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 26 | {"isDnD":false,"eventNum":1,"eventType":3,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 27 | ], 28 | "properties": [], 29 | "overriddenProperties": [], 30 | "parent": { 31 | "name": "Objects", 32 | "path": "folders/Objects.yy", 33 | }, 34 | "resourceVersion": "1.0", 35 | "name": "Obj_GI", 36 | "tags": [], 37 | "resourceType": "GMObject", 38 | } -------------------------------------------------------------------------------- /Global_Illumination/options/linux/options_linux.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_linux_display_name": "Created with GameMaker", 3 | "option_linux_version": "1.0.0.0", 4 | "option_linux_maintainer_email": "", 5 | "option_linux_homepage": "http://www.yoyogames.com", 6 | "option_linux_short_desc": "", 7 | "option_linux_long_desc": "", 8 | "option_linux_splash_screen": "${base_options_dir}/linux/splash/splash.png", 9 | "option_linux_display_splash": false, 10 | "option_linux_icon": "${base_options_dir}/linux/icons/64.png", 11 | "option_linux_start_fullscreen": false, 12 | "option_linux_allow_fullscreen": false, 13 | "option_linux_interpolate_pixels": true, 14 | "option_linux_display_cursor": true, 15 | "option_linux_sync": false, 16 | "option_linux_resize_window": false, 17 | "option_linux_scale": 0, 18 | "option_linux_texture_page": "2048x2048", 19 | "option_linux_enable_steam": false, 20 | "option_linux_disable_sandbox": false, 21 | "resourceVersion": "1.0", 22 | "name": "Linux", 23 | "tags": [], 24 | "resourceType": "GMLinuxOptions", 25 | } -------------------------------------------------------------------------------- /Global_Illumination/options/mac/options_mac.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_mac_display_name": "Created with GameMaker", 3 | "option_mac_app_id": "com.company.game", 4 | "option_mac_version": "1.0.0.0", 5 | "option_mac_output_dir": "~/gamemakerstudio2", 6 | "option_mac_team_id": "", 7 | "option_mac_signing_identity": "Developer ID Application:", 8 | "option_mac_copyright": "", 9 | "option_mac_splash_png": "${base_options_dir}/mac/splash/splash.png", 10 | "option_mac_icon_png": "${base_options_dir}/mac/icons/1024.png", 11 | "option_mac_installer_background_png": "${base_options_dir}/mac/splash/installer_background.png", 12 | "option_mac_menu_dock": false, 13 | "option_mac_display_cursor": true, 14 | "option_mac_start_fullscreen": false, 15 | "option_mac_allow_fullscreen": false, 16 | "option_mac_interpolate_pixels": true, 17 | "option_mac_vsync": false, 18 | "option_mac_resize_window": false, 19 | "option_mac_enable_retina": false, 20 | "option_mac_scale": 0, 21 | "option_mac_texture_page": "2048x2048", 22 | "option_mac_build_app_store": false, 23 | "option_mac_allow_incoming_network": false, 24 | "option_mac_allow_outgoing_network": false, 25 | "option_mac_app_category": "Games", 26 | "option_mac_enable_steam": false, 27 | "option_mac_disable_sandbox": false, 28 | "option_mac_x86_64": true, 29 | "option_mac_arm64": true, 30 | "option_mac_apple_sign_in": false, 31 | "resourceVersion": "1.0", 32 | "name": "macOS", 33 | "tags": [], 34 | "resourceType": "GMMacOptions", 35 | } -------------------------------------------------------------------------------- /Global_Illumination/options/main/options_main.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_gameguid": "a5e54390-f895-4abf-bb28-416cd71322a8", 3 | "option_gameid": "0", 4 | "option_game_speed": 60, 5 | "option_mips_for_3d_textures": false, 6 | "option_draw_colour": 4294967295, 7 | "option_window_colour": 255, 8 | "option_steam_app_id": "0", 9 | "option_sci_usesci": false, 10 | "option_author": "", 11 | "option_collision_compatibility": false, 12 | "option_copy_on_write_enabled": false, 13 | "option_spine_licence": false, 14 | "option_template_image": "${base_options_dir}/main/template_image.png", 15 | "option_template_icon": "${base_options_dir}/main/template_icon.png", 16 | "option_template_description": null, 17 | "resourceVersion": "1.4", 18 | "name": "Main", 19 | "tags": [], 20 | "resourceType": "GMMainOptions", 21 | } -------------------------------------------------------------------------------- /Global_Illumination/options/operagx/options_operagx.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_operagx_version": "1.0.0.0", 3 | "option_operagx_next_version": "1.0.0.0", 4 | "option_operagx_game_name": "${project_name}", 5 | "option_operagx_interpolate_pixels": true, 6 | "option_operagx_scale": 0, 7 | "option_operagx_texture_page": "2048x2048", 8 | "option_operagx_display_cursor": true, 9 | "option_operagx_guid": "", 10 | "option_operagx_team_name": "", 11 | "option_operagx_team_id": "", 12 | "option_operagx_editUrl": "", 13 | "option_operagx_internalShareUrl": "", 14 | "option_operagx_publicShareUrl": "", 15 | "resourceVersion": "1.0", 16 | "name": "operagx", 17 | "tags": [], 18 | "resourceType": "GMOperaGXOptions", 19 | } -------------------------------------------------------------------------------- /Global_Illumination/options/windows/options_windows.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_windows_display_name": "Created with GameMaker", 3 | "option_windows_executable_name": "${project_name}.exe", 4 | "option_windows_version": "1.0.0.0", 5 | "option_windows_company_info": "YoYo Games Ltd", 6 | "option_windows_product_info": "Created with GameMaker", 7 | "option_windows_copyright_info": "", 8 | "option_windows_description_info": "A GameMaker Game", 9 | "option_windows_display_cursor": true, 10 | "option_windows_icon": "${base_options_dir}/windows/icons/icon.ico", 11 | "option_windows_save_location": 0, 12 | "option_windows_splash_screen": "${base_options_dir}/windows/splash/splash.png", 13 | "option_windows_use_splash": false, 14 | "option_windows_start_fullscreen": false, 15 | "option_windows_allow_fullscreen_switching": false, 16 | "option_windows_interpolate_pixels": false, 17 | "option_windows_vsync": false, 18 | "option_windows_resize_window": false, 19 | "option_windows_borderless": false, 20 | "option_windows_scale": 0, 21 | "option_windows_copy_exe_to_dest": false, 22 | "option_windows_sleep_margin": 10, 23 | "option_windows_texture_page": "2048x2048", 24 | "option_windows_installer_finished": "${base_options_dir}/windows/installer/finished.bmp", 25 | "option_windows_installer_header": "${base_options_dir}/windows/installer/header.bmp", 26 | "option_windows_license": "${base_options_dir}/windows/installer/license.txt", 27 | "option_windows_nsis_file": "${base_options_dir}/windows/installer/nsis_script.nsi", 28 | "option_windows_enable_steam": false, 29 | "option_windows_disable_sandbox": false, 30 | "option_windows_steam_use_alternative_launcher": false, 31 | "option_windows_use_x64": true, 32 | "resourceVersion": "1.1", 33 | "name": "Windows", 34 | "tags": [], 35 | "resourceType": "GMWindowsOptions", 36 | } -------------------------------------------------------------------------------- /Global_Illumination/rooms/room1/room1.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnd": false, 3 | "volume": 1.0, 4 | "parentRoom": null, 5 | "views": [ 6 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 7 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 8 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 9 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 10 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 11 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 12 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 13 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 14 | ], 15 | "layers": [ 16 | {"instances":[ 17 | {"properties":[],"isDnd":false,"objectId":{"name":"Obj_GI","path":"objects/Obj_GI/Obj_GI.yy",},"inheritCode":false,"hasCreationCode":false,"colour":4294967295,"rotation":0.0,"scaleX":1.0,"scaleY":1.0,"imageIndex":0,"imageSpeed":1.0,"inheritedItemId":null,"frozen":false,"ignore":false,"inheritItemSettings":false,"x":24.0,"y":32.0,"resourceVersion":"1.0","name":"inst_2C550858","tags":[],"resourceType":"GMRInstance",}, 18 | ],"visible":true,"depth":0,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":8,"gridY":8,"layers":[],"hierarchyFrozen":false,"effectEnabled":true,"effectType":null,"properties":[],"resourceVersion":"1.0","name":"Instances","tags":[],"resourceType":"GMRInstanceLayer",}, 19 | {"spriteId":null,"colour":4278190080,"x":0,"y":0,"htiled":false,"vtiled":false,"hspeed":0.0,"vspeed":0.0,"stretch":false,"animationFPS":15.0,"animationSpeedType":0,"userdefinedAnimFPS":false,"visible":true,"depth":100,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":8,"gridY":8,"layers":[],"hierarchyFrozen":false,"effectEnabled":true,"effectType":null,"properties":[],"resourceVersion":"1.0","name":"Background","tags":[],"resourceType":"GMRBackgroundLayer",}, 20 | ], 21 | "inheritLayers": false, 22 | "creationCodeFile": "", 23 | "inheritCode": false, 24 | "instanceCreationOrder": [ 25 | {"name":"inst_2C550858","path":"rooms/Room1/Room1.yy",}, 26 | ], 27 | "inheritCreationOrder": false, 28 | "sequenceId": null, 29 | "roomSettings": { 30 | "inheritRoomSettings": false, 31 | "Width": 1920, 32 | "Height": 1080, 33 | "persistent": false, 34 | }, 35 | "viewSettings": { 36 | "inheritViewSettings": false, 37 | "enableViews": false, 38 | "clearViewBackground": false, 39 | "clearDisplayBuffer": true, 40 | }, 41 | "physicsSettings": { 42 | "inheritPhysicsSettings": false, 43 | "PhysicsWorld": false, 44 | "PhysicsWorldGravityX": 0.0, 45 | "PhysicsWorldGravityY": 10.0, 46 | "PhysicsWorldPixToMetres": 0.1, 47 | }, 48 | "parent": { 49 | "name": "Rooms", 50 | "path": "folders/Rooms.yy", 51 | }, 52 | "resourceVersion": "1.0", 53 | "name": "Room1", 54 | "tags": [], 55 | "resourceType": "GMRoom", 56 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_denoise/shd_denoise.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 in_Coord; 2 | uniform vec2 in_Resol; 3 | 4 | #define INV_SQRT_OF_2PI 0.39894228040143267793994605993439 // 1.0/SQRT_OF_2PI 5 | #define INV_PI 0.31830988618379067153776752674503 6 | 7 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 | // Copyright (c) 2018-2019 Michele Morrone 9 | // All rights reserved. 10 | // 11 | // https://michelemorrone.eu - https://BrutPitt.com 12 | // 13 | // me@michelemorrone.eu - brutpitt@gmail.com 14 | // twitter: @BrutPitt - github: BrutPitt 15 | // 16 | // https://github.com/BrutPitt/glslSmartDeNoise/ 17 | // 18 | // This software is distributed under the terms of the BSD 2-Clause license 19 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 | vec4 smartDeNoise(sampler2D tex, vec2 uv, float sigma, float kSigma, float threshold) { 21 | float radius = floor(kSigma*sigma + 0.5); 22 | float radQ = radius * radius; 23 | 24 | float invSigmaQx2 = .5 / (sigma * sigma); // 1.0 / (sigma^2 * 2.0) 25 | float invSigmaQx2PI = INV_PI * invSigmaQx2; // 1.0 / (sqrt(PI) * sigma) 26 | 27 | float invThresholdSqx2 = .5 / (threshold * threshold); // 1.0 / (sigma^2 * 2.0) 28 | float invThresholdSqrt2PI = INV_SQRT_OF_2PI / threshold; // 1.0 / (sqrt(2*PI) * sigma) 29 | 30 | vec4 centrPx = texture2D(tex,uv); 31 | 32 | float zBuff = 0.0; 33 | vec4 aBuff = vec4(0.0); 34 | vec2 size = in_Resol; 35 | 36 | for(float x=-radius; x <= radius; x++) { 37 | float pt = sqrt(radQ-x*x); // pt = yRadius: have circular trend 38 | for(float y=-pt; y <= pt; y++) { 39 | vec2 d = vec2(x,y); 40 | 41 | float blurFactor = exp( -dot(d , d) * invSigmaQx2 ) * invSigmaQx2PI; 42 | 43 | vec4 walkPx = texture2D(tex,uv+d/size); 44 | 45 | vec4 dC = walkPx-centrPx; 46 | float deltaFactor = exp( -dot(dC, dC) * invThresholdSqx2) * invThresholdSqrt2PI * blurFactor; 47 | 48 | zBuff += deltaFactor; 49 | aBuff += deltaFactor*walkPx; 50 | } 51 | } 52 | return aBuff/zBuff; 53 | } 54 | 55 | void main() { 56 | gl_FragColor = smartDeNoise(gm_BaseTexture, in_Coord, 5.0, 1.0, 0.100); 57 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_denoise/shd_denoise.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; 5 | attribute vec2 in_TextureCoord; 6 | varying vec2 in_Coord; 7 | 8 | void main() { 9 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position, 1.0); 10 | in_Coord = in_TextureCoord; 11 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_denoise/shd_denoise.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "Shd_DENOISE", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_distfld/shd_distfld.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 in_Coord; 2 | 3 | float V2_F16(vec2 v) { return v.x + (v.y / 255.0); } 4 | vec2 F16_V2(float f) { return vec2(floor(f * 255.0) / 255.0, fract(f * 255.0)); } 5 | 6 | void main() { 7 | vec4 jfuv = texture2D(gm_BaseTexture, in_Coord); 8 | vec2 jumpflood = vec2(V2_F16(jfuv.rg),V2_F16(jfuv.ba)); 9 | gl_FragColor = vec4(F16_V2(distance(in_Coord, jumpflood)), 0.0, 1.0); 10 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_distfld/shd_distfld.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; 5 | attribute vec2 in_TextureCoord; 6 | varying vec2 in_Coord; 7 | varying vec4 in_Color; 8 | 9 | void main() { 10 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position, 1.0); 11 | in_Coord = in_TextureCoord; 12 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_distfld/shd_distfld.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "Shd_DISTFLD", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_gilight/shd_gilight.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 in_Coord; 2 | varying vec4 in_Color; 3 | uniform vec2 in_Resol; 4 | uniform sampler2D in_Distfld; 5 | uniform sampler2D in_Fastnse; 6 | 7 | #define TAU 6.2831853071795864769252867665590 8 | #define MAX_STEPS 32.0 // higher = accuracy, lower = efficiency 9 | #define RAYS_PER_PIXEL 32.0 // higher = accuracy, lower = efficiency 10 | #define EPSILON 0.001 // floating point precision check 11 | #define dot(f) dot(f,f) // shorthand dot of a single float 12 | 13 | float V2_F16(vec2 v) { return v.x + (v.y / 255.0); } 14 | bool RANGE(float v, float lo, float hi) { return (v - hi) * (v - lo) > 0.0; } 15 | bool surfacemarch(vec2 pix, vec2 dir, float noise, out vec2 hitpos, out vec3 hitcol) { 16 | float aspect = in_Resol.x / in_Resol.y; 17 | vec2 pixel = vec2(pix.x * aspect, pix.y); 18 | 19 | for(float ray = 0.0, dst = 0.0, i = 0.0; i < MAX_STEPS; i += 1.0) { 20 | vec2 raypos = pixel + (dir * ray); 21 | raypos.x /= aspect; 22 | ray += (dst = V2_F16(texture2D(in_Distfld, raypos).rg)); 23 | 24 | if (RANGE(raypos.x, 0.0, 1.0) || RANGE(raypos.y, 0.0, 1.0)) return false; 25 | if (dst <= EPSILON) { 26 | // Random sample either surface emitters or previous frame emission pixel. 27 | vec3 srceCol = texture2D(gm_BaseTexture, raypos).rgb; 28 | float srceValue = max(srceCol.r, max(srceCol.g, srceCol.b)); 29 | vec2 srcePos = raypos; 30 | 31 | raypos *= aspect; 32 | raypos -= (dir * ray * noise); 33 | raypos /= aspect; 34 | 35 | vec3 destCol = texture2D(gm_BaseTexture, raypos).rgb; 36 | float destValue = max(destCol.r, max(destCol.g, destCol.b)); 37 | vec2 destPos = raypos; 38 | 39 | float check = step(destValue, srceValue); 40 | hitcol = (check > 0.0)? srceCol : mix(destCol, srceCol, 0.5); 41 | hitpos = (check > 0.0)? srcePos : destPos; 42 | return true; 43 | } 44 | } 45 | return false; 46 | } 47 | 48 | vec3 tonemap(vec3 color, float dist) { 49 | // INVERSE SQR LAW FOR LIGHT: (not my preferred, visually) 50 | //return color * (1.0 / (1.0 + dot(dist / min(in_Resol.x, in_Resol.y)))); 51 | 52 | // LINEAR DROP OFF: 53 | return color * (1.0 - (dist / min(in_Resol.x, in_Resol.y))); 54 | } 55 | 56 | void main() { 57 | vec3 colors = vec3(0.0); 58 | float emissv = 0.0, 59 | gnoise = texture2D(in_Fastnse, in_Coord).r, 60 | gangle = gnoise * TAU; 61 | 62 | const float RAY_DELTA = TAU * (1.0/RAYS_PER_PIXEL); 63 | for(float i = 0.0; i < TAU; i += RAY_DELTA) { 64 | vec2 hitpos = in_Coord; vec3 hitcol = vec3(0.0); 65 | surfacemarch(in_Coord, vec2(cos(gangle + i), -sin(gangle + i)), gnoise, hitpos, hitcol); 66 | hitcol = tonemap(hitcol, distance(in_Coord * in_Resol, hitpos * in_Resol)); 67 | emissv += max(hitcol.r, max(hitcol.g, hitcol.b)); 68 | colors += hitcol; 69 | } 70 | 71 | vec3 color = (colors / emissv) * (emissv / RAYS_PER_PIXEL); 72 | gl_FragColor = vec4(color, 1.0); 73 | } 74 | -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_gilight/shd_gilight.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; 5 | attribute vec4 in_Colour; 6 | attribute vec2 in_TextureCoord; 7 | varying vec2 in_Coord; 8 | varying vec4 in_Color; 9 | 10 | void main() { 11 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position, 1.0); 12 | in_Color = in_Colour; 13 | in_Coord = in_TextureCoord; 14 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_gilight/shd_gilight.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "Shd_GILIGHT", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_jumpfld/shd_jumpfld.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 in_Coord; 2 | uniform float in_Jdist; 3 | uniform vec2 in_Resol; 4 | 5 | float V2_F16(vec2 v) { return v.x + (v.y / 255.0); } 6 | 7 | void main() { 8 | vec2 offsets[9]; 9 | offsets[0] = vec2(-1.0, -1.0); 10 | offsets[1] = vec2(-1.0, 0.0); 11 | offsets[2] = vec2(-1.0, 1.0); 12 | offsets[3] = vec2(0.0, -1.0); 13 | offsets[4] = vec2(0.0, 0.0); 14 | offsets[5] = vec2(0.0, 1.0); 15 | offsets[6] = vec2(1.0, -1.0); 16 | offsets[7] = vec2(1.0, 0.0); 17 | offsets[8] = vec2(1.0, 1.0); 18 | 19 | float closest_dist = 9999999.9; 20 | vec2 closest_pos = vec2(0.0); 21 | vec4 closest_data = vec4(0.0); 22 | 23 | for(int i = 0; i < 9; i++) { 24 | vec2 jump = in_Coord + (offsets[i] * (in_Jdist / in_Resol)); 25 | vec4 seed = texture2D(gm_BaseTexture, jump); 26 | vec2 seedpos = vec2(V2_F16(seed.xy), V2_F16(seed.zw)); 27 | float dist = distance(seedpos, in_Coord); 28 | 29 | if (seedpos != vec2(0.0) && dist <= closest_dist) { 30 | closest_dist = dist; 31 | closest_data = seed; 32 | } 33 | } 34 | 35 | gl_FragColor = closest_data; 36 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_jumpfld/shd_jumpfld.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; 5 | attribute vec2 in_TextureCoord; 6 | varying vec2 in_Coord; 7 | varying vec4 in_Color; 8 | 9 | void main() { 10 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position, 1.0); 11 | in_Coord = in_TextureCoord; 12 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_jumpfld/shd_jumpfld.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "Shd_JUMPFLD", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_prejump/shd_prejump.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 in_Coord; 2 | 3 | vec2 F16_V2(float f) { return vec2(floor(f * 255.0) / 255.0, fract(f * 255.0)); } 4 | 5 | void main() { 6 | vec4 scene = texture2D(gm_BaseTexture, in_Coord); 7 | gl_FragColor = vec4(F16_V2(in_Coord.x * scene.a), F16_V2(in_Coord.y * scene.a)); 8 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_prejump/shd_prejump.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; 5 | attribute vec4 in_Colour; 6 | attribute vec2 in_TextureCoord; 7 | varying vec2 in_Coord; 8 | varying vec4 in_Color; 9 | 10 | void main() { 11 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position, 1.0); 12 | in_Color = in_Colour; 13 | in_Coord = in_TextureCoord; 14 | } -------------------------------------------------------------------------------- /Global_Illumination/shaders/shd_prejump/shd_prejump.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "Shd_PREJUMP", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Global_Illumination/sprites/spr_bluenoise/e6b68fc2-ba7d-42b1-9485-01bd0548adda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yaazarai/2DGI/06660fb368133c026f05bf16d5f09e86e70f6975/Global_Illumination/sprites/spr_bluenoise/e6b68fc2-ba7d-42b1-9485-01bd0548adda.png -------------------------------------------------------------------------------- /Global_Illumination/sprites/spr_bluenoise/layers/e6b68fc2-ba7d-42b1-9485-01bd0548adda/4a0088c3-adb2-46d7-85a2-8a2b5bfcdc4d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yaazarai/2DGI/06660fb368133c026f05bf16d5f09e86e70f6975/Global_Illumination/sprites/spr_bluenoise/layers/e6b68fc2-ba7d-42b1-9485-01bd0548adda/4a0088c3-adb2-46d7-85a2-8a2b5bfcdc4d.png -------------------------------------------------------------------------------- /Global_Illumination/sprites/spr_bluenoise/spr_bluenoise.yy: -------------------------------------------------------------------------------- 1 | { 2 | "bboxMode": 0, 3 | "collisionKind": 1, 4 | "type": 0, 5 | "origin": 0, 6 | "preMultiplyAlpha": false, 7 | "edgeFiltering": false, 8 | "collisionTolerance": 0, 9 | "swfPrecision": 2.525, 10 | "bbox_left": 0, 11 | "bbox_right": 511, 12 | "bbox_top": 0, 13 | "bbox_bottom": 511, 14 | "HTile": false, 15 | "VTile": false, 16 | "For3D": false, 17 | "width": 512, 18 | "height": 512, 19 | "textureGroupId": { 20 | "name": "Default", 21 | "path": "texturegroups/Default", 22 | }, 23 | "swatchColours": null, 24 | "gridX": 0, 25 | "gridY": 0, 26 | "frames": [ 27 | {"compositeImage":{"FrameId":{"name":"e6b68fc2-ba7d-42b1-9485-01bd0548adda","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",},"LayerId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",},"images":[ 28 | {"FrameId":{"name":"e6b68fc2-ba7d-42b1-9485-01bd0548adda","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",},"LayerId":{"name":"4a0088c3-adb2-46d7-85a2-8a2b5bfcdc4d","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",}, 29 | ],"parent":{"name":"Spr_Bluenoise","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",},"resourceVersion":"1.0","name":"e6b68fc2-ba7d-42b1-9485-01bd0548adda","tags":[],"resourceType":"GMSpriteFrame",}, 30 | ], 31 | "sequence": { 32 | "spriteId": {"name":"Spr_Bluenoise","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",}, 33 | "timeUnits": 1, 34 | "playback": 1, 35 | "playbackSpeed": 30.0, 36 | "playbackSpeedType": 0, 37 | "autoRecord": true, 38 | "volume": 1.0, 39 | "length": 1.0, 40 | "events": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore`1","elementType":"MessageEventKeyframe",}, 41 | "moments": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore`1","elementType":"MomentsEventKeyframe",}, 42 | "tracks": [ 43 | {"name":"frames","spriteId":null,"keyframes":{"Keyframes":[ 44 | {"id":"d60d0b37-ee9a-41b6-8150-3cd0fac26098","Key":0.0,"Length":1.0,"Stretch":false,"Disabled":false,"IsCreationKey":false,"Channels":{"0":{"Id":{"name":"e6b68fc2-ba7d-42b1-9485-01bd0548adda","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",},"resourceVersion":"1.0","resourceType":"SpriteFrameKeyframe",},},"resourceVersion":"1.0","resourceType":"Keyframe`1","elementType":"SpriteFrameKeyframe",}, 45 | ],"resourceVersion":"1.0","resourceType":"KeyframeStore`1","elementType":"SpriteFrameKeyframe",},"trackColour":0,"inheritsTrackColour":true,"builtinName":0,"traits":0,"interpolation":1,"tracks":[],"events":[],"isCreationTrack":false,"resourceVersion":"1.0","tags":[],"resourceType":"GMSpriteFramesTrack","modifiers":[],}, 46 | ], 47 | "visibleRange": null, 48 | "lockOrigin": false, 49 | "showBackdrop": true, 50 | "showBackdropImage": false, 51 | "backdropImagePath": "", 52 | "backdropImageOpacity": 0.5, 53 | "backdropWidth": 1366, 54 | "backdropHeight": 768, 55 | "backdropXOffset": 0.0, 56 | "backdropYOffset": 0.0, 57 | "xorigin": 0, 58 | "yorigin": 0, 59 | "eventToFunction": {}, 60 | "eventStubScript": null, 61 | "parent": {"name":"Spr_Bluenoise","path":"sprites/Spr_Bluenoise/Spr_Bluenoise.yy",}, 62 | "resourceVersion": "1.4", 63 | "name": "Spr_Bluenoise", 64 | "tags": [], 65 | "resourceType": "GMSequence", 66 | }, 67 | "layers": [ 68 | {"visible":true,"isLocked":false,"blendMode":0,"opacity":100.0,"displayName":"default","resourceVersion":"1.0","name":"4a0088c3-adb2-46d7-85a2-8a2b5bfcdc4d","tags":[],"resourceType":"GMImageLayer",}, 69 | ], 70 | "nineSlice": null, 71 | "parent": { 72 | "name": "Sprites", 73 | "path": "folders/Sprites.yy", 74 | }, 75 | "resourceVersion": "1.0", 76 | "name": "Spr_Bluenoise", 77 | "tags": [], 78 | "resourceType": "GMSprite", 79 | } -------------------------------------------------------------------------------- /Global_Illumination/sprites/spr_scenegi/51e15803-6dc2-4d7e-a198-0d6a76c66511.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yaazarai/2DGI/06660fb368133c026f05bf16d5f09e86e70f6975/Global_Illumination/sprites/spr_scenegi/51e15803-6dc2-4d7e-a198-0d6a76c66511.png -------------------------------------------------------------------------------- /Global_Illumination/sprites/spr_scenegi/layers/51e15803-6dc2-4d7e-a198-0d6a76c66511/33e9aa65-0e7a-4e69-9a0f-25e73072f14a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yaazarai/2DGI/06660fb368133c026f05bf16d5f09e86e70f6975/Global_Illumination/sprites/spr_scenegi/layers/51e15803-6dc2-4d7e-a198-0d6a76c66511/33e9aa65-0e7a-4e69-9a0f-25e73072f14a.png -------------------------------------------------------------------------------- /Global_Illumination/sprites/spr_scenegi/spr_scenegi.yy: -------------------------------------------------------------------------------- 1 | { 2 | "bboxMode": 0, 3 | "collisionKind": 1, 4 | "type": 0, 5 | "origin": 0, 6 | "preMultiplyAlpha": false, 7 | "edgeFiltering": false, 8 | "collisionTolerance": 0, 9 | "swfPrecision": 2.525, 10 | "bbox_left": 190, 11 | "bbox_right": 345, 12 | "bbox_top": 57, 13 | "bbox_bottom": 126, 14 | "HTile": false, 15 | "VTile": false, 16 | "For3D": false, 17 | "width": 480, 18 | "height": 270, 19 | "textureGroupId": { 20 | "name": "Default", 21 | "path": "texturegroups/Default", 22 | }, 23 | "swatchColours": [ 24 | 4282384639, 25 | 4279440147, 26 | 4279966491, 27 | 4280756007, 28 | 4282203453, 29 | 4284308829, 30 | 4286940549, 31 | 4290032820, 32 | 4294967295, 33 | 4292726727, 34 | 4290355602, 35 | 4287787877, 36 | 4285418562, 37 | 4283313962, 38 | 4281473306, 39 | 4279961358, 40 | 4280029724, 41 | 4280360761, 42 | 4280822877, 43 | 4281747594, 44 | 4283068351, 45 | 4285111526, 46 | 4288662262, 47 | 4291815161, 48 | 4283476973, 49 | 4281890016, 50 | 4280567238, 51 | 4280100238, 52 | 4278210815, 53 | 4279531245, 54 | 4279542527, 55 | 4280666367, 56 | 4283952127, 57 | 4286512339, 58 | 4284475033, 59 | 4283417946, 60 | 4283144243, 61 | 4283461406, 62 | 4283190291, 63 | 4282658316, 64 | 4285348096, 65 | 4289358080, 66 | 4292646912, 67 | 4294561024, 68 | 4294963468, 69 | 4294966676, 70 | 4293776125, 71 | 4294281715, 72 | 4294787035, 73 | 4294576506, 74 | 4292412208, 75 | 4287824396, 76 | 4282325251, 77 | 4282586171, 78 | 4284556386, 79 | 4287576211, 80 | 4291384010, 81 | 4286992584, 82 | 4287070710, 83 | 4284306933, 84 | 4282135274, 85 | 4281345220, 86 | 4281015945, 87 | 4280753239, 88 | 4282384639, 89 | ], 90 | "gridX": 0, 91 | "gridY": 0, 92 | "frames": [ 93 | {"compositeImage":{"FrameId":{"name":"51e15803-6dc2-4d7e-a198-0d6a76c66511","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",},"LayerId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",},"images":[ 94 | {"FrameId":{"name":"51e15803-6dc2-4d7e-a198-0d6a76c66511","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",},"LayerId":{"name":"33e9aa65-0e7a-4e69-9a0f-25e73072f14a","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",}, 95 | ],"parent":{"name":"Spr_SceneGI","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",},"resourceVersion":"1.0","name":"51e15803-6dc2-4d7e-a198-0d6a76c66511","tags":[],"resourceType":"GMSpriteFrame",}, 96 | ], 97 | "sequence": { 98 | "spriteId": {"name":"Spr_SceneGI","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",}, 99 | "timeUnits": 1, 100 | "playback": 1, 101 | "playbackSpeed": 30.0, 102 | "playbackSpeedType": 0, 103 | "autoRecord": true, 104 | "volume": 1.0, 105 | "length": 1.0, 106 | "events": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore`1","elementType":"MessageEventKeyframe",}, 107 | "moments": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore`1","elementType":"MomentsEventKeyframe",}, 108 | "tracks": [ 109 | {"name":"frames","spriteId":null,"keyframes":{"Keyframes":[ 110 | {"id":"16db781c-8437-4f84-9c15-899a60c42ec2","Key":0.0,"Length":1.0,"Stretch":false,"Disabled":false,"IsCreationKey":false,"Channels":{"0":{"Id":{"name":"51e15803-6dc2-4d7e-a198-0d6a76c66511","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",},"resourceVersion":"1.0","resourceType":"SpriteFrameKeyframe",},},"resourceVersion":"1.0","resourceType":"Keyframe`1","elementType":"SpriteFrameKeyframe",}, 111 | ],"resourceVersion":"1.0","resourceType":"KeyframeStore`1","elementType":"SpriteFrameKeyframe",},"trackColour":0,"inheritsTrackColour":true,"builtinName":0,"traits":0,"interpolation":1,"tracks":[],"events":[],"isCreationTrack":false,"resourceVersion":"1.0","tags":[],"resourceType":"GMSpriteFramesTrack","modifiers":[],}, 112 | ], 113 | "visibleRange": null, 114 | "lockOrigin": false, 115 | "showBackdrop": true, 116 | "showBackdropImage": false, 117 | "backdropImagePath": "", 118 | "backdropImageOpacity": 0.5, 119 | "backdropWidth": 1366, 120 | "backdropHeight": 768, 121 | "backdropXOffset": 0.0, 122 | "backdropYOffset": 0.0, 123 | "xorigin": 0, 124 | "yorigin": 0, 125 | "eventToFunction": {}, 126 | "eventStubScript": null, 127 | "parent": {"name":"Spr_SceneGI","path":"sprites/Spr_SceneGI/Spr_SceneGI.yy",}, 128 | "resourceVersion": "1.4", 129 | "name": "Spr_SceneGI", 130 | "tags": [], 131 | "resourceType": "GMSequence", 132 | }, 133 | "layers": [ 134 | {"visible":true,"isLocked":false,"blendMode":0,"opacity":100.0,"displayName":"default","resourceVersion":"1.0","name":"33e9aa65-0e7a-4e69-9a0f-25e73072f14a","tags":[],"resourceType":"GMImageLayer",}, 135 | ], 136 | "nineSlice": null, 137 | "parent": { 138 | "name": "Sprites", 139 | "path": "folders/Sprites.yy", 140 | }, 141 | "resourceVersion": "1.0", 142 | "name": "Spr_SceneGI", 143 | "tags": [], 144 | "resourceType": "GMSprite", 145 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2DGI 2 | 2D Global Illumination GLSL ES 3 | 4 | Source Tutorial by Samuel Bigos: https://samuelbigos.github.io/posts/2dgi1-2d-global-illumination-in-godot.html 5 | 6 | GameMaker Tutorial by Me: https://forum.yoyogames.com/index.php?threads/all-about-2d-global-illumination.97941/ 7 | 8 |

9 | GI 10 |

11 | --------------------------------------------------------------------------------