├── shaders ├── entity.properties ├── world-1 │ ├── final.fsh │ ├── final.vsh │ ├── composite6.fsh │ ├── composite10.vsh │ ├── composite11.vsh │ ├── composite12.vsh │ ├── composite13.vsh │ ├── composite3.vsh │ ├── composite4.vsh │ ├── composite5.vsh │ ├── composite6.vsh │ ├── composite7.vsh │ ├── composite8.vsh │ ├── composite9.vsh │ ├── deferred3.vsh │ ├── deferred5.vsh │ ├── deferred6.vsh │ ├── composite10.fsh │ ├── composite11.fsh │ ├── composite12.fsh │ ├── composite4.fsh │ ├── gbuffers_armor_glint.fsh │ ├── gbuffers_armor_glint.vsh │ ├── composite13.fsh │ ├── gbuffers_basic.vsh │ ├── gbuffers_textured.vsh │ ├── composite8.fsh │ ├── composite9.fsh │ ├── deferred6.fsh │ ├── gbuffers_block.vsh │ ├── gbuffers_terrain.vsh │ ├── gbuffers_water.vsh │ ├── gbuffers_basic.fsh │ ├── gbuffers_textured.fsh │ ├── deferred5.fsh │ ├── gbuffers_block.fsh │ ├── deferred3.fsh │ ├── gbuffers_terrain.fsh │ ├── composite7.fsh │ ├── composite5.fsh │ └── composite3.fsh ├── world1 │ ├── final.fsh │ ├── final.vsh │ ├── composite6.fsh │ ├── composite10.vsh │ ├── composite11.vsh │ ├── composite12.vsh │ ├── composite13.vsh │ ├── composite3.vsh │ ├── composite4.vsh │ ├── composite5.vsh │ ├── composite6.vsh │ ├── composite7.vsh │ ├── composite8.vsh │ ├── composite9.vsh │ ├── deferred3.vsh │ ├── deferred5.vsh │ ├── deferred6.vsh │ ├── composite10.fsh │ ├── composite11.fsh │ ├── composite12.fsh │ ├── composite4.fsh │ ├── gbuffers_armor_glint.fsh │ ├── gbuffers_armor_glint.vsh │ ├── composite13.fsh │ ├── gbuffers_basic.vsh │ ├── gbuffers_textured.vsh │ ├── composite8.fsh │ ├── composite9.fsh │ ├── deferred6.fsh │ ├── gbuffers_block.vsh │ ├── gbuffers_terrain.vsh │ ├── gbuffers_water.vsh │ ├── gbuffers_basic.fsh │ ├── gbuffers_textured.fsh │ ├── deferred5.fsh │ ├── gbuffers_block.fsh │ ├── deferred3.fsh │ ├── gbuffers_terrain.fsh │ ├── composite7.fsh │ ├── composite5.fsh │ └── composite3.fsh ├── img │ └── Luts.png ├── lib │ ├── lmcol.glsl │ ├── ambcol.glsl │ ├── thunder.glsl │ ├── colorspace.glsl │ ├── lightcol.glsl │ ├── normals.glsl │ ├── wind.glsl │ ├── clouds.set │ ├── shadowtransform.glsl │ ├── shadow_lite.glsl │ ├── bloom.glsl │ ├── essentials.glsl │ ├── clouds.glsl │ ├── temp.glsl │ ├── shadow.glsl │ ├── sky.glsl │ └── trans.glsl ├── composite.vsh ├── deferred.vsh ├── deferred1.vsh ├── deferred2.vsh ├── deferred4.vsh ├── deferred5.vsh ├── deferred6.vsh ├── composite1.vsh ├── composite10.vsh ├── composite11.vsh ├── composite12.vsh ├── composite13.vsh ├── composite2.vsh ├── composite3.vsh ├── composite4.vsh ├── composite5.vsh ├── composite6.vsh ├── composite7.vsh ├── composite8.vsh ├── composite9.vsh ├── deferred3.vsh ├── common │ └── pbrformats ├── final.vsh ├── composite10.fsh ├── composite11.fsh ├── composite12.fsh ├── composite4.fsh ├── gbuffers_armor_glint.fsh ├── deferred1.fsh ├── deferred2.fsh ├── gbuffers_armor_glint.vsh ├── composite13.fsh ├── composite2.fsh ├── shadow.fsh ├── block.properties ├── gbuffers_basic.vsh ├── gbuffers_textured.vsh ├── deferred4.fsh ├── composite8.fsh ├── composite9.fsh ├── gbuffers_block.vsh ├── gbuffers_water.vsh ├── gbuffers_basic.fsh ├── gbuffers_textured.fsh ├── shadow.vsh ├── deferred.fsh ├── gbuffers_terrain.vsh ├── deferred6.fsh ├── composite6.fsh ├── composite1.fsh ├── shaders.properties ├── composite7.fsh ├── deferred5.fsh ├── final.fsh ├── deferred3.fsh ├── composite.fsh └── composite5.fsh ├── README.md └── LICENCE /shaders/entity.properties: -------------------------------------------------------------------------------- 1 | entity.1 = 2 | -------------------------------------------------------------------------------- /shaders/world-1/final.fsh: -------------------------------------------------------------------------------- 1 | #include "/final.fsh" 2 | -------------------------------------------------------------------------------- /shaders/world-1/final.vsh: -------------------------------------------------------------------------------- 1 | #include "/final.vsh" 2 | -------------------------------------------------------------------------------- /shaders/world1/final.fsh: -------------------------------------------------------------------------------- 1 | #include "/final.fsh" 2 | -------------------------------------------------------------------------------- /shaders/world1/final.vsh: -------------------------------------------------------------------------------- 1 | #include "/final.vsh" 2 | -------------------------------------------------------------------------------- /shaders/world-1/composite6.fsh: -------------------------------------------------------------------------------- 1 | #include "/composite6.fsh" 2 | -------------------------------------------------------------------------------- /shaders/world1/composite6.fsh: -------------------------------------------------------------------------------- 1 | #include "/composite6.fsh" 2 | -------------------------------------------------------------------------------- /shaders/img/Luts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stduhpf/universalis/HEAD/shaders/img/Luts.png -------------------------------------------------------------------------------- /shaders/lib/lmcol.glsl: -------------------------------------------------------------------------------- 1 | #define TorchColor vec3(1.,.67,.4) 2 | #define ambientCol vec3(.2,.2,.35) 3 | -------------------------------------------------------------------------------- /shaders/lib/ambcol.glsl: -------------------------------------------------------------------------------- 1 | float wta = (abs(float(worldTime)-17990)-5220); 2 | float ambi = .5*(.9*(smoothstep(0.,1000.,wta))+.1); 3 | -------------------------------------------------------------------------------- /shaders/composite.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred1.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred2.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred4.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred5.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred6.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite1.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite10.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite11.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite12.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite13.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite2.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite3.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite4.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite5.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite6.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite7.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite8.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/composite9.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/deferred3.vsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position = ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/lib/thunder.glsl: -------------------------------------------------------------------------------- 1 | float isday = sin(TAU*float(worldTime)/24000.); 2 | float bolt = step((1.-rainStrength)*2.+.51+.15*sign(isday),dot(skyColor,skyColor)); 3 | -------------------------------------------------------------------------------- /shaders/world-1/composite10.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite11.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite12.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite13.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite3.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite4.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite5.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite6.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite7.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite8.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/composite9.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/deferred3.vsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position = ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/deferred5.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world-1/deferred6.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite10.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite11.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite12.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite13.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite3.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite4.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite5.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite6.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite7.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite8.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/composite9.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/deferred3.vsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position = ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/deferred5.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/world1/deferred6.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec2 tc; 4 | 5 | void main(){ 6 | gl_Position =ftransform(); 7 | tc = gl_MultiTexCoord0.xy; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/common/pbrformats: -------------------------------------------------------------------------------- 1 | #define OFF 0 2 | #define labPBRv1_1 1 3 | #define labPBRv1_2 2 4 | #define labPBRv1_3 3 5 | #define PBR_FORMAT OFF //[OFF labPBRv1_1 labPBRv1_2 labPBRv1_3] 6 | -------------------------------------------------------------------------------- /shaders/final.vsh: -------------------------------------------------------------------------------- 1 | #version 400 compatibility 2 | 3 | varying vec2 tc; 4 | 5 | 6 | void main(){ 7 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 8 | tc = gl_MultiTexCoord0.xy; 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /shaders/composite10.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,3.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/composite11.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,4.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/composite12.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,5.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world-1/composite10.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,3.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world-1/composite11.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,4.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world-1/composite12.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,5.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world1/composite10.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,3.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world1/composite11.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,4.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world1/composite12.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | 8 | 9 | /*DRAWBUFFERS:1*/ 10 | void main(){ 11 | 12 | gl_FragData[0]=vec4(kawazePass(colortex1,tc,5.,resolution),1.); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /shaders/world-1/composite4.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | varying vec2 tc; 5 | uniform sampler2D colortex4; 6 | uniform sampler2D colortex0; 7 | 8 | 9 | /*DRAWBUFFERS:0*/ 10 | void main(){ 11 | vec3 c = texture2D(colortex0,tc).rgb; 12 | vec3 refc = texture2D(colortex4,tc).rgb; 13 | 14 | gl_FragData[0] = vec4(c+refc,1.); 15 | } 16 | -------------------------------------------------------------------------------- /shaders/world1/composite4.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | varying vec2 tc; 5 | uniform sampler2D colortex4; 6 | uniform sampler2D colortex0; 7 | 8 | 9 | /*DRAWBUFFERS:0*/ 10 | void main(){ 11 | vec3 c = texture2D(colortex0,tc).rgb; 12 | vec3 refc = texture2D(colortex4,tc).rgb; 13 | 14 | gl_FragData[0] = vec4(c+refc,1.); 15 | } 16 | -------------------------------------------------------------------------------- /shaders/composite4.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #include "lib/essentials.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex4; 7 | uniform sampler2D colortex0; 8 | 9 | 10 | /*DRAWBUFFERS:0*/ 11 | void main(){ 12 | vec3 c = texture2D(colortex0,tc).rgb; 13 | vec3 refc = texture2D(colortex4,tc).rgb; 14 | 15 | gl_FragData[0] = vec4(c+refc,1.); 16 | } 17 | -------------------------------------------------------------------------------- /shaders/gbuffers_armor_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D texture; 4 | 5 | #include "/lib/colorspace.glsl" 6 | 7 | varying vec4 texcoord; 8 | varying vec4 tintColor; 9 | 10 | 11 | /*DRAWBUFFERS:0*/ 12 | 13 | void main() 14 | { 15 | 16 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor; 17 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 18 | } 19 | -------------------------------------------------------------------------------- /shaders/deferred1.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex4; 7 | 8 | 9 | /*DRAWBUFFERS:4*/ 10 | void main(){ 11 | if(floor(2.*tc)==vec2(0)){ 12 | gl_FragData[0]=vec4(kawazePass(colortex4,tc,1.,resolution),1.); 13 | } 14 | else{ 15 | gl_FragData[0]=texture2D(colortex4,tc); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shaders/deferred2.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex4; 7 | 8 | 9 | /*DRAWBUFFERS:4*/ 10 | void main(){ 11 | if(floor(2.*tc)==vec2(0)){ 12 | gl_FragData[0]=vec4(kawazePass(colortex4,tc,2.,resolution),1.); 13 | } 14 | else{ 15 | gl_FragData[0]=texture2D(colortex4,tc); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_armor_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D texture; 4 | 5 | #include "/lib/colorspace.glsl" 6 | 7 | varying vec4 texcoord; 8 | varying vec4 tintColor; 9 | 10 | 11 | /*DRAWBUFFERS:0*/ 12 | 13 | void main() 14 | { 15 | 16 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor; 17 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 18 | } 19 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_armor_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D texture; 4 | 5 | #include "/lib/colorspace.glsl" 6 | 7 | varying vec4 texcoord; 8 | varying vec4 tintColor; 9 | 10 | 11 | /*DRAWBUFFERS:0*/ 12 | 13 | void main() 14 | { 15 | 16 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor; 17 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 18 | } 19 | -------------------------------------------------------------------------------- /shaders/lib/colorspace.glsl: -------------------------------------------------------------------------------- 1 | vec3 srgbToLinear(vec3 srgb){ 2 | return mix( 3 | srgb / 12.92, 4 | pow(.947867 * srgb + .0521327, vec3(2.4) ), 5 | step( .04045, srgb ) 6 | ); 7 | } 8 | 9 | vec3 linearToSRGB(vec3 linear){ 10 | return mix( 11 | linear * 12.92, 12 | pow(linear, vec3(1./2.4) ) * 1.055 - .055, 13 | step( .0031308, linear ) 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /shaders/lib/lightcol.glsl: -------------------------------------------------------------------------------- 1 | vec3 lightdir = camdir(normalize(shadowLightPosition)); 2 | vec3 lightCol=vec3(0); 3 | if(worldTime<=12770 || worldTime>=23210){ 4 | lightCol=mix(vec3(.4,.1,0.05),vec3(1.,1.,.85),max(0.,sqrt(lightdir.y))); 5 | } 6 | else{ 7 | lightCol=mix(vec3(.08,.08,.08),.5*vec3(.078,.08,.1),max(0.,sqrt(lightdir.y))); 8 | } 9 | float wt = abs(abs(float(worldTime)-17990)-5220); 10 | lightCol*=smoothstep(50,820,wt); 11 | -------------------------------------------------------------------------------- /shaders/lib/normals.glsl: -------------------------------------------------------------------------------- 1 | vec4 nmp = gettex(normals,uv); 2 | vec3 nm = nmp.rgb*2.-1.; 3 | #if PBR_FORMAT ==labPBRv1_2 4 | vec2 tb = nm.xy; 5 | ao = nm.z*.5.5; 6 | n = vec3(tb,sqrt(1.-dot(tb,tb))); //test for 2 channels normals (is working fine) 7 | #else 8 | ao = length(nm); 9 | n = (nm/ao); 10 | #ifndef AO_FIX 11 | ao*=ao; 12 | #else 13 | ao=sqrt(ao); 14 | ao = saturate(ao); 15 | #endif 16 | #endif 17 | n=tbn*n; 18 | -------------------------------------------------------------------------------- /shaders/gbuffers_armor_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec4 texcoord; 4 | varying vec4 tintColor; 5 | 6 | uniform int frameCounter; 7 | 8 | #include "/lib/essentials.glsl" 9 | 10 | 11 | 12 | void main() 13 | { 14 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 15 | gl_Position = ftransform(); 16 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 17 | texcoord = gl_MultiTexCoord0; 18 | tintColor = gl_Color; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_armor_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec4 texcoord; 4 | varying vec4 tintColor; 5 | 6 | uniform int frameCounter; 7 | 8 | #include "/lib/essentials.glsl" 9 | 10 | 11 | 12 | void main() 13 | { 14 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 15 | gl_Position = ftransform(); 16 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 17 | texcoord = gl_MultiTexCoord0; 18 | tintColor = gl_Color; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_armor_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec4 texcoord; 4 | varying vec4 tintColor; 5 | 6 | uniform int frameCounter; 7 | 8 | #include "/lib/essentials.glsl" 9 | 10 | 11 | 12 | void main() 13 | { 14 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 15 | gl_Position = ftransform(); 16 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 17 | texcoord = gl_MultiTexCoord0; 18 | tintColor = gl_Color; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /shaders/composite13.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | uniform sampler2D depthtex1; 8 | 9 | 10 | /*DRAWBUFFERS:1*/ 11 | void main(){ 12 | if(floor(2.*tc)==vec2(1)){ 13 | gl_FragData[0]=filterCloud(colortex1,tc,1.,resolution,depthtex1); 14 | } 15 | else{ 16 | if(floor(2.*tc)==vec2(1,0.)){ 17 | gl_FragData[0]=filterCloudSh(colortex1,tc,1.,resolution); 18 | }else{ 19 | gl_FragData[0]=texture2D(colortex1,tc); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shaders/composite2.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | uniform sampler2D depthtex1; 8 | 9 | 10 | /*DRAWBUFFERS:1*/ 11 | void main(){ 12 | if(floor(2.*tc)==vec2(1)){ 13 | gl_FragData[0]=filterCloud(colortex1,tc,2.,resolution,depthtex1); 14 | } 15 | else{ 16 | if(floor(2.*tc)==vec2(1,0.)){ 17 | gl_FragData[0]=filterCloudSh(colortex1,tc,2.,resolution); 18 | }else{ 19 | gl_FragData[0]=texture2D(colortex1,tc); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shaders/world-1/composite13.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | uniform sampler2D depthtex1; 8 | 9 | 10 | /*DRAWBUFFERS:1*/ 11 | void main(){ 12 | if(floor(2.*tc)==vec2(1)){ 13 | gl_FragData[0]=filterCloud(colortex1,tc,1.,resolution,depthtex1); 14 | } 15 | else{ 16 | if(floor(2.*tc)==vec2(1,0.)){ 17 | gl_FragData[0]=filterCloudSh(colortex1,tc,1.,resolution); 18 | }else{ 19 | gl_FragData[0]=texture2D(colortex1,tc); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shaders/world1/composite13.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex1; 7 | uniform sampler2D depthtex1; 8 | 9 | 10 | /*DRAWBUFFERS:1*/ 11 | void main(){ 12 | if(floor(2.*tc)==vec2(1)){ 13 | gl_FragData[0]=filterCloud(colortex1,tc,1.,resolution,depthtex1); 14 | } 15 | else{ 16 | if(floor(2.*tc)==vec2(1,0.)){ 17 | gl_FragData[0]=filterCloudSh(colortex1,tc,1.,resolution); 18 | }else{ 19 | gl_FragData[0]=texture2D(colortex1,tc); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shaders/shadow.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #include "lib/colorspace.glsl" 4 | uniform sampler2D texture; 5 | varying vec2 tc; 6 | varying vec4 tintColor; 7 | varying vec3 normal; 8 | 9 | //#define RSM_NORMAL_MAPPING 10 | #ifdef RSM_NORMAL_MAPPING 11 | uniform sampler2D normals; 12 | varying mat3 tbn; 13 | #endif 14 | 15 | 16 | void main(){ 17 | vec4 c=texture2D(texture,tc)*tintColor; 18 | c.rgb = srgbToLinear(c.rgb); 19 | gl_FragData[0] = c; 20 | #ifdef RSM_NORMAL_MAPPING 21 | vec3 n = tbn*(2.*texture2D(normals,tc).rgb-1.); 22 | gl_FragData[1]=vec4(n*.5+.5,1.); 23 | #else 24 | gl_FragData[1] = vec4(normal*.5+.5,1.); 25 | #endif 26 | } 27 | -------------------------------------------------------------------------------- /shaders/block.properties: -------------------------------------------------------------------------------- 1 | block.31 = grass fern tall_grass:half=lower wheat carrots potatoes beetroots large_fern:half=lower 2 | block.30 = oak_leaves birch_leaves jungle_leaves dark_oak_leaves spruce_leaves acacia_leaves tall_grass:half=upper large_fern:half=upper 3 | block.8 = water 4 | block.9 = flowing_water 5 | block.160 = white_stained_glass orange_stained_glass magenta_stained_glass light_blue_stained_glass yellow_stained_glass lime_stained_glass pink_stained_glass gray_stained_glass light_gray_stained_glass cyan_stained_glass purple_stained_glass blue_stained_glass brown_stained_glass green_stained_glass red_stained_glass black_stained_glass 6 | layer.translucent=minecraft:glass_pane minecraft:glass 7 | -------------------------------------------------------------------------------- /shaders/lib/wind.glsl: -------------------------------------------------------------------------------- 1 | vec3 wind (vec3 pos){ 2 | vec3 dirp = vec3(1.,-.01,1.4)*.2; 3 | 4 | vec3 dird = cos(frameTimeCounter*vec3(.99635256,1.01524,.345)*.5-pos*.1); 5 | //vec3 dird = vec3(cos(frameTimeCounter*.1-pos.x),sin(frameTimeCounter*.120126-pos.y),.5*cos(frameTimeCounter*.378+.01-pos.z)); 6 | 7 | float speed = 1.5; 8 | 9 | float phase = speed*frameTimeCounter+dot(pos,dirp); 10 | float a=.15+.05*sin(frameTimeCounter+phase*.2)+.05*rainStrength; 11 | 12 | float pressure = (sin(phase)*(1.+rainStrength)+.5*sin(phase*2.3015)+.18*cos(phase*3.953))/1.78; 13 | 14 | phase = speed*frameTimeCounter+2.*dot(pos,dirp.xzy); 15 | pressure = mix(pressure,(sin(phase)*(1.+rainStrength)+.5*sin(phase*2.3015)+.18*cos(phase*3.953))/1.78,.25); 16 | return dird*pressure*pressure*a; 17 | } 18 | -------------------------------------------------------------------------------- /shaders/gbuffers_basic.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #define NORMAL_MAPPING 3 | 4 | varying vec3 normal; 5 | varying vec4 texcoord; 6 | varying vec4 tintColor; 7 | varying vec4 lmcoord; 8 | #ifdef NORMAL_MAPPING 9 | varying mat3 tbn; 10 | 11 | attribute vec4 at_tangent; 12 | #endif 13 | 14 | uniform int frameCounter; 15 | 16 | #include "/lib/essentials.glsl" 17 | 18 | 19 | 20 | void main() 21 | { 22 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 23 | gl_Position = ftransform(); 24 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | texcoord = gl_MultiTexCoord0; 27 | lmcoord = gl_MultiTexCoord1; 28 | tintColor = gl_Color; 29 | 30 | #ifdef NORMAL_MAPPING 31 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 32 | vec3 binormal = cross(tangent,normal); 33 | tbn= mat3(tangent, binormal, normal); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /shaders/gbuffers_textured.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #define NORMAL_MAPPING 3 | 4 | varying vec3 normal; 5 | varying vec4 texcoord; 6 | varying vec4 tintColor; 7 | varying vec4 lmcoord; 8 | #ifdef NORMAL_MAPPING 9 | varying mat3 tbn; 10 | 11 | attribute vec4 at_tangent; 12 | #endif 13 | 14 | uniform int frameCounter; 15 | 16 | #include "/lib/essentials.glsl" 17 | 18 | 19 | 20 | void main() 21 | { 22 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 23 | gl_Position = ftransform(); 24 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | texcoord = gl_MultiTexCoord0; 27 | lmcoord = gl_MultiTexCoord1; 28 | tintColor = gl_Color; 29 | 30 | #ifdef NORMAL_MAPPING 31 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 32 | vec3 binormal = cross(tangent,normal); 33 | tbn= mat3(tangent, binormal, normal); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_basic.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #define NORMAL_MAPPING 3 | 4 | varying vec3 normal; 5 | varying vec4 texcoord; 6 | varying vec4 tintColor; 7 | varying vec4 lmcoord; 8 | #ifdef NORMAL_MAPPING 9 | varying mat3 tbn; 10 | 11 | attribute vec4 at_tangent; 12 | #endif 13 | 14 | uniform int frameCounter; 15 | 16 | #include "/lib/essentials.glsl" 17 | 18 | 19 | 20 | void main() 21 | { 22 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 23 | gl_Position = ftransform(); 24 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | texcoord = gl_MultiTexCoord0; 27 | lmcoord = gl_MultiTexCoord1; 28 | tintColor = gl_Color; 29 | 30 | #ifdef NORMAL_MAPPING 31 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 32 | vec3 binormal = cross(tangent,normal); 33 | tbn= mat3(tangent, binormal, normal); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_basic.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #define NORMAL_MAPPING 3 | 4 | varying vec3 normal; 5 | varying vec4 texcoord; 6 | varying vec4 tintColor; 7 | varying vec4 lmcoord; 8 | #ifdef NORMAL_MAPPING 9 | varying mat3 tbn; 10 | 11 | attribute vec4 at_tangent; 12 | #endif 13 | 14 | uniform int frameCounter; 15 | 16 | #include "/lib/essentials.glsl" 17 | 18 | 19 | 20 | void main() 21 | { 22 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 23 | gl_Position = ftransform(); 24 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | texcoord = gl_MultiTexCoord0; 27 | lmcoord = gl_MultiTexCoord1; 28 | tintColor = gl_Color; 29 | 30 | #ifdef NORMAL_MAPPING 31 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 32 | vec3 binormal = cross(tangent,normal); 33 | tbn= mat3(tangent, binormal, normal); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_textured.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #define NORMAL_MAPPING 3 | 4 | varying vec3 normal; 5 | varying vec4 texcoord; 6 | varying vec4 tintColor; 7 | varying vec4 lmcoord; 8 | #ifdef NORMAL_MAPPING 9 | varying mat3 tbn; 10 | 11 | attribute vec4 at_tangent; 12 | #endif 13 | 14 | uniform int frameCounter; 15 | 16 | #include "/lib/essentials.glsl" 17 | 18 | 19 | 20 | void main() 21 | { 22 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 23 | gl_Position = ftransform(); 24 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | texcoord = gl_MultiTexCoord0; 27 | lmcoord = gl_MultiTexCoord1; 28 | tintColor = gl_Color; 29 | 30 | #ifdef NORMAL_MAPPING 31 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 32 | vec3 binormal = cross(tangent,normal); 33 | tbn= mat3(tangent, binormal, normal); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_textured.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #define NORMAL_MAPPING 3 | 4 | varying vec3 normal; 5 | varying vec4 texcoord; 6 | varying vec4 tintColor; 7 | varying vec4 lmcoord; 8 | #ifdef NORMAL_MAPPING 9 | varying mat3 tbn; 10 | 11 | attribute vec4 at_tangent; 12 | #endif 13 | 14 | uniform int frameCounter; 15 | 16 | #include "/lib/essentials.glsl" 17 | 18 | 19 | 20 | void main() 21 | { 22 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 23 | gl_Position = ftransform(); 24 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | texcoord = gl_MultiTexCoord0; 27 | lmcoord = gl_MultiTexCoord1; 28 | tintColor = gl_Color; 29 | 30 | #ifdef NORMAL_MAPPING 31 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 32 | vec3 binormal = cross(tangent,normal); 33 | tbn= mat3(tangent, binormal, normal); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /shaders/lib/clouds.set: -------------------------------------------------------------------------------- 1 | #define cloud_min_plane 270. 2 | #define cloud_top_plane 490. 3 | #define cloud_low 300. 4 | #define cloud_high 390. 5 | 6 | #define cloud_mid cloud_low*.5+.5*cloud_high 7 | #define cloud_den (.05+.08*rainStrength) 8 | 9 | uniform int worldDay; 10 | int worldtime = (worldTime + 24000*worldDay); 11 | 12 | #define CLOUD_DETAILS 2 //[1 2 3] 13 | #define CLOUD_LIGHTING_DETAILS 1 //[1 2 3] 14 | 15 | #define turb -.05 16 | #define med .75 17 | #define smol .1 18 | #define mini .07 19 | 20 | #define CLOUD_SCALE 0.75 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] 21 | -------------------------------------------------------------------------------- /shaders/deferred4.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/trans.glsl" 4 | 5 | varying vec2 tc; 6 | //uniform sampler2D colortex0; 7 | uniform sampler2D colortex1; 8 | uniform sampler2D colortex4; 9 | uniform sampler2D depthtex1; 10 | 11 | vec3 filt(vec2 tc, sampler2D s){ 12 | vec3 a = vec3(0); 13 | float b =0.; 14 | float dp =depthLin(texture2D(depthtex1,tc).r); 15 | for(int i =-1;i<1;i++){ 16 | for(int j =-1;j<1;j++){ 17 | float si = 3.-float(i+j+i*j); 18 | vec2 sc = tc+1.5*vec2(i,j)/resolution; 19 | if(abs(depthLin(texture2D(depthtex1,sc).r)-dp)<.001/dp){ 20 | a+=si*texture2D(s,sc ).rgb; 21 | b+=si; 22 | } 23 | } 24 | } 25 | return a/b; 26 | } 27 | #define GLOBAL_ILLUMINATION 28 | /*DRAWBUFFERS:14*/ 29 | void main(){ 30 | gl_FragData[0]=vec4(filt(tc,colortex1).rg,texture2D(colortex1, tc).b,1.); 31 | #ifdef GLOBAL_ILLUMINATIOOOO 32 | gl_FragData[1]=vec4(filt(tc,colortex4),1.); 33 | #else 34 | gl_FragData[1]=texture2D(colortex4,tc); 35 | #endif 36 | 37 | } 38 | -------------------------------------------------------------------------------- /shaders/composite8.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | #include "lib/essentials.glsl" 5 | #include "lib/bloom.glsl" 6 | 7 | varying vec2 tc; 8 | uniform sampler2D colortex7; 9 | uniform sampler2D colortex0; 10 | uniform sampler2D colortex1; 11 | 12 | vec3 filt(vec2 tc, sampler2D s){ 13 | vec3 a = vec3(0); 14 | 15 | a=3.*texture2D(s, tc).rgb; 16 | a+=2.*texture2D(s, tc+vec2(0,1)/resolution).rgb; 17 | a+=2.*texture2D(s, tc+vec2(-1,0)/resolution).rgb; 18 | a+=2.*texture2D(s, tc+vec2(0,-1)/resolution).rgb; 19 | a+=2.*texture2D(s, tc+vec2(1,0)/resolution).rgb; 20 | a+=texture2D(s, tc+vec2(1,1)/resolution).rgb; 21 | a+=texture2D(s, tc+vec2(-1,1)/resolution).rgb; 22 | a+=texture2D(s, tc+vec2(1,-1)/resolution).rgb; 23 | a+=texture2D(s, tc+vec2(-1,-1)/resolution).rgb; 24 | return a/15.; 25 | } 26 | 27 | /*DRAWBUFFERS:01*/ 28 | void main(){ 29 | if(texture2D(colortex7, tc).r<.5){ 30 | gl_FragData[0]=texture2D(colortex0,tc); 31 | }else{ 32 | gl_FragData[0]=vec4(kawazePass(colortex0,tc,1.,resolution),1.); 33 | } 34 | 35 | gl_FragData[1]=vec4(kawazePass1(colortex0,tc,1.,resolution),1.); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /shaders/composite9.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex7; 7 | uniform sampler2D colortex0; 8 | uniform sampler2D colortex1; 9 | 10 | 11 | vec3 filt(vec2 tc, sampler2D s){ 12 | vec3 a = vec3(0); 13 | 14 | a=3.*texture2D(s, tc).rgb; 15 | a+=2.*texture2D(s, tc+3.*vec2(0,1)/resolution).rgb; 16 | a+=2.*texture2D(s, tc+3.*vec2(-1,0)/resolution).rgb; 17 | a+=2.*texture2D(s, tc+3.*vec2(0,-1)/resolution).rgb; 18 | a+=2.*texture2D(s, tc+3.*vec2(1,0)/resolution).rgb; 19 | a+=texture2D(s, tc+3.*vec2(1,1)/resolution).rgb; 20 | a+=texture2D(s, tc+3.*vec2(-1,1)/resolution).rgb; 21 | a+=texture2D(s, tc+3.*vec2(1,-1)/resolution).rgb; 22 | a+=texture2D(s, tc+3.*vec2(-1,-1)/resolution).rgb; 23 | return a/15.; 24 | } 25 | 26 | /*DRAWBUFFERS:01*/ 27 | void main(){ 28 | if(texture2D(colortex7, tc).g<.5){ 29 | gl_FragData[0]=texture2D(colortex0,tc); 30 | }else{ 31 | gl_FragData[0]=vec4(kawazePass(colortex0,tc,2.,resolution),1.); 32 | } 33 | gl_FragData[1]=vec4(kawazePass(colortex1,tc,2.,resolution),1.); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world1/composite8.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | #include "../lib/essentials.glsl" 5 | #include "../lib/bloom.glsl" 6 | 7 | varying vec2 tc; 8 | uniform sampler2D colortex7; 9 | uniform sampler2D colortex0; 10 | uniform sampler2D colortex1; 11 | 12 | vec3 filt(vec2 tc, sampler2D s){ 13 | vec3 a = vec3(0); 14 | 15 | a=3.*texture2D(s, tc).rgb; 16 | a+=2.*texture2D(s, tc+vec2(0,1)/resolution).rgb; 17 | a+=2.*texture2D(s, tc+vec2(-1,0)/resolution).rgb; 18 | a+=2.*texture2D(s, tc+vec2(0,-1)/resolution).rgb; 19 | a+=2.*texture2D(s, tc+vec2(1,0)/resolution).rgb; 20 | a+=texture2D(s, tc+vec2(1,1)/resolution).rgb; 21 | a+=texture2D(s, tc+vec2(-1,1)/resolution).rgb; 22 | a+=texture2D(s, tc+vec2(1,-1)/resolution).rgb; 23 | a+=texture2D(s, tc+vec2(-1,-1)/resolution).rgb; 24 | return a/15.; 25 | } 26 | 27 | /*DRAWBUFFERS:01*/ 28 | void main(){ 29 | if(texture2D(colortex7, tc).r<.5){ 30 | gl_FragData[0]=texture2D(colortex0,tc); 31 | }else{ 32 | gl_FragData[0]=vec4(kawazePass(colortex0,tc,1.,resolution),1.); 33 | } 34 | 35 | gl_FragData[1]=vec4(kawazePass1(colortex0,tc,1.,resolution),1.); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /shaders/world-1/composite8.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | #include "../lib/essentials.glsl" 5 | #include "../lib/bloom.glsl" 6 | 7 | varying vec2 tc; 8 | uniform sampler2D colortex7; 9 | uniform sampler2D colortex0; 10 | uniform sampler2D colortex1; 11 | 12 | vec3 filt(vec2 tc, sampler2D s){ 13 | vec3 a = vec3(0); 14 | 15 | a=3.*texture2D(s, tc).rgb; 16 | a+=2.*texture2D(s, tc+vec2(0,1)/resolution).rgb; 17 | a+=2.*texture2D(s, tc+vec2(-1,0)/resolution).rgb; 18 | a+=2.*texture2D(s, tc+vec2(0,-1)/resolution).rgb; 19 | a+=2.*texture2D(s, tc+vec2(1,0)/resolution).rgb; 20 | a+=texture2D(s, tc+vec2(1,1)/resolution).rgb; 21 | a+=texture2D(s, tc+vec2(-1,1)/resolution).rgb; 22 | a+=texture2D(s, tc+vec2(1,-1)/resolution).rgb; 23 | a+=texture2D(s, tc+vec2(-1,-1)/resolution).rgb; 24 | return a/15.; 25 | } 26 | 27 | /*DRAWBUFFERS:01*/ 28 | void main(){ 29 | if(texture2D(colortex7, tc).r<.5){ 30 | gl_FragData[0]=texture2D(colortex0,tc); 31 | }else{ 32 | gl_FragData[0]=vec4(kawazePass(colortex0,tc,1.,resolution),1.); 33 | } 34 | 35 | gl_FragData[1]=vec4(kawazePass1(colortex0,tc,1.,resolution),1.); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /shaders/world-1/composite9.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex7; 7 | uniform sampler2D colortex0; 8 | uniform sampler2D colortex1; 9 | 10 | 11 | vec3 filt(vec2 tc, sampler2D s){ 12 | vec3 a = vec3(0); 13 | 14 | a=3.*texture2D(s, tc).rgb; 15 | a+=2.*texture2D(s, tc+3.*vec2(0,1)/resolution).rgb; 16 | a+=2.*texture2D(s, tc+3.*vec2(-1,0)/resolution).rgb; 17 | a+=2.*texture2D(s, tc+3.*vec2(0,-1)/resolution).rgb; 18 | a+=2.*texture2D(s, tc+3.*vec2(1,0)/resolution).rgb; 19 | a+=texture2D(s, tc+3.*vec2(1,1)/resolution).rgb; 20 | a+=texture2D(s, tc+3.*vec2(-1,1)/resolution).rgb; 21 | a+=texture2D(s, tc+3.*vec2(1,-1)/resolution).rgb; 22 | a+=texture2D(s, tc+3.*vec2(-1,-1)/resolution).rgb; 23 | return a/15.; 24 | } 25 | 26 | /*DRAWBUFFERS:01*/ 27 | void main(){ 28 | if(texture2D(colortex7, tc).g<.5){ 29 | gl_FragData[0]=texture2D(colortex0,tc); 30 | }else{ 31 | gl_FragData[0]=vec4(kawazePass(colortex0,tc,2.,resolution),1.); 32 | } 33 | gl_FragData[1]=vec4(kawazePass(colortex1,tc,2.,resolution),1.); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world1/composite9.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/bloom.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex7; 7 | uniform sampler2D colortex0; 8 | uniform sampler2D colortex1; 9 | 10 | 11 | vec3 filt(vec2 tc, sampler2D s){ 12 | vec3 a = vec3(0); 13 | 14 | a=3.*texture2D(s, tc).rgb; 15 | a+=2.*texture2D(s, tc+3.*vec2(0,1)/resolution).rgb; 16 | a+=2.*texture2D(s, tc+3.*vec2(-1,0)/resolution).rgb; 17 | a+=2.*texture2D(s, tc+3.*vec2(0,-1)/resolution).rgb; 18 | a+=2.*texture2D(s, tc+3.*vec2(1,0)/resolution).rgb; 19 | a+=texture2D(s, tc+3.*vec2(1,1)/resolution).rgb; 20 | a+=texture2D(s, tc+3.*vec2(-1,1)/resolution).rgb; 21 | a+=texture2D(s, tc+3.*vec2(1,-1)/resolution).rgb; 22 | a+=texture2D(s, tc+3.*vec2(-1,-1)/resolution).rgb; 23 | return a/15.; 24 | } 25 | 26 | /*DRAWBUFFERS:01*/ 27 | void main(){ 28 | if(texture2D(colortex7, tc).g<.5){ 29 | gl_FragData[0]=texture2D(colortex0,tc); 30 | }else{ 31 | gl_FragData[0]=vec4(kawazePass(colortex0,tc,2.,resolution),1.); 32 | } 33 | gl_FragData[1]=vec4(kawazePass(colortex1,tc,2.,resolution),1.); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /shaders/world-1/deferred6.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "/lib/essentials.glsl" 3 | #include "/lib/trans.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex7; 7 | uniform sampler2D colortex1; 8 | uniform sampler2D colortex4; 9 | uniform sampler2D colortex0; 10 | uniform sampler2D colortex3; 11 | uniform sampler2D depthtex1; 12 | 13 | uniform sampler2D gnormal; 14 | 15 | uniform vec3 shadowLightPosition; 16 | uniform int worldTime; 17 | 18 | 19 | 20 | #define AMBIENT_OCCLUSION 21 | #define GLOBAL_ILLUMINATION 22 | 23 | #define EMMISIVE_MAP 24 | #define OREN_NAYAR_DIFFUSE 25 | #define USE_METALS 26 | 27 | /*DRAWBUFFERS:07*/ 28 | void main(){ 29 | vec3 gi = texture2D(colortex4,tc).rgb; 30 | vec3 lme = texture2D(colortex7,tc).rgb; 31 | float pxdpth = texture2D(depthtex1,tc).r; 32 | vec3 pbr = texture2D(colortex3,tc).rgb; 33 | #ifdef EMMISIVE_MAP 34 | float emmisiveness =lme.b; 35 | #else 36 | float emmisiveness=0.; 37 | #endif 38 | vec4 c = texture2D(colortex0,tc); 39 | 40 | #ifdef USE_METALS 41 | #else 42 | pbr.g*=0.; 43 | #endif 44 | gl_FragData[0]=vec4(c.rgb*((pxdpth<1.&&pbr.g<.9)? 45 | (gi+emmisiveness) 46 | :vec3(1)),1.); 47 | gl_FragData[1]=vec4(lme.rg,0.,1.); 48 | } 49 | -------------------------------------------------------------------------------- /shaders/world1/deferred6.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "/lib/essentials.glsl" 3 | #include "/lib/trans.glsl" 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex7; 7 | uniform sampler2D colortex1; 8 | uniform sampler2D colortex4; 9 | uniform sampler2D colortex0; 10 | uniform sampler2D colortex3; 11 | uniform sampler2D depthtex1; 12 | 13 | uniform sampler2D gnormal; 14 | 15 | uniform vec3 shadowLightPosition; 16 | uniform int worldTime; 17 | 18 | 19 | 20 | #define AMBIENT_OCCLUSION 21 | #define GLOBAL_ILLUMINATION 22 | 23 | #define EMMISIVE_MAP 24 | #define OREN_NAYAR_DIFFUSE 25 | #define USE_METALS 26 | 27 | /*DRAWBUFFERS:07*/ 28 | void main(){ 29 | vec3 gi = texture2D(colortex4,tc).rgb; 30 | vec3 lme = texture2D(colortex7,tc).rgb; 31 | float pxdpth = texture2D(depthtex1,tc).r; 32 | vec3 pbr = texture2D(colortex3,tc).rgb; 33 | #ifdef EMMISIVE_MAP 34 | float emmisiveness =lme.b; 35 | #else 36 | float emmisiveness=0.; 37 | #endif 38 | vec4 c = texture2D(colortex0,tc); 39 | 40 | #ifdef USE_METALS 41 | #else 42 | pbr.g*=0.; 43 | #endif 44 | gl_FragData[0]=vec4(c.rgb*((pxdpth<1.&&pbr.g<.9)? 45 | (gi+emmisiveness) 46 | :vec3(1)),1.); 47 | gl_FragData[1]=vec4(lme.rg,0.,1.); 48 | } 49 | -------------------------------------------------------------------------------- /shaders/gbuffers_block.vsh: -------------------------------------------------------------------------------- 1 | #version 420 compatibility 2 | 3 | out vec3 normal; 4 | out vec4 texcoord; 5 | out vec4 tintColor; 6 | out vec4 lmcoord; 7 | out mat3 tbn; 8 | out vec3 vpos; 9 | out vec2 midTexCoord; 10 | out vec2 texres; 11 | out vec3 wpos; 12 | attribute vec4 at_tangent; 13 | attribute vec2 mc_midTexCoord; 14 | 15 | uniform vec3 cameraPosition; 16 | 17 | uniform int frameCounter; 18 | 19 | #include "/lib/essentials.glsl" 20 | 21 | uniform mat4 gbufferModelViewInverse; 22 | 23 | 24 | void main() 25 | { 26 | midTexCoord = mc_midTexCoord; 27 | 28 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 29 | gl_Position = ftransform(); 30 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 31 | normal= normalize(gl_NormalMatrix*gl_Normal); 32 | texcoord = gl_MultiTexCoord0; 33 | lmcoord = gl_MultiTexCoord1; 34 | tintColor = gl_Color; 35 | 36 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 37 | vec3 binormal = cross(tangent,normal); 38 | tbn= mat3(tangent, binormal, normal); 39 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 40 | wpos = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 41 | texres = (2.*abs(texcoord.st-midTexCoord)); 42 | } 43 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_block.vsh: -------------------------------------------------------------------------------- 1 | #version 420 compatibility 2 | 3 | out vec3 normal; 4 | out vec4 texcoord; 5 | out vec4 tintColor; 6 | out vec4 lmcoord; 7 | out mat3 tbn; 8 | out vec3 vpos; 9 | out vec2 midTexCoord; 10 | out vec2 texres; 11 | out vec3 wpos; 12 | attribute vec4 at_tangent; 13 | attribute vec2 mc_midTexCoord; 14 | 15 | uniform vec3 cameraPosition; 16 | 17 | uniform int frameCounter; 18 | 19 | #include "/lib/essentials.glsl" 20 | 21 | uniform mat4 gbufferModelViewInverse; 22 | 23 | 24 | void main() 25 | { 26 | midTexCoord = mc_midTexCoord; 27 | 28 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 29 | gl_Position = ftransform(); 30 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 31 | normal= normalize(gl_NormalMatrix*gl_Normal); 32 | texcoord = gl_MultiTexCoord0; 33 | lmcoord = gl_MultiTexCoord1; 34 | tintColor = gl_Color; 35 | 36 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 37 | vec3 binormal = cross(tangent,normal); 38 | tbn= mat3(tangent, binormal, normal); 39 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 40 | wpos = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 41 | texres = (2.*abs(texcoord.st-midTexCoord)); 42 | } 43 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_block.vsh: -------------------------------------------------------------------------------- 1 | #version 420 compatibility 2 | 3 | out vec3 normal; 4 | out vec4 texcoord; 5 | out vec4 tintColor; 6 | out vec4 lmcoord; 7 | out mat3 tbn; 8 | out vec3 vpos; 9 | out vec2 midTexCoord; 10 | out vec2 texres; 11 | out vec3 wpos; 12 | attribute vec4 at_tangent; 13 | attribute vec2 mc_midTexCoord; 14 | 15 | uniform vec3 cameraPosition; 16 | 17 | uniform int frameCounter; 18 | 19 | #include "/lib/essentials.glsl" 20 | 21 | uniform mat4 gbufferModelViewInverse; 22 | 23 | 24 | void main() 25 | { 26 | midTexCoord = mc_midTexCoord; 27 | 28 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 29 | gl_Position = ftransform(); 30 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 31 | normal= normalize(gl_NormalMatrix*gl_Normal); 32 | texcoord = gl_MultiTexCoord0; 33 | lmcoord = gl_MultiTexCoord1; 34 | tintColor = gl_Color; 35 | 36 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 37 | vec3 binormal = cross(tangent,normal); 38 | tbn= mat3(tangent, binormal, normal); 39 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 40 | wpos = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 41 | texres = (2.*abs(texcoord.st-midTexCoord)); 42 | } 43 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_terrain.vsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | varying vec3 normal; 4 | varying vec4 texcoord; 5 | varying vec4 tintColor; 6 | varying vec4 lmcoord; 7 | varying mat3 tbn; 8 | varying vec3 vpos; 9 | varying vec2 midTexCoord; 10 | varying vec2 texres; 11 | varying vec3 wpos; 12 | attribute vec4 at_tangent; 13 | attribute vec2 mc_midTexCoord; 14 | 15 | uniform vec3 cameraPosition; 16 | 17 | uniform int frameCounter; 18 | 19 | #include "/lib/essentials.glsl" 20 | 21 | uniform mat4 gbufferModelViewInverse; 22 | 23 | 24 | void main() 25 | { 26 | midTexCoord = mc_midTexCoord; 27 | 28 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 29 | gl_Position = ftransform(); 30 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 31 | normal= normalize(gl_NormalMatrix*gl_Normal); 32 | texcoord = gl_MultiTexCoord0; 33 | lmcoord = gl_MultiTexCoord1; 34 | tintColor = gl_Color; 35 | 36 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 37 | vec3 binormal = cross(tangent,normal); 38 | tbn= mat3(tangent, binormal, normal); 39 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 40 | wpos = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 41 | texres = (2.*abs(texcoord.st-midTexCoord)); 42 | } 43 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_terrain.vsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | varying vec3 normal; 4 | varying vec4 texcoord; 5 | varying vec4 tintColor; 6 | varying vec4 lmcoord; 7 | varying mat3 tbn; 8 | varying vec3 vpos; 9 | varying vec2 midTexCoord; 10 | varying vec2 texres; 11 | varying vec3 wpos; 12 | attribute vec4 at_tangent; 13 | attribute vec2 mc_midTexCoord; 14 | 15 | uniform vec3 cameraPosition; 16 | 17 | uniform int frameCounter; 18 | 19 | #include "/lib/essentials.glsl" 20 | 21 | uniform mat4 gbufferModelViewInverse; 22 | 23 | 24 | void main() 25 | { 26 | midTexCoord = mc_midTexCoord; 27 | 28 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 29 | gl_Position = ftransform(); 30 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 31 | normal= normalize(gl_NormalMatrix*gl_Normal); 32 | texcoord = gl_MultiTexCoord0; 33 | lmcoord = gl_MultiTexCoord1; 34 | tintColor = gl_Color; 35 | 36 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 37 | vec3 binormal = cross(tangent,normal); 38 | tbn= mat3(tangent, binormal, normal); 39 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 40 | wpos = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 41 | texres = (2.*abs(texcoord.st-midTexCoord)); 42 | } 43 | -------------------------------------------------------------------------------- /shaders/gbuffers_water.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec3 normal; 4 | varying vec4 texcoord; 5 | varying vec4 tintColor; 6 | varying vec4 lmcoord; 7 | varying mat3 tnb; 8 | varying mat3 tbn; 9 | varying vec3 position; 10 | varying vec3 vpos; 11 | varying vec2 midTexCoord; 12 | varying float entity; 13 | varying vec2 texres; 14 | 15 | 16 | uniform int frameCounter; 17 | uniform mat4 gbufferModelViewInverse; 18 | uniform vec3 cameraPosition; 19 | 20 | attribute vec4 at_tangent; 21 | attribute vec2 mc_midTexCoord; 22 | attribute vec2 mc_Entity; 23 | 24 | 25 | #include "lib/essentials.glsl" 26 | 27 | 28 | void main() 29 | { 30 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 31 | midTexCoord = mc_midTexCoord; 32 | gl_Position = ftransform(); 33 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 34 | texcoord = gl_MultiTexCoord0; 35 | lmcoord = gl_MultiTexCoord1; 36 | tintColor = gl_Color; 37 | position = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 38 | vec3 t,b; 39 | normal= normalize(gl_NormalMatrix*gl_Normal); 40 | t=normalize(gl_NormalMatrix*at_tangent.xyz); 41 | b= cross(t,normal); 42 | tnb = mat3(t,normal,b); 43 | tbn = mat3(t,b,normal); 44 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 45 | entity=mc_Entity.x; 46 | texres = 2.*abs(texcoord.st-midTexCoord); 47 | } 48 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_water.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec3 normal; 4 | varying vec4 texcoord; 5 | varying vec4 tintColor; 6 | varying vec4 lmcoord; 7 | varying mat3 tnb; 8 | varying mat3 tbn; 9 | varying vec3 position; 10 | varying vec3 vpos; 11 | varying vec2 midTexCoord; 12 | varying float entity; 13 | varying vec2 texres; 14 | 15 | 16 | uniform int frameCounter; 17 | uniform mat4 gbufferModelViewInverse; 18 | uniform vec3 cameraPosition; 19 | 20 | attribute vec4 at_tangent; 21 | attribute vec2 mc_midTexCoord; 22 | attribute vec2 mc_Entity; 23 | 24 | 25 | #include "/lib/essentials.glsl" 26 | 27 | 28 | void main() 29 | { 30 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 31 | midTexCoord = mc_midTexCoord; 32 | gl_Position = ftransform(); 33 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 34 | texcoord = gl_MultiTexCoord0; 35 | lmcoord = gl_MultiTexCoord1; 36 | tintColor = gl_Color; 37 | position = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 38 | vec3 t,b; 39 | normal= normalize(gl_NormalMatrix*gl_Normal); 40 | t=normalize(gl_NormalMatrix*at_tangent.xyz); 41 | b= cross(t,normal); 42 | tnb = mat3(t,normal,b); 43 | tbn = mat3(t,b,normal); 44 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 45 | entity=mc_Entity.x; 46 | texres = 2.*abs(texcoord.st-midTexCoord); 47 | } 48 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_water.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec3 normal; 4 | varying vec4 texcoord; 5 | varying vec4 tintColor; 6 | varying vec4 lmcoord; 7 | varying mat3 tnb; 8 | varying mat3 tbn; 9 | varying vec3 position; 10 | varying vec3 vpos; 11 | varying vec2 midTexCoord; 12 | varying float entity; 13 | varying vec2 texres; 14 | 15 | 16 | uniform int frameCounter; 17 | uniform mat4 gbufferModelViewInverse; 18 | uniform vec3 cameraPosition; 19 | 20 | attribute vec4 at_tangent; 21 | attribute vec2 mc_midTexCoord; 22 | attribute vec2 mc_Entity; 23 | 24 | 25 | #include "/lib/essentials.glsl" 26 | 27 | 28 | void main() 29 | { 30 | vec2 offset = vec2(haltonSeq(5,frameCounter),haltonSeq(7,frameCounter+12)); 31 | midTexCoord = mc_midTexCoord; 32 | gl_Position = ftransform(); 33 | gl_Position.xy += 2.*(offset-.5)*gl_Position.w/resolution; 34 | texcoord = gl_MultiTexCoord0; 35 | lmcoord = gl_MultiTexCoord1; 36 | tintColor = gl_Color; 37 | position = (gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex)).xyz+cameraPosition; 38 | vec3 t,b; 39 | normal= normalize(gl_NormalMatrix*gl_Normal); 40 | t=normalize(gl_NormalMatrix*at_tangent.xyz); 41 | b= cross(t,normal); 42 | tnb = mat3(t,normal,b); 43 | tbn = mat3(t,b,normal); 44 | vpos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz; 45 | entity=mc_Entity.x; 46 | texres = 2.*abs(texcoord.st-midTexCoord); 47 | } 48 | -------------------------------------------------------------------------------- /shaders/gbuffers_basic.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #define NORMAL_MAPPING 4 | 5 | #include "/common/pbrformats" 6 | 7 | 8 | uniform sampler2D texture; 9 | #ifdef NORMAL_MAPPING 10 | uniform sampler2D normals; 11 | #endif 12 | #if PBR_FORMAT 13 | uniform sampler2D specular; 14 | #endif 15 | #include "/lib/colorspace.glsl" 16 | 17 | varying vec3 normal; 18 | varying vec4 texcoord; 19 | varying vec4 tintColor; 20 | varying vec4 lmcoord; 21 | varying mat3 tbn; 22 | 23 | /*DRAWBUFFERS:03271*/ 24 | 25 | void main() 26 | { 27 | vec2 lm = lmcoord.xy/256.; 28 | vec3 blocklightdir = tbn*normalize(vec3(dFdx(lm.x),-dFdy(lm.x),.005*(1.-sqrt(lm.x)))); 29 | #if PBR_FORMAT 30 | vec4 PBRdata = texture2D(specular,texcoord.st); 31 | #else 32 | vec4 PBRdata = vec4(0); 33 | #endif 34 | #if PBR_FORMAT == labPBRv1_3 35 | PBRdata.g = sqrt(PBRdata.g); 36 | #endif 37 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor; 38 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 39 | // gl_FragData[0].rgb=PBRdata.rgb; 40 | gl_FragData[1]=vec4(PBRdata.rgb,1); 41 | float ao = 1.; 42 | #ifdef NORMAL_MAPPING 43 | #define gettex texture2D 44 | vec2 uv = texcoord.st; 45 | vec3 n; 46 | #include "/lib/normals.glsl" 47 | gl_FragData[2]=vec4(n*.5+.5,1.); 48 | //lm.x*=max(0.,dot(n,blocklightdir)); 49 | #else 50 | gl_FragData[2]=vec4(.5+.5*normal,1.); 51 | #endif 52 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 53 | //gl_FragData[0].rgb*=ao*ao; 54 | gl_FragData[4]=vec4(ao,1,1,1); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_basic.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #define NORMAL_MAPPING 4 | #include "/common/pbrformats" 5 | 6 | 7 | uniform sampler2D texture; 8 | #ifdef NORMAL_MAPPING 9 | uniform sampler2D normals; 10 | #endif 11 | #if PBR_FORMAT 12 | uniform sampler2D specular; 13 | #endif 14 | #include "/lib/colorspace.glsl" 15 | 16 | varying vec3 normal; 17 | varying vec4 texcoord; 18 | varying vec4 tintColor; 19 | varying vec4 lmcoord; 20 | varying mat3 tbn; 21 | 22 | /*DRAWBUFFERS:03271*/ 23 | 24 | void main() 25 | { 26 | vec2 lm = lmcoord.xy/256.; 27 | vec3 blocklightdir = tbn*normalize(vec3(dFdx(lm.x),-dFdy(lm.x),.005*(1.-sqrt(lm.x)))); 28 | #if PBR_FORMAT 29 | vec4 PBRdata = texture2D(specular,texcoord.st); 30 | #else 31 | vec4 PBRdata = vec4(0); 32 | #endif 33 | #if PBR_FORMAT == labPBRv1_3 34 | PBRdata.g = sqrt(PBRdata.g); 35 | #endif 36 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor; 37 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 38 | // gl_FragData[0].rgb=PBRdata.rgb; 39 | gl_FragData[1]=vec4(PBRdata.rgb,1); 40 | float ao = 0.; 41 | #ifdef NORMAL_MAPPING 42 | #define gettex texture2D 43 | vec2 uv = texcoord.st; 44 | vec3 n; 45 | #include "/lib/normals.glsl" 46 | gl_FragData[2]=vec4(n*.5+.5,1.); 47 | lm*=ao*ao; 48 | //lm.x*=max(0.,dot(n,blocklightdir)); 49 | #else 50 | gl_FragData[2]=vec4(.5+.5*normal,1.); 51 | #endif 52 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 53 | //gl_FragData[0].rgb*=ao*ao; 54 | gl_FragData[4]=vec4(ao*ao,1,1,1); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_basic.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #define NORMAL_MAPPING 4 | #include "/common/pbrformats" 5 | 6 | 7 | uniform sampler2D texture; 8 | #ifdef NORMAL_MAPPING 9 | uniform sampler2D normals; 10 | #endif 11 | #if PBR_FORMAT 12 | uniform sampler2D specular; 13 | #endif 14 | #include "/lib/colorspace.glsl" 15 | 16 | varying vec3 normal; 17 | varying vec4 texcoord; 18 | varying vec4 tintColor; 19 | varying vec4 lmcoord; 20 | varying mat3 tbn; 21 | 22 | /*DRAWBUFFERS:03271*/ 23 | 24 | void main() 25 | { 26 | vec2 lm = lmcoord.xy/256.; 27 | vec3 blocklightdir = tbn*normalize(vec3(dFdx(lm.x),-dFdy(lm.x),.005*(1.-sqrt(lm.x)))); 28 | #if PBR_FORMAT 29 | vec4 PBRdata = texture2D(specular,texcoord.st); 30 | #else 31 | vec4 PBRdata = vec4(0); 32 | #endif 33 | #if PBR_FORMAT == labPBRv1_3 34 | PBRdata.g = sqrt(PBRdata.g); 35 | #endif 36 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor; 37 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 38 | // gl_FragData[0].rgb=PBRdata.rgb; 39 | gl_FragData[1]=vec4(PBRdata.rgb,1); 40 | float ao = 0.; 41 | #ifdef NORMAL_MAPPING 42 | #define gettex texture2D 43 | vec2 uv = texcoord.st; 44 | vec3 n; 45 | #include "/lib/normals.glsl" 46 | gl_FragData[2]=vec4(n*.5+.5,1.); 47 | lm*=ao*ao; 48 | //lm.x*=max(0.,dot(n,blocklightdir)); 49 | #else 50 | gl_FragData[2]=vec4(.5+.5*normal,1.); 51 | #endif 52 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 53 | //gl_FragData[0].rgb*=ao*ao; 54 | gl_FragData[4]=vec4(ao*ao,1,1,1); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shaders/gbuffers_textured.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #define NORMAL_MAPPING 4 | 5 | #include "/common/pbrformats" 6 | 7 | 8 | uniform sampler2D texture; 9 | #ifdef NORMAL_MAPPING 10 | uniform sampler2D normals; 11 | #endif 12 | #if PBR_FORMAT 13 | uniform sampler2D specular; 14 | #endif 15 | #include "/lib/colorspace.glsl" 16 | 17 | varying vec3 normal; 18 | varying vec4 texcoord; 19 | varying vec4 tintColor; 20 | varying vec4 lmcoord; 21 | varying mat3 tbn; 22 | uniform vec4 entityColor; 23 | uniform int entityId; 24 | /*DRAWBUFFERS:03271*/ 25 | 26 | void main() 27 | { 28 | vec2 lm = lmcoord.xy/256.; 29 | vec3 blocklightdir = tbn*normalize(vec3(dFdx(lm.x),-dFdy(lm.x),.005*(1.-sqrt(lm.x)))); 30 | #if PBR_FORMAT 31 | vec4 PBRdata = texture2D(specular,texcoord.st); 32 | #else 33 | vec4 PBRdata = vec4(0); 34 | #endif 35 | #if PBR_FORMAT == labPBRv1_3 36 | PBRdata.g = sqrt(PBRdata.g); 37 | #endif 38 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor+vec4(entityColor.rgb,0); 39 | 40 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 41 | gl_FragData[1]=vec4(PBRdata.rgb,1); 42 | float ao = 1.; 43 | #ifdef NORMAL_MAPPING 44 | #define gettex texture2D 45 | vec2 uv = texcoord.st; 46 | vec3 n; 47 | #include "/lib/normals.glsl" 48 | 49 | gl_FragData[2]=vec4(n*.5+.5,gl_FragData[0].a); 50 | //lm*=ao; 51 | #else 52 | gl_FragData[2]=vec4(.5+.5*normal,gl_FragData[0].a); 53 | #endif 54 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 55 | //gl_FragData[0].rgb*=ao*ao; 56 | gl_FragData[4]=vec4(ao,1,1,1); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_textured.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #define NORMAL_MAPPING 4 | 5 | #include "/common/pbrformats" 6 | 7 | 8 | uniform sampler2D texture; 9 | #ifdef NORMAL_MAPPING 10 | uniform sampler2D normals; 11 | #endif 12 | #if PBR_FORMAT 13 | uniform sampler2D specular; 14 | #endif 15 | #include "/lib/colorspace.glsl" 16 | 17 | varying vec3 normal; 18 | varying vec4 texcoord; 19 | varying vec4 tintColor; 20 | varying vec4 lmcoord; 21 | varying mat3 tbn; 22 | uniform vec4 entityColor; 23 | uniform int entityId; 24 | /*DRAWBUFFERS:03271*/ 25 | 26 | void main() 27 | { 28 | vec2 lm = lmcoord.xy/256.; 29 | vec3 blocklightdir = tbn*normalize(vec3(dFdx(lm.x),-dFdy(lm.x),.005*(1.-sqrt(lm.x)))); 30 | #if PBR_FORMAT 31 | vec4 PBRdata = texture2D(specular,texcoord.st); 32 | #else 33 | vec4 PBRdata = vec4(0); 34 | #endif 35 | #if PBR_FORMAT == labPBRv1_3 36 | PBRdata.g = sqrt(PBRdata.g); 37 | #endif 38 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor+vec4(entityColor.rgb,0); 39 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 40 | gl_FragData[1]=vec4(PBRdata.rgb,1); 41 | float ao = 1.; 42 | #ifdef NORMAL_MAPPING 43 | #define gettex texture2D 44 | vec2 uv = texcoord.st; 45 | vec3 n; 46 | #include "/lib/normals.glsl" 47 | gl_FragData[2]=vec4(n*.5+.5,gl_FragData[0].a); 48 | //lm*=ao; 49 | #else 50 | gl_FragData[2]=vec4(.5+.5*normal,gl_FragData[0].a); 51 | #endif 52 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 53 | //gl_FragData[0].rgb*=ao*ao; 54 | gl_FragData[4]=vec4(ao,1,1,1); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_textured.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #define NORMAL_MAPPING 4 | 5 | #include "/common/pbrformats" 6 | 7 | 8 | uniform sampler2D texture; 9 | #ifdef NORMAL_MAPPING 10 | uniform sampler2D normals; 11 | #endif 12 | #if PBR_FORMAT 13 | uniform sampler2D specular; 14 | #endif 15 | #include "/lib/colorspace.glsl" 16 | 17 | varying vec3 normal; 18 | varying vec4 texcoord; 19 | varying vec4 tintColor; 20 | varying vec4 lmcoord; 21 | varying mat3 tbn; 22 | uniform vec4 entityColor; 23 | uniform int entityId; 24 | /*DRAWBUFFERS:03271*/ 25 | 26 | void main() 27 | { 28 | vec2 lm = lmcoord.xy/256.; 29 | vec3 blocklightdir = tbn*normalize(vec3(dFdx(lm.x),-dFdy(lm.x),.005*(1.-sqrt(lm.x)))); 30 | #if PBR_FORMAT 31 | vec4 PBRdata = texture2D(specular,texcoord.st); 32 | #else 33 | vec4 PBRdata = vec4(0); 34 | #endif 35 | #if PBR_FORMAT == labPBRv1_3 36 | PBRdata.g = sqrt(PBRdata.g); 37 | #endif 38 | gl_FragData[0]=texture2D(texture,texcoord.st)*tintColor+vec4(entityColor.rgb,0); 39 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb); 40 | gl_FragData[1]=vec4(PBRdata.rgb,1); 41 | float ao = 1.; 42 | #ifdef NORMAL_MAPPING 43 | #define gettex texture2D 44 | vec2 uv = texcoord.st; 45 | vec3 n; 46 | #include "/lib/normals.glsl" 47 | gl_FragData[2]=vec4(n*.5+.5,gl_FragData[0].a); 48 | //lm*=ao; 49 | #else 50 | gl_FragData[2]=vec4(.5+.5*normal,gl_FragData[0].a); 51 | #endif 52 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 53 | //gl_FragData[0].rgb*=ao*ao; 54 | gl_FragData[4]=vec4(ao,1,1,1); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shaders/shadow.vsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | #include "lib/shadowtransform.glsl" 4 | #include "lib/essentials.glsl" 5 | 6 | varying vec2 tc; 7 | varying vec4 tintColor; 8 | varying vec3 normal; 9 | //#define RSM_NORMAL_MAPPING //can improve the quality of gi in some situations, but is not worth the performance cost most of the time 10 | #ifdef RSM_NORMAL_MAPPING 11 | varying mat3 tbn; 12 | 13 | attribute vec4 at_tangent; 14 | #endif 15 | attribute vec4 mc_Entity; 16 | attribute vec2 mc_midTexCoord; 17 | uniform float frameTimeCounter; 18 | uniform float rainStrength; 19 | uniform vec3 cameraPosition; 20 | 21 | #include "lib/wind.glsl" 22 | 23 | void main() 24 | { 25 | normal= normalize(gl_NormalMatrix*gl_Normal); 26 | 27 | tc = gl_MultiTexCoord0.xy; 28 | gl_Position = gl_ModelViewMatrix*gl_Vertex; 29 | 30 | if(mc_Entity.x == 30){ 31 | gl_Position = shadowModelViewInverse*gl_Position; 32 | 33 | gl_Position.xyz+=wind(gl_Position.xyz+cameraPosition); 34 | 35 | gl_Position = shadowModelView*gl_Position; 36 | } 37 | 38 | if(mc_Entity.x == 31 ){ 39 | gl_Position = shadowModelViewInverse*gl_Position; 40 | 41 | bool istop = (tc.t < mc_midTexCoord.t); 42 | if(istop){ 43 | gl_Position.xyz+=wind(gl_Position.xyz+cameraPosition); 44 | } 45 | gl_Position = shadowModelView*gl_Position; 46 | } 47 | gl_Position = gl_ProjectionMatrix *gl_Position; 48 | 49 | gl_Position.xyz = stransformcam(gl_Position.xyz); 50 | 51 | tintColor = gl_Color; 52 | 53 | #ifdef RSM_NORMAL_MAPPING 54 | vec3 tangent = normalize(gl_NormalMatrix*normalize(at_tangent.xyz)); 55 | vec3 binormal = cross(tangent,normal); 56 | tbn= mat3(tangent, binormal, normal); 57 | #endif 58 | } 59 | -------------------------------------------------------------------------------- /shaders/lib/shadowtransform.glsl: -------------------------------------------------------------------------------- 1 | #define pow8(a) (a*=(a*=(a*=a))) 2 | 3 | float length8(vec2 a){ 4 | a=abs(a); 5 | return sqrt(sqrt(sqrt(pow8(a.x)+pow8(a.y)))); 6 | } 7 | 8 | 9 | uniform mat4 shadowProjection; 10 | uniform mat4 shadowModelView; 11 | 12 | uniform mat4 shadowProjectionInverse; 13 | uniform mat4 shadowModelViewInverse; 14 | //forwards shadow map 15 | 16 | vec3 sclip2view(vec3 clippos){ 17 | vec4 p =shadowProjectionInverse*vec4(clippos,1.); 18 | return p.xyz/p.w; 19 | } 20 | 21 | vec3 sview2cam(vec3 viewpos){ 22 | vec4 p =shadowModelViewInverse*vec4(viewpos,1); 23 | return p.xyz/p.w; 24 | } 25 | 26 | #define sclip2cam(clippos) sview2cam(sclip2view(clippos)) 27 | 28 | //backwards shadow map 29 | 30 | vec3 scam2view(vec3 campos){ 31 | vec4 p = shadowModelView*vec4(campos,1.); 32 | return p.xyz/p.w; 33 | } 34 | vec3 sview2clip(vec3 viewpos){ 35 | vec4 p = shadowProjection*vec4(viewpos,1.); 36 | return p.xyz/p.w; 37 | } 38 | 39 | vec3 scamdir(vec3 viewdir){ 40 | vec4 d = shadowModelViewInverse*vec4(viewdir,0); 41 | return d.xyz; 42 | } 43 | 44 | #define scam2clip(campos) sview2clip(scam2view(campos)) 45 | 46 | 47 | #define SHADOW_BIAS .4 //[.1 .2 .4 .6 .8 1. 1.2 1.4 1.6] 48 | 49 | vec3 stransformcam(vec3 campos){ 50 | campos.xy/=SHADOW_BIAS+length8(campos.xy); 51 | campos.z*=.4; 52 | return campos; 53 | } 54 | vec2 stransform2(vec2 campos){ 55 | campos.xy/=SHADOW_BIAS+length8(campos.xy); 56 | return campos; 57 | } 58 | float stransformd(float camdepth){ 59 | camdepth*=2.5; 60 | return camdepth; 61 | } 62 | 63 | 64 | float sdepthLin(float depth){ 65 | float diff = -2./shadowProjection[2][2]; 66 | float somm = 2.*shadowProjection[2][3]/shadowProjection[2][2]; 67 | return (diff)*(somm-diff)*.5 / (somm - depth * (diff)); 68 | } 69 | -------------------------------------------------------------------------------- /shaders/deferred.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/trans.glsl" 4 | #include "lib/sky.glsl" 5 | 6 | uniform sampler2D colortex0; 7 | uniform sampler2D depthtex1; 8 | 9 | 10 | varying vec2 tc; 11 | 12 | uniform sampler2D noisetex; 13 | uniform float frameTimeCounter; 14 | uniform int worldTime; 15 | uniform float rainStrength; 16 | uniform float wetness; 17 | 18 | 19 | #define iTime frameTimeCounter 20 | 21 | 22 | #include "lib/clouds.glsl" 23 | 24 | #define CLOUD_SHADOW_QUALITY 2.0 //[1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0] 25 | 26 | float cloudsh(vec3 ro,vec3 rd,vec2 I){ 27 | float h = dot(vec3(0,cloud_min_plane,0)-ro,vec3(0,1,0))/dot(rd,vec3(0,1,0)); 28 | float h2 = dot(vec3(0,cloud_top_plane,0)-ro,vec3(0,1,0))/dot(rd,vec3(0,1,0)); 29 | if((h<0.&&h2<0.)) 30 | return 1.; 31 | float t= h; 32 | h=max(h,h2), 33 | h2 = minp(t,h2); 34 | if(h2==0.)h=min(h,100.); 35 | float d = bayer16(I*resolution); 36 | vec3 p = ro+(h-d*(h2-=h)/CLOUD_SHADOW_QUALITY)*rd; 37 | float a =0.; 38 | float sts = h2/CLOUD_SHADOW_QUALITY; 39 | for(int i = 0;i++=1.))),1.); 76 | gl_FragData[1]=vec4(lme.rg,shd,1.); 77 | } 78 | -------------------------------------------------------------------------------- /shaders/lib/shadow_lite.glsl: -------------------------------------------------------------------------------- 1 | uniform int frameCounter; 2 | #define PCSS_ACCURACY 4 //[2 3 4 5 6] //Huge performance impact, little visual difference 3 | #define sshradius .1/PCSS_ACCURACY //radius in m*pixel/screenwidthh 4 | 5 | #define PCSS_SAMPLES 8 //[1 2 4 8 12 16] 6 | #define shadow_offset 0.0001 7 | #define GA 2.39996322973 8 | 9 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 10 | 11 | //#define SSCS 12 | 13 | #define PCSS 14 | //#define VOLUME_PCSS 15 | const int shadowMapResolution = 2048; //[512 1024 2048 4096] 16 | const float shadowDistance = 64.; //[16. 32. 64. 128. 256.] 17 | 18 | #define PCSS_STRENGTH 1. //[0. .25 .5 1. 1.5 2. 2.5 3. 3.5 4.] //0 disables PCSS, but keeps the filtering 19 | float getPenumbra(vec3 sp){ 20 | if (PCSS_STRENGTH==0.){ 21 | return 0.; 22 | }else{ 23 | int k = 0; 24 | float a = 0.; 25 | float r =0.; 26 | for(int i = 0;i=1.){ 23 | gl_FragData[1].rgb = mix(getSky3(normalize(screen2cam(vec3(tc,1.))))*.5,color.rgb,texture2D(colortex1,tc*.5+.5).b); 24 | } 25 | if(floor(2.*tc)==vec2(1)){ 26 | gl_FragData[0]=filterCloud(colortex1,tc,1.,resolution,depthtex1); 27 | } 28 | else{ 29 | if(floor(2.*tc)==vec2(1,0.)){ 30 | gl_FragData[0]=filterCloudSh(colortex1,tc,1.,resolution); 31 | }else{ 32 | if(floor(2.*tc)==vec2(0.)){ 33 | 34 | const float kernel[3] = float[](9./64., 3./32., 1./16.); 35 | vec3 sum = vec3(0); 36 | float cum_w = 0.0; 37 | float c_phi = 5.0; 38 | float n_phi = 0.5; 39 | 40 | 41 | vec3 cval = texture2D(colortex1, tc).xyz; 42 | vec3 nval = texture2D(colortex2, tc).xyz; 43 | 44 | float ang = 2.0*3.1415926535*hash(2510.12860182*tc.x + 7290.9126812*tc.y+5.1839513*frameCounter); 45 | mat2 m = mat2(cos(ang),sin(ang),-sin(ang),cos(ang)); 46 | float denoiseStrength = (2. + 3.*hash(6410.128752*tc.x + 3120.321374*tc.y+1.92357812*frameCounter)); 47 | for(int i=-1; i<2; i++){ 48 | for(int j=-1; j<2; j++){ 49 | vec2 uv = (tc+m*(vec2(i,j)* denoiseStrength)/resolution.xy); 50 | 51 | vec3 ctmp = texture2D(colortex1, uv).xyz; 52 | vec3 t = cval - ctmp; 53 | float dist2 = dot(t,t); 54 | float c_w = min(exp(-(dist2)/c_phi), 1.0); 55 | 56 | vec3 ntmp = texture2D(colortex2, uv*2.).xyz; 57 | t = nval - ntmp; 58 | dist2 = max(dot(t,t), 0.0); 59 | float n_w = min(exp(-(dist2)/n_phi), 1.0); 60 | 61 | int kerk = int(abs(i)+abs(j)); 62 | 63 | float weight0 = c_w*n_w; 64 | sum += ctmp*weight0*kernel[kerk]; 65 | cum_w += weight0*kernel[kerk]; 66 | } 67 | } 68 | gl_FragData[0]=vec4(sum/cum_w,1.); 69 | }else{ 70 | gl_FragData[0]=texture2D(colortex1,tc); 71 | } 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_block.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #extension GL_ARB_shader_texture_lod : enable 3 | #extension GL_ARB_gpu_shader4 : enable 4 | 5 | #define NORMAL_MAPPING 6 | //#define DIRECTIONAL_LIGHTMAPS //super broken, not recommended 7 | //#define AO_FIX 8 | 9 | #include "/common/pbrformats" 10 | 11 | 12 | uniform sampler2D texture; 13 | uniform sampler2D normals; 14 | #if PBR_FORMAT 15 | uniform sampler2D specular; 16 | #endif 17 | uniform sampler2D noisetex; 18 | #include "/lib/colorspace.glsl" 19 | #include "/lib/trans.glsl" 20 | #include "/lib/essentials.glsl" 21 | 22 | varying vec3 normal; 23 | varying vec4 texcoord; 24 | varying vec4 tintColor; 25 | varying vec4 lmcoord; 26 | varying mat3 tbn; 27 | varying vec3 vpos; 28 | varying vec2 midTexCoord; 29 | uniform vec3 shadowLightPosition; 30 | uniform float frameTimeCounter; 31 | uniform int frameCounter; 32 | varying vec3 wpos; 33 | 34 | const int noiseTextureResolution = 256; 35 | 36 | varying vec2 texres; 37 | #define tt texres // vec2(max(texres.x,texres.y)) 38 | 39 | float dither = bayer16(gl_FragCoord.xy); 40 | 41 | 42 | 43 | vec2 dcdx = dFdx(texcoord.rg); 44 | vec2 dcdy = dFdy(texcoord.rg); 45 | 46 | vec4 gettex(sampler2D t, vec2 v) 47 | { 48 | v =(v-midTexCoord)/texres+.5; 49 | v=(fract(v)-.5)*texres+midTexCoord; 50 | return texture2DGradARB(t,v,dcdx,dcdy); 51 | 52 | } 53 | 54 | 55 | /*DRAWBUFFERS:03271*/ 56 | void main() 57 | { 58 | 59 | vec2 uv = texcoord.st; 60 | vec2 lm = lmcoord.xy/256.; 61 | mat2 dlm = mat2(dFdx(lm.x),-dFdy(lm.x),dFdx(lm.y),-dFdy(lm.y)); 62 | vec3 blocklightdir = normalize(vec3(dlm[0],2.*length(dlm[0])*(lm.x))); 63 | #if PBR_FORMAT 64 | vec4 PBRdata =gettex(specular,uv); 65 | #else 66 | vec4 PBRdata = vec4(0); 67 | #endif 68 | #if PBR_FORMAT == labPBRv1_3 69 | PBRdata.g = sqrt(PBRdata.g); 70 | #endif 71 | 72 | gl_FragData[0]=gettex(texture,uv)*tintColor; 73 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb);//*step(abs(texres.x-texres.y),.0001);//*0.+blocklightdir; 74 | 75 | gl_FragData[4]=vec4(1); 76 | vec3 n = normal, nrml=normal; 77 | float ao=1.; 78 | #ifdef NORMAL_MAPPING 79 | #include "/lib/normals.glsl" 80 | #ifdef DIRECTIONAL_LIGHTMAPS 81 | float rgh = pow(1.-PBRdata.r,2.); 82 | lm.x=min(blocklightdir.z>.0?diffuse(vpos,blocklightdir,n*tbn,rgh)*(parallaxshadow(uv,blocklightdir)*.75+.25):1.,lm.x); 83 | //lm.y*=skylightdir.z>.01?max(0.1,dot(n*tbn,skylightdir))*parallaxshadow(uv,skylightdir):1.; 84 | #endif 85 | gl_FragData[4].r=(ao); 86 | //gl_FragData[0].rgb = vec3(ao*ao); 87 | 88 | 89 | #endif 90 | gl_FragData[2]=vec4(.5+.5*n,1.); 91 | 92 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 93 | 94 | gl_FragData[1]=vec4(PBRdata.rgb,1); 95 | } 96 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_block.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #extension GL_ARB_shader_texture_lod : enable 3 | #extension GL_ARB_gpu_shader4 : enable 4 | 5 | #define NORMAL_MAPPING 6 | //#define DIRECTIONAL_LIGHTMAPS //super broken, not recommended 7 | //#define AO_FIX 8 | 9 | #include "/common/pbrformats" 10 | 11 | 12 | uniform sampler2D texture; 13 | uniform sampler2D normals; 14 | #if PBR_FORMAT 15 | uniform sampler2D specular; 16 | #endif 17 | uniform sampler2D noisetex; 18 | #include "/lib/colorspace.glsl" 19 | #include "/lib/trans.glsl" 20 | #include "/lib/essentials.glsl" 21 | 22 | varying vec3 normal; 23 | varying vec4 texcoord; 24 | varying vec4 tintColor; 25 | varying vec4 lmcoord; 26 | varying mat3 tbn; 27 | varying vec3 vpos; 28 | varying vec2 midTexCoord; 29 | uniform vec3 shadowLightPosition; 30 | uniform float frameTimeCounter; 31 | uniform int frameCounter; 32 | varying vec3 wpos; 33 | 34 | const int noiseTextureResolution = 256; 35 | 36 | varying vec2 texres; 37 | #define tt texres // vec2(max(texres.x,texres.y)) 38 | 39 | float dither = bayer16(gl_FragCoord.xy); 40 | 41 | 42 | 43 | vec2 dcdx = dFdx(texcoord.rg); 44 | vec2 dcdy = dFdy(texcoord.rg); 45 | 46 | vec4 gettex(sampler2D t, vec2 v) 47 | { 48 | v =(v-midTexCoord)/texres+.5; 49 | v=(fract(v)-.5)*texres+midTexCoord; 50 | return texture2DGradARB(t,v,dcdx,dcdy); 51 | 52 | } 53 | 54 | 55 | /*DRAWBUFFERS:03271*/ 56 | void main() 57 | { 58 | 59 | vec2 uv = texcoord.st; 60 | vec2 lm = lmcoord.xy/256.; 61 | mat2 dlm = mat2(dFdx(lm.x),-dFdy(lm.x),dFdx(lm.y),-dFdy(lm.y)); 62 | vec3 blocklightdir = normalize(vec3(dlm[0],2.*length(dlm[0])*(lm.x))); 63 | #if PBR_FORMAT 64 | vec4 PBRdata =gettex(specular,uv); 65 | #else 66 | vec4 PBRdata = vec4(0); 67 | #endif 68 | #if PBR_FORMAT == labPBRv1_3 69 | PBRdata.g = sqrt(PBRdata.g); 70 | #endif 71 | 72 | gl_FragData[0]=gettex(texture,uv)*tintColor; 73 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb);//*step(abs(texres.x-texres.y),.0001);//*0.+blocklightdir; 74 | 75 | gl_FragData[4]=vec4(1); 76 | vec3 n = normal, nrml=normal; 77 | float ao=1.; 78 | #ifdef NORMAL_MAPPING 79 | #include "/lib/normals.glsl" 80 | #ifdef DIRECTIONAL_LIGHTMAPS 81 | float rgh = pow(1.-PBRdata.r,2.); 82 | lm.x=min(blocklightdir.z>.0?diffuse(vpos,blocklightdir,n*tbn,rgh)*(parallaxshadow(uv,blocklightdir)*.75+.25):1.,lm.x); 83 | //lm.y*=skylightdir.z>.01?max(0.1,dot(n*tbn,skylightdir))*parallaxshadow(uv,skylightdir):1.; 84 | #endif 85 | gl_FragData[4].r=(ao); 86 | //gl_FragData[0].rgb = vec3(ao*ao); 87 | 88 | 89 | #endif 90 | gl_FragData[2]=vec4(.5+.5*n,1.); 91 | 92 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 93 | 94 | gl_FragData[1]=vec4(PBRdata.rgb,1); 95 | } 96 | -------------------------------------------------------------------------------- /shaders/lib/bloom.glsl: -------------------------------------------------------------------------------- 1 | const float bloomscale =2.; 2 | 3 | vec3 loadpow(sampler2D s,vec2 tc){ 4 | vec3 c = texture2D(s,bloomscale*tc).rgb; 5 | float i = dot(c,vec3(.33333333333333)); 6 | return c*pow(i*1.3,2.5); 7 | } 8 | 9 | vec3 kawazePass(sampler2D s,vec2 tc,float i,vec2 res){ 10 | vec2 ii = (i+.5)/res; 11 | 12 | vec3 c=texture2D(s,tc+ii).rgb; 13 | c+=texture2D(s,tc-ii).rgb; 14 | ii.x=-ii.x; 15 | c+=texture2D(s,tc+ii).rgb; 16 | c+=texture2D(s,tc-ii).rgb; 17 | 18 | return c*.25; 19 | } 20 | 21 | 22 | vec3 kawazePass1(sampler2D s,vec2 tc,float i,vec2 res){ 23 | vec2 ii = (i+.5)/res; 24 | 25 | vec3 c=loadpow(s,tc+ii); 26 | c+=loadpow(s,tc-ii); 27 | ii.x=-ii.x; 28 | c+=loadpow(s,tc+ii); 29 | c+=loadpow(s,tc-ii); 30 | 31 | return c*.25; 32 | } 33 | 34 | vec3 kawazePassc(sampler2D s,vec2 tc,float i,vec2 res){ 35 | vec2 ii = (i+.5)/res; 36 | 37 | vec3 c=texture2D(s,clamp(tc+ii,vec2(0.),res/3.)).rgb; 38 | c+=texture2D(s,clamp(tc-ii,vec2(0.),res/3.)).rgb; 39 | ii.x=-ii.x; 40 | c+=texture2D(s,clamp(tc+ii,vec2(0.),res/3.)).rgb; 41 | c+=texture2D(s,clamp(tc-ii,vec2(0.),res/3.)).rgb; 42 | 43 | return c*.25; 44 | } 45 | 46 | vec4 filterCloud(sampler2D s,vec2 tc,float i,vec2 res, sampler2D d){ 47 | vec2 ii = (1.*i+.5)/res; 48 | const float treshhold = 1.; 49 | float a =1.; 50 | vec2 fc = fract(tc*2.); 51 | vec4 c = texture2D(s,tc); 52 | const float k = .75; 53 | 54 | if(min(min(fc.x,fc.y),1.-max(fc.x,fc.y))<.001*i) 55 | return c; 56 | if(treshhold<= texture2D(d,fract(2.*tc)).r ){ 57 | fc = 2.*tc-fc; 58 | float dp = float(treshhold<= texture2D(d,fract(2.*(tc+ii))).r)*float(floor(2.*(tc+ii))==fc)*k; 59 | c+=texture2D(s,tc+ii)*dp; 60 | a+=dp; 61 | dp = float(treshhold<= texture2D(d,fract(2.*(tc-ii))).r)*float(floor(2.*(tc-ii))==fc)*k; 62 | c+=texture2D(s,tc-ii)*dp; 63 | a+=dp; 64 | ii.x=-ii.x; 65 | dp = float(treshhold<= texture2D(d,fract(2.*(tc+ii))).r)*float(floor(2.*(tc+ii))==fc)*k; 66 | c+=texture2D(s,tc+ii)*dp; 67 | a+=dp; 68 | dp = float(treshhold<= texture2D(d,fract(2.*(tc-ii))).r)*float(floor(2.*(tc-ii))==fc)*k; 69 | c+=texture2D(s,tc-ii)*dp; 70 | a+=dp; 71 | } 72 | return c/a; 73 | } 74 | 75 | vec4 filterCloudSh(sampler2D s,vec2 tc,float i,vec2 res){ 76 | vec2 ii = (i+.5)/res; 77 | const float treshhold = .9; 78 | float a =0.; 79 | float dp = float(floor(2.*(tc+ii))==floor(2.*(tc))); 80 | vec4 c=texture2D(s,tc+ii)*dp; 81 | a+=dp; 82 | dp = float(floor(2.*(tc-ii))==floor(2.*(tc))); 83 | c+=texture2D(s,tc-ii)*dp; 84 | a+=dp; 85 | ii.x=-ii.x; 86 | dp = float(floor(2.*(tc+ii))==floor(2.*(tc))); 87 | c+=texture2D(s,tc+ii)*dp; 88 | a+=dp; 89 | dp = float(floor(2.*(tc-ii))==floor(2.*(tc))); 90 | c+=texture2D(s,tc-ii)*dp; 91 | a+=dp; 92 | if (a<1.) 93 | return texture2D(s,tc); 94 | return c/a; 95 | } 96 | -------------------------------------------------------------------------------- /shaders/world1/deferred3.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #include "../lib/trans.glsl" 3 | #include "../lib/essentials.glsl" 4 | 5 | 6 | uniform sampler2D gcolor; 7 | 8 | uniform sampler2D gdepth; 9 | uniform sampler2D gnormal; 10 | 11 | uniform sampler2D colortex7; 12 | uniform sampler2D colortex4; 13 | uniform sampler2D colortex3; 14 | 15 | uniform sampler2D depthtex1; 16 | uniform sampler2D shadowtex1; 17 | uniform sampler2D shadowtex0; 18 | uniform sampler2D shadowcolor0; 19 | uniform sampler2D shadowcolor1; 20 | uniform float frameTimeCounter; 21 | uniform int frameCounter; 22 | 23 | uniform int worldTime; 24 | 25 | 26 | varying vec2 tc; 27 | 28 | 29 | #define AO_SAMPLES 2 //[1 2 4 8 12 16] //samples per pixelper frame 30 | #define AO_RADIUS .45 //[.1 .15 .2 .25 .3 .35 .4 .45 .5 .55 .6 .65 .7 .75 .8 .85 .9 .95 1. 1.25 1.5 1.75 2. 3. ]radius in m*pixel/screenwidthh 31 | 32 | const float autorad = float(AO_RADIUS)*.715/sqrt(float(AO_SAMPLES+1)); //.715 is empirical 33 | 34 | 35 | #define AMBIENT_OCCLUSION 36 | 37 | #define GA 2.39996322973 38 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 39 | float dither = 0; 40 | 41 | #ifdef AMBIENT_OCCLUSION 42 | //#define COLORED_SHADOW 43 | 44 | float ssao(float pixdpth, vec3 n){ 45 | vec3 p =screen2view(vec3(tc,pixdpth)); 46 | 47 | float a = 0.; 48 | float seq = float(frameCounter)/17.; 49 | 50 | vec2 angle = vec2(0,autorad/(p.z)); 51 | angle*=rot(dither*6.28318530718+24*seq); 52 | float r = 1.+fract(dither+10*seq); 53 | for(int i = 0;i=1. ){ 87 | r=1.; 88 | 89 | col.rgb = vec3(.013,.005,.004); 90 | } 91 | float ao=r; 92 | //csh = 1.; 93 | if(pixdpth<1.){ 94 | #ifdef AMBIENT_OCCLUSION 95 | ao *= ssao(pixdpth,normal) ; 96 | #endif 97 | gl_FragData[2] = vec4(0.,0.,0.,1.); 98 | 99 | }else{ 100 | gl_FragData[2] = vec4(0,0,0,1.); 101 | } 102 | 103 | col.rgb*=.5; 104 | gl_FragData[0] = col; 105 | gl_FragData[1] = vec4(ao,0.,r,1); 106 | } 107 | -------------------------------------------------------------------------------- /shaders/world-1/deferred3.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #include "../lib/trans.glsl" 3 | #include "../lib/essentials.glsl" 4 | 5 | 6 | uniform sampler2D gcolor; 7 | 8 | uniform sampler2D gdepth; 9 | uniform sampler2D gnormal; 10 | 11 | uniform sampler2D colortex7; 12 | uniform sampler2D colortex4; 13 | uniform sampler2D colortex3; 14 | 15 | uniform sampler2D depthtex1; 16 | uniform sampler2D shadowtex1; 17 | uniform sampler2D shadowtex0; 18 | uniform sampler2D shadowcolor0; 19 | uniform sampler2D shadowcolor1; 20 | uniform float frameTimeCounter; 21 | uniform int frameCounter; 22 | 23 | uniform int worldTime; 24 | 25 | 26 | varying vec2 tc; 27 | 28 | 29 | #define AO_SAMPLES 2 //[1 2 4 8 12 16] //samples per pixelper frame 30 | #define AO_RADIUS .45 //[.1 .15 .2 .25 .3 .35 .4 .45 .5 .55 .6 .65 .7 .75 .8 .85 .9 .95 1. 1.25 1.5 1.75 2. 3. ]radius in m*pixel/screenwidthh 31 | 32 | const float autorad = float(AO_RADIUS)*.715/sqrt(float(AO_SAMPLES+1)); //.715 is empirical 33 | 34 | 35 | #define AMBIENT_OCCLUSION 36 | 37 | #define GA 2.39996322973 38 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 39 | float dither = 0; 40 | 41 | #ifdef AMBIENT_OCCLUSION 42 | //#define COLORED_SHADOW 43 | 44 | float ssao(float pixdpth, vec3 n){ 45 | vec3 p =screen2view(vec3(tc,pixdpth)); 46 | 47 | float a = 0.; 48 | float seq = float(frameCounter)/17.; 49 | 50 | vec2 angle = vec2(0,autorad/(p.z)); 51 | angle*=rot(dither*6.28318530718+24*seq); 52 | float r = 1.+fract(dither+10*seq); 53 | for(int i = 0;i=1. ){ 87 | r=1.; 88 | 89 | col.rgb = vec3(.013,.005,.004); 90 | } 91 | float ao=r; 92 | //csh = 1.; 93 | if(pixdpth<1.){ 94 | #ifdef AMBIENT_OCCLUSION 95 | ao *= ssao(pixdpth,normal) ; 96 | #endif 97 | gl_FragData[2] = vec4(0.,0.,0.,1.); 98 | 99 | }else{ 100 | gl_FragData[2] = vec4(0,0,0,1.); 101 | } 102 | 103 | col.rgb*=.5; 104 | gl_FragData[0] = col; 105 | gl_FragData[1] = vec4(ao,0.,r,1); 106 | } 107 | -------------------------------------------------------------------------------- /shaders/lib/essentials.glsl: -------------------------------------------------------------------------------- 1 | //matrices de bayer pour dithering uniforme 2 | 3 | //de 0 a 1-1/n² 4 | float bayer2(vec2 a){ 5 | a = floor(a); 6 | return fract( dot(a, vec2(.5, a.y * .75)) ); 7 | } 8 | #define bayer4(a) (bayer2( .5*(a))*.25+bayer2(a)) 9 | #define bayer8(a) (bayer4( .5*(a))*.25+bayer2(a)) 10 | #define bayer16(a) (bayer8( .5*(a))*.25+bayer2(a)) 11 | #define bayer32(a) (bayer16(.5*(a))*.25+bayer2(a)) 12 | #define bayer64(a) (bayer32(.5*(a))*.25+bayer2(a)) 13 | #define bayer128(a) (bayer64(.5*(a))*.25+bayer2(a)) 14 | 15 | //de -0.5+1/2n² a 0.5-1/2n² 16 | #define dither2(p) (bayer2( p)-.375 ) 17 | #define dither4(p) (bayer4( p)-.46875 ) 18 | #define dither8(p) (bayer8( p)-.4921875 ) 19 | #define dither16(p) (bayer16( p)-.498046875) 20 | #define dither32(p) (bayer32( p)-.499511719) 21 | #define dither64(p) (bayer64( p)-.49987793 ) 22 | #define dither128(p) (bayer128(p)-.499969482) 23 | 24 | //matrices rotation 25 | mat2 rot(float a){ 26 | float x,y; 27 | return mat2(x=cos(a),y=sin(a),-y,x); 28 | } 29 | 30 | //resolution 31 | uniform float viewWidth; 32 | uniform float viewHeight; 33 | #define resolution vec2(viewWidth,viewHeight) 34 | 35 | uniform float shadowWidth; 36 | 37 | float saturate(float x){ 38 | return clamp(x,0.,1.); 39 | } 40 | vec3 saturate3(vec3 x){ 41 | return clamp(x,vec3(0),vec3(1)); 42 | } 43 | //misc 44 | float minp(float a,float b){ 45 | return min(max(0.,a),max(0.,b)); 46 | } 47 | float boxmin(vec2 tc,sampler2D t){ 48 | float a = 0.; 49 | 50 | a=texture2D(t, tc).b; 51 | a=min(a,texture2D(t, tc+vec2(0,1.)/resolution).b); 52 | a=min(a,texture2D(t, tc+vec2(0,-1.)/resolution).b); 53 | a=min(a,texture2D(t, tc+vec2(1.,0)/resolution).b); 54 | a=min(a,texture2D(t, tc+vec2(-1.,0)/resolution).b); 55 | a=min(a,texture2D(t, tc+vec2(1.,1.)/resolution).b); 56 | a=min(a,texture2D(t, tc+vec2(-1.,1.)/resolution).b); 57 | a=min(a,texture2D(t, tc+vec2(1.,-1.)/resolution).b); 58 | a=min(a,texture2D(t, tc+vec2(-1.,-1.)/resolution).b); 59 | 60 | 61 | return a; 62 | } 63 | float boxmax(vec2 tc,sampler2D t){ 64 | float a = 0.; 65 | float k=1.; 66 | a=texture2D(t, tc).b; 67 | a=max(a,texture2D(t, tc+k*vec2(0,1.)/resolution).b); 68 | a=max(a,texture2D(t, tc+k*vec2(0,-1.)/resolution).b); 69 | a=max(a,texture2D(t, tc+k*vec2(1.,0)/resolution).b); 70 | a=max(a,texture2D(t, tc+k*vec2(-1.,0)/resolution).b); 71 | a=max(a,texture2D(t, tc+k*vec2(1.,1.)/resolution).b); 72 | a=max(a,texture2D(t, tc+k*vec2(-1.,1.)/resolution).b); 73 | a=max(a,texture2D(t, tc+k*vec2(1.,-1.)/resolution).b); 74 | a=max(a,texture2D(t, tc+k*vec2(-1.,-1.)/resolution).b); 75 | 76 | 77 | return a; 78 | } 79 | 80 | float haltonSeq(int b, int i) { 81 | i=int(mod(i,128)); 82 | float r = 0.; 83 | float f = 1.; 84 | while(i>0){ 85 | r += (f/=float(b))*float(mod(i,b)); 86 | i = i/b; 87 | } 88 | return r; 89 | } 90 | 91 | const float PI = 3.14159265359; 92 | const float TAU = 6.28318530718; 93 | -------------------------------------------------------------------------------- /shaders/lib/clouds.glsl: -------------------------------------------------------------------------------- 1 | #include "clouds.set" 2 | 3 | const int noiseTextureResolution = 256; 4 | 5 | float vnoise(vec2 a){ 6 | vec2 b = floor(a); 7 | a=fract(a); 8 | const float res = float(noiseTextureResolution); 9 | vec2 g1 = texture2D(noisetex,(b/res)).rg*2.-1.; 10 | vec2 g2 = texture2D(noisetex,((b+vec2(0,1))/res)).rg*2.-1.; 11 | vec2 g3 = texture2D(noisetex,((b+vec2(1,0))/res)).rg*2.-1.; 12 | vec2 g4 = texture2D(noisetex,((b+1.)/res)).rg*2.-1.; 13 | float d1 = dot(a,g1); 14 | float d2 = dot(a-vec2(0,1),g2); 15 | float d3 = dot(a-vec2(1,0),g3); 16 | float d4 = dot(a-1.,g4); 17 | 18 | a=smoothstep(0.,1.,a); 19 | float n = mix(mix(d1,d2,a.y),mix(d3,d4,a.y),a.x); 20 | return n+.5; 21 | } 22 | 23 | 24 | vec3 hash33c(vec3 p3){ 25 | p3 = mod(p3+50.3,100.6)-50.3; 26 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 27 | p3 += dot(p3, p3.yxz+19.19); 28 | return fract((p3.xxy + p3.yxx)*p3.zyx)-.5; 29 | } 30 | 31 | vec3 dephash(vec3 p){ 32 | return p+hash33c(p); 33 | } 34 | 35 | float worley(vec3 p){ 36 | p+=worldtime*vec3(.1,.02,.3)*.005; 37 | vec3 P =floor(p); 38 | vec3 p0 = dephash(P) 39 | ,p1= dephash(P+vec3(0,0,1)) 40 | ,p2= dephash(P+vec3(0,1,0)) 41 | ,p3= dephash(P+vec3(0,1,1)) 42 | ,p4= dephash(P+vec3(1,0,0)) 43 | ,p5= dephash(P+vec3(1,0,1)) 44 | ,p6= dephash(P+vec3(1,1,0)) 45 | ,p7= dephash(P+vec3(1,1,1)); 46 | float d0 = distance(p,p0), 47 | d1 = distance(p,p1), 48 | d2 = distance(p,p2), 49 | d3 = distance(p,p3), 50 | d4 = distance(p,p4), 51 | d5 = distance(p,p5), 52 | d6 = distance(p,p6), 53 | d7 = distance(p,p7); 54 | float md = min(min(min(d0,d1),min(d2,d3)),min(min(d4,d5),min(d6,d7))); 55 | return 1.-(md)*2.3; 56 | } 57 | 58 | 59 | float fbm(vec3 p){ 60 | float n = worley((p*=4.1*CLOUD_SCALE)); 61 | n=(1.+n*med)*worley(n*turb+(p/=4.1)); 62 | #if(CLOUD_DETAILS>1) 63 | n+=smol*worley(p*=-vec3(15.1,19.5,14.3)); 64 | #if(CLOUD_DETAILS>2) 65 | n+=mini*worley(p*=-vec3(4.1,2.5,4.3)); 66 | #endif 67 | #endif 68 | // n=1.-((hash33c(p).r*.1+.9)*(1.-n)); 69 | return n*2.; 70 | } 71 | float fbm2(vec3 p){ 72 | float n = worley((p*=4.1*CLOUD_SCALE)); 73 | n=(1.+n*med)*worley(n*turb+(p/=4.1)); 74 | #if(CLOUD_LIGHTING_DETAILS>1) 75 | n+=smol*worley(p*=-vec3(15.1,19.5,14.3)); 76 | #if(CLOUD_LIGHTING_DETAILS>2) 77 | n+=mini*worley(p*=-vec3(4.1,2.5,4.3)); 78 | #endif 79 | #endif 80 | // n=1.-((hash33c(p).r*.1+.9)*(1.-n)); 81 | return n*2.; 82 | } 83 | 84 | float clf(vec3 p, float c){ 85 | float lowbound = smoothstep(cloud_min_plane,cloud_low,p.y),highbound = smoothstep(cloud_top_plane,cloud_high,p.y); 86 | highbound=sqrt(highbound); 87 | c*= lowbound*highbound 88 | *max(smoothstep(0.6,0.3,vnoise(0.00001*(p.xz-vec2(worldtime)*5.))),max(rainStrength,wetness)); 89 | return smoothstep(.1,.3,c+.7*max(rainStrength,wetness*wetness*wetness*wetness)); 90 | } 91 | 92 | 93 | float cloods( vec3 p){ 94 | float c=fbm(.02*p*vec3(.1,.15,.2)); 95 | return clf( p, c); 96 | } 97 | float cloods2( vec3 p){ 98 | float c= fbm2(.02*p*vec3(.1,.15,.2)); 99 | return clf( p, c); 100 | } 101 | -------------------------------------------------------------------------------- /shaders/world-1/gbuffers_terrain.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #extension GL_ARB_shader_texture_lod : enable 3 | #extension GL_ARB_gpu_shader4 : enable 4 | 5 | #define NORMAL_MAPPING 6 | #define POM 7 | //#define DIRECTIONAL_LIGHTMAPS //super broken, not recommended 8 | //#define AO_FIX 9 | 10 | #include "/common/pbrformats" 11 | 12 | 13 | uniform sampler2D texture; 14 | uniform sampler2D normals; 15 | #if PBR_FORMAT 16 | uniform sampler2D specular; 17 | #endif 18 | uniform sampler2D noisetex; 19 | #include "/lib/colorspace.glsl" 20 | #include "/lib/trans.glsl" 21 | #include "/lib/essentials.glsl" 22 | 23 | varying vec3 normal; 24 | varying vec4 texcoord; 25 | varying vec4 tintColor; 26 | varying vec4 lmcoord; 27 | varying mat3 tbn; 28 | varying vec3 vpos; 29 | varying vec2 midTexCoord; 30 | uniform vec3 shadowLightPosition; 31 | uniform float frameTimeCounter; 32 | uniform int frameCounter; 33 | varying vec3 wpos; 34 | 35 | const int noiseTextureResolution = 256; 36 | 37 | varying vec2 texres; 38 | #define tt texres // vec2(max(texres.x,texres.y)) 39 | 40 | float dither = bayer16(gl_FragCoord.xy); 41 | 42 | 43 | 44 | vec2 dcdx = dFdx(texcoord.rg); 45 | vec2 dcdy = dFdy(texcoord.rg); 46 | 47 | vec4 gettex(sampler2D t, vec2 v) 48 | { 49 | v =(v-midTexCoord)/texres+.5; 50 | v=(fract(v)-.5)*texres+midTexCoord; 51 | return texture2DGradARB(t,v,dcdx,dcdy); 52 | 53 | } 54 | 55 | 56 | 57 | #define POM_DEPTH .25 // [.025 .05 .1 .2 .25 .3 .4 .5 .6 .7 .75 .8 .9 1.] 58 | #define POM_STEPS 64 //[4 8 16 32 64 128 256] 59 | vec2 parallaxpos(vec2 uv,vec3 rd) 60 | { 61 | float dpth = POM_DEPTH; 62 | float ste =dpth/(POM_STEPS+1); 63 | float height = dpth*gettex(normals,uv).w; 64 | vec3 pc = vec3(uv,0.); 65 | vec3 rstep = -ste*vec3(tt,1.)*rd/rd.z; 66 | pc+=rstep*fract(dither+haltonSeq(13,frameCounter)); 67 | for(int i =0;i= height-dpth;i++) 68 | { 69 | if(gettex(texture,pc.xy).w==0.) 70 | break; 71 | pc+=rstep; 72 | height =dpth*gettex(normals,pc.xy).w;//*(sin(frameTimeCounter)*.5+.5); 73 | } 74 | //pc.xy -= rstep.xy*(height-pc.z)*ste; 75 | return pc.xy; 76 | } 77 | 78 | 79 | /*DRAWBUFFERS:03271*/ 80 | void main() 81 | { 82 | #ifdef POM 83 | vec2 uv = parallaxpos(texcoord.st,vpos*tbn); 84 | #else 85 | vec2 uv = texcoord.st; 86 | #endif 87 | vec2 lm = lmcoord.xy/256.; 88 | mat2 dlm = mat2(dFdx(lm.x),-dFdy(lm.x),dFdx(lm.y),-dFdy(lm.y)); 89 | vec3 blocklightdir = normalize(vec3(dlm[0],2.*length(dlm[0])*(lm.x))); 90 | #if PBR_FORMAT 91 | vec4 PBRdata =gettex(specular,uv); 92 | #else 93 | vec4 PBRdata = vec4(0); 94 | #endif 95 | #if PBR_FORMAT == labPBRv1_3 96 | PBRdata.g = sqrt(PBRdata.g); 97 | #endif 98 | gl_FragData[0]=gettex(texture,uv)*tintColor; 99 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb);//*step(abs(texres.x-texres.y),.0001);//*0.+blocklightdir; 100 | 101 | gl_FragData[4]=vec4(1); 102 | vec3 n = normal, nrml=normal; 103 | float ao=1.; 104 | #ifdef NORMAL_MAPPING 105 | #include "/lib/normals.glsl" 106 | 107 | #ifdef DIRECTIONAL_LIGHTMAPS 108 | float rgh = pow(1.-PBRdata.r,2.); 109 | lm.x=min(blocklightdir.z>.0?diffuse(vpos,blocklightdir,n*tbn,rgh)*(parallaxshadow(uv,blocklightdir)*.75+.25):1.,lm.x); 110 | //lm.y*=skylightdir.z>.01?max(0.1,dot(n*tbn,skylightdir))*parallaxshadow(uv,skylightdir):1.; 111 | #endif 112 | gl_FragData[4].r=(ao); 113 | //gl_FragData[0].rgb = vec3(ao*ao); 114 | 115 | 116 | #endif 117 | gl_FragData[2]=vec4(.5+.5*n,1.); 118 | 119 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 120 | 121 | gl_FragData[1]=vec4(PBRdata.rgb,1); 122 | } 123 | -------------------------------------------------------------------------------- /shaders/world1/gbuffers_terrain.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #extension GL_ARB_shader_texture_lod : enable 3 | #extension GL_ARB_gpu_shader4 : enable 4 | 5 | #define NORMAL_MAPPING 6 | #define POM 7 | //#define DIRECTIONAL_LIGHTMAPS //super broken, not recommended 8 | //#define AO_FIX 9 | 10 | #include "/common/pbrformats" 11 | 12 | 13 | uniform sampler2D texture; 14 | uniform sampler2D normals; 15 | #if PBR_FORMAT 16 | uniform sampler2D specular; 17 | #endif 18 | uniform sampler2D noisetex; 19 | #include "/lib/colorspace.glsl" 20 | #include "/lib/trans.glsl" 21 | #include "/lib/essentials.glsl" 22 | 23 | varying vec3 normal; 24 | varying vec4 texcoord; 25 | varying vec4 tintColor; 26 | varying vec4 lmcoord; 27 | varying mat3 tbn; 28 | varying vec3 vpos; 29 | varying vec2 midTexCoord; 30 | uniform vec3 shadowLightPosition; 31 | uniform float frameTimeCounter; 32 | uniform int frameCounter; 33 | varying vec3 wpos; 34 | 35 | const int noiseTextureResolution = 256; 36 | 37 | varying vec2 texres; 38 | #define tt texres // vec2(max(texres.x,texres.y)) 39 | 40 | float dither = bayer16(gl_FragCoord.xy); 41 | 42 | 43 | 44 | vec2 dcdx = dFdx(texcoord.rg); 45 | vec2 dcdy = dFdy(texcoord.rg); 46 | 47 | vec4 gettex(sampler2D t, vec2 v) 48 | { 49 | v =(v-midTexCoord)/texres+.5; 50 | v=(fract(v)-.5)*texres+midTexCoord; 51 | return texture2DGradARB(t,v,dcdx,dcdy); 52 | 53 | } 54 | 55 | 56 | 57 | #define POM_DEPTH .25 // [.025 .05 .1 .2 .25 .3 .4 .5 .6 .7 .75 .8 .9 1.] 58 | #define POM_STEPS 64 //[4 8 16 32 64 128 256] 59 | vec2 parallaxpos(vec2 uv,vec3 rd) 60 | { 61 | float dpth = POM_DEPTH; 62 | float ste =dpth/(POM_STEPS+1); 63 | float height = dpth*gettex(normals,uv).w; 64 | vec3 pc = vec3(uv,0.); 65 | vec3 rstep = -ste*vec3(tt,1.)*rd/rd.z; 66 | pc+=rstep*fract(dither+haltonSeq(13,frameCounter)); 67 | for(int i =0;i= height-dpth;i++) 68 | { 69 | if(gettex(texture,pc.xy).w==0.) 70 | break; 71 | pc+=rstep; 72 | height =dpth*gettex(normals,pc.xy).w;//*(sin(frameTimeCounter)*.5+.5); 73 | } 74 | //pc.xy -= rstep.xy*(height-pc.z)*ste; 75 | return pc.xy; 76 | } 77 | 78 | 79 | /*DRAWBUFFERS:03271*/ 80 | void main() 81 | { 82 | #ifdef POM 83 | vec2 uv = parallaxpos(texcoord.st,vpos*tbn); 84 | #else 85 | vec2 uv = texcoord.st; 86 | #endif 87 | vec2 lm = lmcoord.xy/256.; 88 | mat2 dlm = mat2(dFdx(lm.x),-dFdy(lm.x),dFdx(lm.y),-dFdy(lm.y)); 89 | vec3 blocklightdir = normalize(vec3(dlm[0],2.*length(dlm[0])*(lm.x))); 90 | #if PBR_FORMAT 91 | vec4 PBRdata =gettex(specular,uv); 92 | #else 93 | vec4 PBRdata = vec4(0); 94 | #endif 95 | #if PBR_FORMAT == labPBRv1_3 96 | PBRdata.g = sqrt(PBRdata.g); 97 | #endif 98 | 99 | gl_FragData[0]=gettex(texture,uv)*tintColor; 100 | gl_FragData[0].rgb= srgbToLinear(gl_FragData[0].rgb);//*step(abs(texres.x-texres.y),.0001);//*0.+blocklightdir; 101 | 102 | gl_FragData[4]=vec4(1); 103 | vec3 n = normal, nrml=normal; 104 | float ao=1.; 105 | #ifdef NORMAL_MAPPING 106 | #include "/lib/normals.glsl" 107 | 108 | #ifdef DIRECTIONAL_LIGHTMAPS 109 | float rgh = pow(1.-PBRdata.r,2.); 110 | lm.x=min(blocklightdir.z>.0?diffuse(vpos,blocklightdir,n*tbn,rgh)*(parallaxshadow(uv,blocklightdir)*.75+.25):1.,lm.x); 111 | //lm.y*=skylightdir.z>.01?max(0.1,dot(n*tbn,skylightdir))*parallaxshadow(uv,skylightdir):1.; 112 | #endif 113 | gl_FragData[4].r=(ao); 114 | //gl_FragData[0].rgb = vec3(ao*ao); 115 | 116 | 117 | #endif 118 | gl_FragData[2]=vec4(.5+.5*n,1.); 119 | 120 | gl_FragData[3]=vec4(lm,PBRdata.a<1.?PBRdata.a:0.,1.); 121 | 122 | gl_FragData[1]=vec4(PBRdata.rgb,1); 123 | } 124 | -------------------------------------------------------------------------------- /shaders/shaders.properties: -------------------------------------------------------------------------------- 1 | oldLighting=false 2 | underwaterOverlay = false 3 | sun=false 4 | moon=false 5 | stars=false 6 | vignette=false 7 | clouds=off 8 | 9 | beacon.beam.depth=true 10 | 11 | blend.gbuffers_water=SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE 12 | 13 | alphaTest.gbuffers_water=off 14 | rain.depth=true 15 | beacon.beam.depth=true 16 | 17 | texture.composite.colortex5=/img/Luts.png 18 | 19 | screen.columns=2 20 | screen= [CAMERA] [LIGHING] [WATER] [SKY] [SURFACE] [VOLUMES] [POST] [BUGGED] 21 | 22 | screen.CAMERA.columns=2 23 | screen.CAMERA= [DOF] TONEMAP BLOOM BLOOM_STRENGTH AUTO_EXPOSURE EXPOSURE_SPEED EXPOSURE_MULTIPLIER MAX_EXPOSURE 24 | screen.DOF.columns=2 25 | screen.DOF=DOF BETTER_DOF TEMPORAL_DOF DOF_IT DOF_APERTURE DOF_FOCAL DOF_CLOSEST ANISOTROPIC_DOF ANISOTROPIC_DOF_DEFORMATION 26 | 27 | screen.LIGHING.columns=2 28 | screen.LIGHING= [SHADOWS] [AMBIENT] [GI] TEMPORAL_LIGHT_ACCUMULATION OREN_NAYAR_DIFFUSE 29 | screen.SHADOWS.columns=2 30 | screen.SHADOWS= PCSS PCSS_STRENGTH PCSS_SAMPLES PCSS_ACCURACY SHADOW_BIAS shadowMapResolution shadowDistance 31 | screen.AMBIENT.columns=2 32 | screen.AMBIENT= AMBIENT_OCCLUSION AO_SAMPLES AO_RADIUS 33 | screen.GI.columns=2 34 | screen.GI= GLOBAL_ILLUMINATION GI_SAMPLES GI_HQ_FILTER GI_DITHER_SCALE RSM_DIST 35 | 36 | screen.WATER.columns=2 37 | screen.WATER=WATER_TEXTURE WATER_PARALLAX WATER_PARALLAX_PRECISION WATER_HEIGHT WAVE_NOISE_OCTAVES VOLUMETRIC_WATER WATER_THICCNESS WATER_ABSORB WATER_VOL_STEPS PILLAR_WATER 38 | 39 | screen.SKY.columns=2 40 | screen.SKY=SUN_BRIGHNESS MOON_BRIGHNESS [CLOUDS] 41 | 42 | screen.SURFACE.columns=2 43 | screen.SURFACE= [REFLECTIONS] [NORMALS_PARALLAX] [REFRACTIONS] [RESSOUCE_PACK_FORMAT] 44 | screen.REFLECTIONS.columns=2 45 | screen.REFLECTIONS= SSR SHADOW_SPACE_REFLECTION SSR_STEPS SHSR_STEPS SSR_FILTER CLOUD_REF_FILTER SSR_MIN_PREC SHSR_PREC SSR_REJECTION SHSR_PREC_BIAS 46 | screen.NORMALS_PARALLAX.columns=2 47 | screen.NORMALS_PARALLAX= NORMAL_MAPPING [PARALLAX] SELF_SHADOW RSM_NORMAL_MAPPING 48 | screen.PARALLAX.columns=2 49 | screen.PARALLAX= POM POM_DEPTH POM_STEPS PARALLAX_ALTER_DEPTHMAP 50 | screen.REFRACTIONS.columns=2 51 | screen.REFRACTIONS= FAKE_REFRACTION REFRACT_ALL_TRANSPARENTS 52 | screen.RESSOUCE_PACK_FORMAT= PBR_FORMAT EMMISIVE_MAP USE_METALS FORCE_SSS 53 | 54 | screen.VOLUMES.columns=2 55 | screen.VOLUMES= [CLOUDS] VOLUMETRIC_LIGHT VOL_STEPS FOG_DETAIL VOLUMETRIC_WATER WATER_VOL_STEPS VOLUME_PCSS 56 | screen.CLOUDS.columns=2 57 | screen.CLOUDS= CLOUD_RAYTRACING_QUALITY CLOUD_DETAILS CLOUD_LIGHTING_QUALITY CLOUD_LIGHTING_DETAILS CLOUD_SHADOW_QUALITY CLOUD_VL_QUALITY CLOUD_REF_FILTER CLOUD_SCALE 58 | 59 | screen.POST.columns=2 60 | screen.POST=SHARPENING SATURATION CONTRAST LUT LUT_TABLE LUT_SPACE TAA_STRENGTH 61 | 62 | screen.BUGGED=* PILLAR_WATER 63 | 64 | sliders=EXPOSURE_MULTIPLIER EXPOSURE_SPEED MAX_EXPOSURE BLOOM_STRENGTH shadowDistance TAA_STRENGTH CLOUD_SCALE POM_STEPS ANISOTROPIC_DOF_DEFORMATION EXPOSURE_MULTIPLIER DOF_APERTURE DOF_FOCAL DOF_CLOSEST PCSS_STRENGTH AO_RADIUS WATER_PARALLAX_PRECISION WATER_HEIGHT WATER_THICCNESS SUN_BRIGHNESS MOON_BRIGHNESS SSR_MIN_PREC CONTRAST SATURATION SHARPENING CLOUD_RAYTRACING_QUALITY CLOUD_LIGHTING_QUALITY CLOUD_VL_QUALITY CLOUD_SHADOW_QUALITY SHSR_PREC 65 | -------------------------------------------------------------------------------- /shaders/world-1/composite7.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex0; 7 | uniform sampler2D depthtex1; 8 | uniform sampler2D depthtex0; 9 | uniform float centerDepthSmooth; 10 | 11 | //#define DOF 12 | #define BETTER_DOF 13 | //#define TEMPORAL_DOF //increases the demporal resolution of DOF, but loks jittery 14 | 15 | #ifdef TEMPORAL_DOF 16 | uniform float frameTimeCounter; 17 | #endif 18 | 19 | 20 | #define DOF_APERTURE 0.1 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]//radius in m*pixel/screenwidthh 21 | #define DOF_IT 4 //[1 2 4 8 16 32 64 128] 22 | #define DOF_FOCAL 0.0257 //[0.0001 0.0002 0.0005 0.001 0.0017 0.0026 0.0037 0.005 0.0065 0.0082 0.0101 0.0122 0.0145 0.017 0.0197 0.0226 0.0257 0.029 0.0325 0.0362 0.0401 0.0442 0.0485 0.05299 0.05769 0.06259 0.06769 0.07299 0.07849 0.08419 0.09009 0.09619 0.10249 0.10899 0.11569 0.12259 0.12969 0.13699 0.14449 0.15218 0.16008 0.16818 0.17648 0.18498 0.19368 0.20258 0.21168 0.22098 0.23048 0.24018 0.25007 0.26017 0.27047 0.28097 0.29167 0.30257 0.31367 0.32497 0.33647 0.34817 0.36006 0.37216 0.38446 0.39696 0.40966 0.42256 0.43566 0.44896 0.46245 0.47615 0.49005 0.50415 0.51845 0.53295 0.54765 0.56254 0.57764 0.59294 0.60844 0.62414 0.64004 0.65613 0.67243 0.68893 0.70563 0.72253 0.73963 0.75692 0.77442 0.79212 0.81002 0.82812 0.84642 0.86491 0.88361 0.90251 0.92161 0.94091 0.9604 0.9801 1.0] 23 | #define DOF_CLOSEST 0.125 //[0.0 0.025 0.05 0.075 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.425 0.45 0.475 0.5 0.525 0.55 0.575 0.6 0.625 0.65 0.675 0.7 0.725 0.75 0.775 0.8 0.825 0.85 0.875 0.9 0.925 0.95 0.975 1.0] 24 | 25 | #ifdef DOF 26 | #include "../lib/essentials.glsl" 27 | #include "../lib/trans.glsl" 28 | #define GA 2.39996322973 29 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 30 | 31 | const float autorad = .715/sqrt(float(DOF_IT+1)); //.715 is empirical 32 | const float centerDepthHalflife =2.0f; 33 | 34 | float getCoC(float depth, float focalDepth){ 35 | return float(DOF_APERTURE)*DOF_FOCAL*abs(depth-focalDepth)/(depth*(focalDepth - DOF_FOCAL)); 36 | } 37 | 38 | vec3 getDOF(vec2 tc, float depth,float Coc,float focalDepth){ 39 | vec3 c=vec3(0); 40 | float d = bayer16(gl_FragCoord.xy); 41 | #ifdef TEMPORAL_DOF 42 | d=fract(d+frameTimeCounter*240.1); 43 | #endif 44 | float delta = depth-focalDepth; 45 | float rad = Coc*autorad; 46 | vec2 angle = vec2(0,rad); 47 | angle*=rot(6.28*d); 48 | float r = 1.; 49 | float j=0.; 50 | vec2 corr = resolution.x/resolution; 51 | for(int i = 0;i=sqrt(DOF_IT)/min(viewWidth,viewHeight); 83 | bool filter1 = Coc>=sqrt(DOF_IT)*3./min(viewWidth,viewHeight); 84 | gl_FragData[1]=vec4(filter,filter1,0,1.); 85 | #else 86 | vec3 c = texture2D(colortex0,tc).rgb; 87 | gl_FragData[1]=vec4(0,0,0,1.); 88 | #endif 89 | 90 | gl_FragData[0]=vec4(c,1.); 91 | //gl_FragData[1]=vec4(kawazePass(colortex0,tc,1.,resolution),1.); 92 | 93 | } 94 | -------------------------------------------------------------------------------- /shaders/world1/composite7.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | 4 | 5 | varying vec2 tc; 6 | uniform sampler2D colortex0; 7 | uniform sampler2D depthtex1; 8 | uniform sampler2D depthtex0; 9 | uniform float centerDepthSmooth; 10 | 11 | //#define DOF 12 | #define BETTER_DOF 13 | //#define TEMPORAL_DOF //increases the demporal resolution of DOF, but loks jittery 14 | 15 | #ifdef TEMPORAL_DOF 16 | uniform float frameTimeCounter; 17 | #endif 18 | 19 | 20 | #define DOF_APERTURE 0.1 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]//radius in m*pixel/screenwidthh 21 | #define DOF_IT 4 //[1 2 4 8 16 32 64 128] 22 | #define DOF_FOCAL 0.0257 //[0.0001 0.0002 0.0005 0.001 0.0017 0.0026 0.0037 0.005 0.0065 0.0082 0.0101 0.0122 0.0145 0.017 0.0197 0.0226 0.0257 0.029 0.0325 0.0362 0.0401 0.0442 0.0485 0.05299 0.05769 0.06259 0.06769 0.07299 0.07849 0.08419 0.09009 0.09619 0.10249 0.10899 0.11569 0.12259 0.12969 0.13699 0.14449 0.15218 0.16008 0.16818 0.17648 0.18498 0.19368 0.20258 0.21168 0.22098 0.23048 0.24018 0.25007 0.26017 0.27047 0.28097 0.29167 0.30257 0.31367 0.32497 0.33647 0.34817 0.36006 0.37216 0.38446 0.39696 0.40966 0.42256 0.43566 0.44896 0.46245 0.47615 0.49005 0.50415 0.51845 0.53295 0.54765 0.56254 0.57764 0.59294 0.60844 0.62414 0.64004 0.65613 0.67243 0.68893 0.70563 0.72253 0.73963 0.75692 0.77442 0.79212 0.81002 0.82812 0.84642 0.86491 0.88361 0.90251 0.92161 0.94091 0.9604 0.9801 1.0] 23 | #define DOF_CLOSEST 0.125 //[0.0 0.025 0.05 0.075 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.425 0.45 0.475 0.5 0.525 0.55 0.575 0.6 0.625 0.65 0.675 0.7 0.725 0.75 0.775 0.8 0.825 0.85 0.875 0.9 0.925 0.95 0.975 1.0] 24 | 25 | #ifdef DOF 26 | #include "../lib/essentials.glsl" 27 | #include "../lib/trans.glsl" 28 | #define GA 2.39996322973 29 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 30 | 31 | const float autorad = .715/sqrt(float(DOF_IT+1)); //.715 is empirical 32 | const float centerDepthHalflife =2.0f; 33 | 34 | float getCoC(float depth, float focalDepth){ 35 | return float(DOF_APERTURE)*DOF_FOCAL*abs(depth-focalDepth)/(depth*(focalDepth - DOF_FOCAL)); 36 | } 37 | 38 | vec3 getDOF(vec2 tc, float depth,float Coc,float focalDepth){ 39 | vec3 c=vec3(0); 40 | float d = bayer16(gl_FragCoord.xy); 41 | #ifdef TEMPORAL_DOF 42 | d=fract(d+frameTimeCounter*240.1); 43 | #endif 44 | float delta = depth-focalDepth; 45 | float rad = Coc*autorad; 46 | vec2 angle = vec2(0,rad); 47 | angle*=rot(6.28*d); 48 | float r = 1.; 49 | float j=0.; 50 | vec2 corr = resolution.x/resolution; 51 | for(int i = 0;i=sqrt(DOF_IT)/min(viewWidth,viewHeight); 83 | bool filter1 = Coc>=sqrt(DOF_IT)*3./min(viewWidth,viewHeight); 84 | gl_FragData[1]=vec4(filter,filter1,0,1.); 85 | #else 86 | vec3 c = texture2D(colortex0,tc).rgb; 87 | gl_FragData[1]=vec4(0,0,0,1.); 88 | #endif 89 | 90 | gl_FragData[0]=vec4(c,1.); 91 | //gl_FragData[1]=vec4(kawazePass(colortex0,tc,1.,resolution),1.); 92 | 93 | } 94 | -------------------------------------------------------------------------------- /shaders/world-1/composite5.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "../lib/essentials.glsl" 3 | #include "../lib/shadowtransform.glsl" 4 | #include "../lib/trans.glsl" 5 | 6 | uniform vec3 shadowLightPosition; 7 | 8 | 9 | 10 | float dither; 11 | 12 | varying vec2 tc; 13 | uniform sampler2D colortex1; 14 | uniform sampler2D depthtex1; 15 | uniform sampler2D depthtex0; 16 | uniform sampler2D colortex0; 17 | uniform sampler2D colortex2; 18 | uniform float frameTimeCounter; 19 | uniform sampler2D shadowtex0; 20 | uniform sampler2D shadowtex1; 21 | 22 | 23 | uniform sampler2D noisetex; 24 | 25 | uniform int frameCounter; 26 | uniform int isEyeInWater; 27 | 28 | uniform float wetness; 29 | uniform float rainStrength; 30 | 31 | 32 | 33 | uniform int worldTime; 34 | 35 | 36 | #include "/lib/lmcol.glsl" 37 | 38 | 39 | #define GA 2.39996322973 40 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 41 | 42 | 43 | 44 | 45 | vec3 hash33c(vec3 p3){ 46 | p3 = mod(p3+50.3,100.6)-50.3; 47 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 48 | p3 += dot(p3, p3.yxz+19.19); 49 | return fract((p3.xxy + p3.yxx)*p3.zyx)-.5; 50 | } 51 | 52 | vec3 dephash(vec3 p){ 53 | return p+hash33c(p); 54 | } 55 | 56 | float worley(vec3 p){ 57 | vec3 P =floor(p); 58 | vec3 p0 = dephash(P) 59 | ,p1= dephash(P+vec3(0,0,1)) 60 | ,p2= dephash(P+vec3(0,1,0)) 61 | ,p3= dephash(P+vec3(0,1,1)) 62 | ,p4= dephash(P+vec3(1,0,0)) 63 | ,p5= dephash(P+vec3(1,0,1)) 64 | ,p6= dephash(P+vec3(1,1,0)) 65 | ,p7= dephash(P+vec3(1,1,1)); 66 | float d0 = distance(p,p0), 67 | d1 = distance(p,p1), 68 | d2 = distance(p,p2), 69 | d3 = distance(p,p3), 70 | d4 = distance(p,p4), 71 | d5 = distance(p,p5), 72 | d6 = distance(p,p6), 73 | d7 = distance(p,p7); 74 | float md = min(min(min(d0,d1),min(d2,d3)),min(min(d4,d5),min(d6,d7))); 75 | return 1.-(md)*2.3; 76 | } 77 | 78 | float hash13(vec3 p3){ 79 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 80 | p3 += dot(p3, p3.yxz+19.19); 81 | return fract(dot(p3,vec3(1))); 82 | 83 | } 84 | 85 | 86 | #define VOL_STEPS 8 //[2 4 8 16 32] 87 | #define VOLUMETRIC_LIGHT 88 | 89 | #ifdef VOLUMETRIC_LIGHT 90 | vec3 volumeLight(vec3 c,vec3 rd){ 91 | 92 | //vec3 rd = screen2cam(p1); 93 | vec3 p = gbufferModelViewInverse[3].xyz; 94 | vec3 st = (rd-p)/float(VOL_STEPS); 95 | vec3 shade =vec3(0.); 96 | 97 | p+=st*fract(dither); 98 | float stlen = length(st); 99 | 100 | 101 | vec3 fogColor = vec3(.013,.005,.004); 102 | 103 | 104 | vec3 lc = vec3(.3,.1,.1); 105 | 106 | float m = 1.; 107 | vec3 trans = vec3(0); 108 | 109 | for(int i=0;i=sqrt(DOF_IT)/min(viewWidth,viewHeight); 92 | bool filter1 = Coc>=sqrt(DOF_IT)*3./min(viewWidth,viewHeight); 93 | gl_FragData[1]=vec4(filter,filter1,0,1.); 94 | #else 95 | vec3 c = texture2D(colortex0,tc).rgb; 96 | gl_FragData[1]=vec4(0,0,0,1.); 97 | #endif 98 | 99 | gl_FragData[0]=vec4(c,1.); 100 | //gl_FragData[1]=vec4(kawazePass(colortex0,tc,1.,resolution),1.); 101 | 102 | } 103 | -------------------------------------------------------------------------------- /shaders/deferred5.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | const bool colortex5Clear = false; 4 | 5 | #include "lib/trans.glsl" 6 | #include "lib/essentials.glsl" 7 | #include "lib/temp.glsl" 8 | 9 | uniform sampler2D colortex0; 10 | uniform sampler2D gnormal; 11 | uniform sampler2D colortex1; 12 | uniform sampler2D depthtex1; 13 | uniform sampler2D depthtex2; 14 | uniform sampler2D colortex7; 15 | uniform sampler2D colortex4; 16 | uniform sampler2D colortex5; 17 | 18 | uniform int worldTime; 19 | uniform vec3 skyColor; 20 | uniform float rainStrength; 21 | 22 | 23 | #define TEMPORAL_LIGHT_ACCUMULATION 24 | #define GLOBAL_ILLUMINATION 25 | //#define GI_HQ_FILTER 26 | #define GI_DITHER_SCALE 1 //[1 2 3 4 5 6 7 8] 27 | #ifdef GI_HQ_FILTER 28 | #define filtersize 2 29 | #else 30 | #define filtersize 1 31 | #endif 32 | 33 | uniform int frameCounter; 34 | 35 | varying vec2 tc; 36 | 37 | 38 | 39 | 40 | #ifdef GLOBAL_ILLUMINATION 41 | vec3 filt(vec2 tc, sampler2D s){ 42 | return texture2D(s,tc ).rgb; 43 | vec3 a = vec3(0); 44 | float b =0.; 45 | float dp =depthLin(texture2D(depthtex1,tc).r); 46 | for(int i =-1;i<1;i++){ 47 | for(int j =-1;j<1;j++){ 48 | float si = 3.-float(i+j+i*j); 49 | vec2 sc = tc+2.5*vec2(i,j)/resolution; 50 | if(abs(depthLin(texture2D(depthtex1,sc).r)-dp)<.001){ 51 | a+=si*texture2D(s,sc ).rgb; 52 | b+=si; 53 | } 54 | } 55 | } 56 | return a/b; 57 | } 58 | #endif 59 | 60 | #include "lib/lmcol.glsl" 61 | 62 | 63 | float hash(float seed) { 64 | return fract(sin(seed)*43758.5453123); 65 | } 66 | /*DRAWBUFFERS:154*/ 67 | void main() { 68 | #include "lib/thunder.glsl" 69 | 70 | vec2 lmcoord=texture2D(colortex7,tc).rg; 71 | 72 | 73 | lmcoord*=lmcoord; 74 | 75 | vec3 naosh = texture2D(colortex1, tc).rgb; 76 | float ao =naosh.x; 77 | vec3 boltc = bolt*ao*lmcoord.y*vec3(.1,.01,.4); 78 | #include "lib/ambcol.glsl" 79 | ao*=.05+lmcoord.y*ambi; 80 | vec3 newgi = ambientCol*ao+boltc; 81 | 82 | 83 | const float kernel[6] = float[](9./64., 3./32., 3./128., 1./64., 1./16., 1./256.); 84 | vec3 sum = vec3(0); 85 | float cum_w = 0.0; 86 | float c_phi = 1.0; 87 | float r_phi = 1.0; 88 | float n_phi = 0.5; 89 | float p_phi = 0.25; 90 | #ifdef GLOBAL_ILLUMINATION 91 | 92 | vec3 cval = texture2D(colortex4, tc).xyz; 93 | vec3 nval = texture2D(gnormal, tc).xyz; 94 | 95 | float ang = 2.0*3.1415926535*hash(2510.12860182*tc.x + 7290.9126812*tc.y+5.1839513*frameCounter); 96 | mat2 m = mat2(cos(ang),sin(ang),-sin(ang),cos(ang)); 97 | float denoiseStrength = GI_DITHER_SCALE*(2. + 3.*hash(6410.128752*tc.x + 3120.321374*tc.y+1.92357812*frameCounter)); 98 | for(int i=-filtersize; i.01){ 84 | #ifdef SSR 85 | vec3 d = normalize(view2screen(screen2view(p)+rd)-p); 86 | float iter = float(ITER+1); 87 | vec3 toBord = (step(0,d)-p)/(d*iter); //distances to borders divided by the number of steps 88 | float limstep =max(min(1./iter,SSR_MIN_PREC),min(min(toBord.x,toBord.y),toBord.z)); 89 | float stepl =(.1+.9*fract(dither+count/float(SSR_FILTER)))*limstep; 90 | p+=stepl*d; 91 | for(int i =0;i.9) 105 | ret*=texture2D(colortex4,p.xy).rgb*.25; 106 | #endif 107 | 108 | } 109 | 110 | #else 111 | if(depth<1.){ 112 | ret = texture2D(colortex0,p.xy).rgb; 113 | float m = texture2D(colortex3,p.xy).g; 114 | #ifdef USE_METALS 115 | if(m>.9) 116 | ret*=texture2D(colortex4,p.xy).rgb; 117 | #endif 118 | nohit=false; 119 | } 120 | #endif 121 | break; 122 | } 123 | stepl =clamp((depth-p.z)/abs(d.z),.01*limstep,limstep); 124 | p+=stepl*d; 125 | } 126 | 127 | #endif 128 | } 129 | return ret; 130 | } 131 | 132 | vec3 hash33(vec3 p3){ 133 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 134 | p3 += dot(p3, p3.yxz+19.19); 135 | return fract((p3.xxy + p3.yxx)*p3.zyx); 136 | 137 | } 138 | float hash13(vec3 p3){ 139 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 140 | p3 += dot(p3, p3.yxz+19.19); 141 | return fract(dot(p3,vec3(1))); 142 | 143 | } 144 | mat3 gettbn(vec3 nor){ 145 | vec3 tc = vec3( 1.0+nor.z-nor.xy*nor.xy, -nor.x*nor.y)/(1.0+nor.z); 146 | vec3 uu = vec3( tc.x, tc.z, -nor.x ); 147 | vec3 vv = vec3( tc.z, tc.y, -nor.y ); 148 | return mat3(uu,vv,nor); 149 | } 150 | 151 | vec3 cosineDirection( in vec3 nor,float r, vec2 fc, int it) 152 | { 153 | float seed= dither8(fc);//+frameTimeCounter*120.1; 154 | mat3 tbn = gettbn(nor); 155 | 156 | float seqf = haltonSeq(13,it); 157 | 158 | float u = r*fract(haltonSeq(5,frameCounter)+seed+seqf);//hash13(vec3(fc, 78.233) + seed); 159 | float v = TAU*fract(haltonSeq(7,frameCounter+12+int(seed*16.))-seqf);//hash13( vec3(fc,10.873 )+ seed); 160 | return normalize(tbn*vec3(sqrt(u)*vec2(cos(v),sin(v)) , sqrt(1.0-u))); 161 | } 162 | 163 | 164 | 165 | vec3 ssrs(vec3 p, vec3 rd, float rough,float sh, float fresnel){ 166 | vec3 c = vec3(0); 167 | vec3 n = normalize(texture2D(colortex2,tc).rgb*2.-1.); 168 | float rq = rough*rough; 169 | //rq *=rq; 170 | for(int i=0;i=.5; 188 | //c*=outsideness; 189 | 190 | vec3 hc = vec3(gl_FragCoord.xy,mod(frameCounter*3.,PI)*50.); 191 | dit = hash13(hc-hc.zxy); 192 | 193 | 194 | dither = fract(dither16(gl_FragCoord.xy)+frameTimeCounter*240.); 195 | float pd = texture2D(depthtex0,tc).r; 196 | 197 | vec3 p = (vec3(tc,pd)); 198 | vec3 viewp = screen2view(p); 199 | vec3 pbr = texture2D(colortex3,tc).rgb; 200 | //pbr.g=.134; 201 | //pbr.r = .9; 202 | float f0 = pbr.g*pbr.g; 203 | 204 | vec3 n = texture2D(colortex2,tc).rgb*2.-1.; 205 | 206 | n = normalize(n); 207 | float sh = 0.; 208 | 209 | 210 | 211 | vec3 rd = normalize(viewp); 212 | float roughness = (1 - pbr.r); 213 | roughness*=roughness; 214 | float fresnel=0.; 215 | //pbr.g++; 216 | #ifdef USE_METALS 217 | if(pbr.g>.9) 218 | fresnel=1.; 219 | else 220 | #endif 221 | fresnel = ((1.0 - f0) * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0)*(pbr.r) + f0); 222 | //fresnel=1.; 223 | 224 | float depth = depthBlock(pd); 225 | 226 | if(pd<1.&&fresnel>0.001){ 227 | 228 | vec3 ref = ssrs(p,rd,roughness,sh,fresnel); 229 | /* 230 | float n0 = 1.33; 231 | n0=1./n0; 232 | vec3 rt = refract(rd, n, n0); 233 | float cti = dot(rd,n),ctt = dot(rt,n); 234 | float fresnel = (cti-n0*ctt)/(cti+n0*ctt); 235 | fresnel*=fresnel; 236 | float fresnel2 = (n0*ctt-cti)/(cti+n0*ctt); 237 | fresnel =saturate(.5*(fresnel+fresnel2*fresnel2)); 238 | //*/ 239 | #ifdef USE_METALS 240 | if(pbr.g>.9) 241 | refc=ref*texture2D(colortex0,tc).rgb*2.,c*=0.; 242 | else 243 | #endif 244 | c*=(1.-fresnel),refc=ref*fresnel; 245 | 246 | } 247 | 248 | 249 | gl_FragData[0] = vec4(c,1.);//texture2D(colortex1,tc*.5+vec2(.5,0.)); 250 | gl_FragData[1] = vec4(refc,1.);//texture2D(colortex1,tc*.5+vec2(.5,0.)); 251 | 252 | } 253 | -------------------------------------------------------------------------------- /shaders/world-1/composite3.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "/lib/essentials.glsl" 3 | #include "/lib/trans.glsl" 4 | 5 | 6 | 7 | 8 | float dither,dit; 9 | 10 | varying vec2 tc; 11 | uniform sampler2D colortex7; 12 | uniform sampler2D colortex4; 13 | uniform sampler2D colortex3; 14 | uniform sampler2D colortex1; 15 | uniform sampler2D depthtex1; 16 | uniform sampler2D depthtex0; 17 | uniform sampler2D colortex0; 18 | uniform sampler2D colortex2; 19 | uniform float frameTimeCounter; 20 | uniform sampler2D shadowtex0; 21 | uniform sampler2D shadowtex1; 22 | uniform sampler2D shadowcolor0; 23 | uniform sampler2D shadowcolor1; 24 | 25 | 26 | uniform sampler2D noisetex; 27 | 28 | uniform int frameCounter; 29 | uniform int isEyeInWater; 30 | 31 | uniform float wetness; 32 | uniform float rainStrength; 33 | 34 | uniform vec3 skyColor; 35 | 36 | 37 | uniform int worldTime; 38 | 39 | 40 | #include "/lib/ambcol.glsl" 41 | #include "/lib/lmcol.glsl" 42 | 43 | 44 | #define SSR 45 | 46 | 47 | #define SSR_STEPS 8 //[4 8 12 16 24 32 64]$ 48 | #define SSR_REJECTION 49 | #define SSR_FILTER 4 //[1 2 4 8 16] 50 | 51 | #define SSR_MIN_PREC .05 //[.02 .03 .04 .05 .06 .07 .08 .1 .2] 52 | 53 | 54 | //#define shadowtex1 shadowtex0 55 | #define GA 2.39996322973 56 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 57 | 58 | 59 | bool isout=false; 60 | float outsideness = 0.; 61 | 62 | 63 | #define USE_METALS 64 | 65 | 66 | 67 | vec3 ssr2(vec3 p,vec3 rd,vec3 n,int count,float sh, float rough){ 68 | rd = reflect(rd,n); 69 | vec3 ret= vec3(.013,.005,.004); 70 | return ret; 71 | } 72 | 73 | 74 | vec3 ssr(vec3 p,vec3 rd,vec3 n,int count,float sh, float rough, float fresnel,float highlight){ 75 | vec3 P=p,RD=rd; 76 | rd = reflect(rd,n); 77 | vec3 gi = texture2D(colortex4,tc).rgb*.25; 78 | 79 | int ITER =int(ceil(float(SSR_STEPS)*(1.-rough))); 80 | 81 | vec3 ret=gi;// min3(vec3(.013,.005,.004),gi); 82 | bool nohit = true; 83 | if(fresnel-.5*rough>.01){ 84 | #ifdef SSR 85 | vec3 d = normalize(view2screen(screen2view(p)+rd)-p); 86 | float iter = float(ITER+1); 87 | vec3 toBord = (step(0,d)-p)/(d*iter); //distances to borders divided by the number of steps 88 | float limstep =max(min(1./iter,SSR_MIN_PREC),min(min(toBord.x,toBord.y),toBord.z)); 89 | float stepl =(.1+.9*fract(dither+count/float(SSR_FILTER)))*limstep; 90 | p+=stepl*d; 91 | for(int i =0;i.9) 105 | ret*=texture2D(colortex4,p.xy).rgb*.25; 106 | #endif 107 | 108 | } 109 | 110 | #else 111 | if(depth<1.){ 112 | ret = texture2D(colortex0,p.xy).rgb; 113 | float m = texture2D(colortex3,p.xy).g; 114 | #ifdef USE_METALS 115 | if(m>.9) 116 | ret*=texture2D(colortex4,p.xy).rgb; 117 | #endif 118 | nohit=false; 119 | } 120 | #endif 121 | break; 122 | } 123 | stepl =clamp((depth-p.z)/abs(d.z),.01*limstep,limstep); 124 | p+=stepl*d; 125 | } 126 | 127 | #endif 128 | } 129 | return ret; 130 | } 131 | 132 | vec3 hash33(vec3 p3){ 133 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 134 | p3 += dot(p3, p3.yxz+19.19); 135 | return fract((p3.xxy + p3.yxx)*p3.zyx); 136 | 137 | } 138 | float hash13(vec3 p3){ 139 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 140 | p3 += dot(p3, p3.yxz+19.19); 141 | return fract(dot(p3,vec3(1))); 142 | 143 | } 144 | mat3 gettbn(vec3 nor){ 145 | vec3 tc = vec3( 1.0+nor.z-nor.xy*nor.xy, -nor.x*nor.y)/(1.0+nor.z); 146 | vec3 uu = vec3( tc.x, tc.z, -nor.x ); 147 | vec3 vv = vec3( tc.z, tc.y, -nor.y ); 148 | return mat3(uu,vv,nor); 149 | } 150 | 151 | vec3 cosineDirection( in vec3 nor,float r, vec2 fc, int it) 152 | { 153 | float seed= dither8(fc);//+frameTimeCounter*120.1; 154 | mat3 tbn = gettbn(nor); 155 | 156 | float seqf = haltonSeq(13,it); 157 | 158 | float u = r*fract(haltonSeq(5,frameCounter)+seed+seqf);//hash13(vec3(fc, 78.233) + seed); 159 | float v = TAU*fract(haltonSeq(7,frameCounter+12+int(seed*16.))-seqf);//hash13( vec3(fc,10.873 )+ seed); 160 | return normalize(tbn*vec3(sqrt(u)*vec2(cos(v),sin(v)) , sqrt(1.0-u))); 161 | } 162 | 163 | 164 | 165 | vec3 ssrs(vec3 p, vec3 rd, float rough,float sh, float fresnel){ 166 | vec3 c = vec3(0); 167 | vec3 n = normalize(texture2D(colortex2,tc).rgb*2.-1.); 168 | float rq = rough*rough; 169 | //rq *=rq; 170 | for(int i=0;i=.5; 188 | //c*=outsideness; 189 | 190 | vec3 hc = vec3(gl_FragCoord.xy,mod(frameCounter*3.,PI)*50.); 191 | dit = hash13(hc-hc.zxy); 192 | 193 | 194 | dither = fract(dither16(gl_FragCoord.xy)+frameTimeCounter*240.); 195 | float pd = texture2D(depthtex0,tc).r; 196 | 197 | vec3 p = (vec3(tc,pd)); 198 | vec3 viewp = screen2view(p); 199 | vec3 pbr = texture2D(colortex3,tc).rgb; 200 | //pbr.g=.134; 201 | //pbr.r = .9; 202 | float f0 = pbr.g*pbr.g; 203 | 204 | vec3 n = texture2D(colortex2,tc).rgb*2.-1.; 205 | 206 | n = normalize(n); 207 | float sh = 0.; 208 | 209 | 210 | 211 | vec3 rd = normalize(viewp); 212 | float roughness = (1 - pbr.r); 213 | roughness*=roughness; 214 | float fresnel=0.; 215 | //pbr.g++; 216 | #ifdef USE_METALS 217 | if(pbr.g>.9) 218 | fresnel=1.; 219 | else 220 | #endif 221 | fresnel = ((1.0 - f0) * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0)*(pbr.r) + f0); 222 | //fresnel=1.; 223 | 224 | float depth = depthBlock(pd); 225 | 226 | if(pd<1.&&fresnel>0.001){ 227 | 228 | vec3 ref = ssrs(p,rd,roughness,sh,fresnel); 229 | /* 230 | float n0 = 1.33; 231 | n0=1./n0; 232 | vec3 rt = refract(rd, n, n0); 233 | float cti = dot(rd,n),ctt = dot(rt,n); 234 | float fresnel = (cti-n0*ctt)/(cti+n0*ctt); 235 | fresnel*=fresnel; 236 | float fresnel2 = (n0*ctt-cti)/(cti+n0*ctt); 237 | fresnel =saturate(.5*(fresnel+fresnel2*fresnel2)); 238 | //*/ 239 | #ifdef USE_METALS 240 | if(pbr.g>.9) 241 | refc=ref*texture2D(colortex0,tc).rgb*2.,c*=0.; 242 | else 243 | #endif 244 | c*=(1.-fresnel),refc=ref*fresnel; 245 | 246 | } 247 | 248 | 249 | gl_FragData[0] = vec4(c,1.);//texture2D(colortex1,tc*.5+vec2(.5,0.)); 250 | gl_FragData[1] = vec4(refc,1.);//texture2D(colortex1,tc*.5+vec2(.5,0.)); 251 | 252 | } 253 | -------------------------------------------------------------------------------- /shaders/deferred3.fsh: -------------------------------------------------------------------------------- 1 | #version 130 2 | #include "lib/trans.glsl" 3 | #include "lib/essentials.glsl" 4 | #include "lib/shadowtransform.glsl" 5 | #include "lib/sky.glsl" 6 | 7 | 8 | uniform sampler2D gcolor; 9 | 10 | uniform sampler2D gdepth; 11 | uniform sampler2D gnormal; 12 | 13 | uniform sampler2D colortex7; 14 | uniform sampler2D colortex4; 15 | uniform sampler2D colortex3; 16 | 17 | uniform sampler2D depthtex1; 18 | uniform sampler2D shadowtex1; 19 | uniform sampler2D shadowtex0; 20 | uniform sampler2D shadowcolor0; 21 | uniform sampler2D shadowcolor1; 22 | uniform float frameTimeCounter; 23 | uniform int frameCounter; 24 | 25 | uniform int worldTime; 26 | 27 | 28 | varying vec2 tc; 29 | 30 | 31 | #define AO_SAMPLES 2 //[1 2 4 8 12 16] //samples per pixelper frame 32 | #define AO_RADIUS .45 //[.1 .15 .2 .25 .3 .35 .4 .45 .5 .55 .6 .65 .7 .75 .8 .85 .9 .95 1. 1.25 1.5 1.75 2. 3. ]radius in m*pixel/screenwidthh 33 | 34 | const float autorad = float(AO_RADIUS)*.715/sqrt(float(AO_SAMPLES+1)); //.715 is empirical 35 | 36 | 37 | #define GI_SAMPLES 8 //[1 2 4 8 12 16 32 64 128] 38 | #define GI_DITHER_SCALE 1 //[1 2 3 4 5 6 7 8] //increases noise but saves framerate 39 | #define RSM_DIST .1 //[.01 .015 .02 .025 .05 .075 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.] 40 | 41 | 42 | #define AMBIENT_OCCLUSION 43 | #define GLOBAL_ILLUMINATION 44 | 45 | #define GA 2.39996322973 46 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 47 | float dither = 0; 48 | 49 | #ifdef AMBIENT_OCCLUSION 50 | //#define COLORED_SHADOW 51 | 52 | float ssao(float pixdpth, vec3 n){ 53 | vec3 p =screen2view(vec3(tc,pixdpth)); 54 | 55 | float a = 0.; 56 | float seq = float(frameCounter)/17.; 57 | 58 | vec2 angle = vec2(0,autorad/(p.z)); 59 | angle*=rot(dither*6.28318530718+24*seq); 60 | float r = 1.+fract(dither+10*seq); 61 | for(int i = 0;i=1.)?0.:i*i)*lightCol;//sss 162 | #ifdef COLORED_SHADOW 163 | if(texture2D(shadowtex0,sp.xy).r0.){ 164 | #ifdef OREN_NAYAR_DIFFUSE 165 | float i = diffuse(-rd,normalize(shadowLightPosition),n,rough); 166 | #else 167 | float i = saturate(dot(rd,normalize(shadowLightPosition))); 168 | #endif 169 | col+=sh*texture2D(shadowcolor0,sp.xy).rgb*lightCol*i*2.; 170 | sh=0.; 171 | } 172 | #endif 173 | // #ifdef PCSS 174 | // return min(s,getSoftShadows(sp,max(getPenumbra(sp),1.41421356237/float(shadowMapResolution*MC_SHADOW_QUALITY)),pixdpth)); 175 | // #else 176 | return col*2.; 177 | // #endif 178 | } 179 | /*DRAWBUFFERS:014*/ 180 | void main(){ 181 | vec4 col = texture2D(gcolor,tc); 182 | vec3 pbr = texture2D(colortex3,tc).rgb; 183 | 184 | 185 | dither = dither16(gl_FragCoord.xy); 186 | vec3 normal = texture2D(gnormal,tc).rgb*2.-1.; 187 | float pixdpth = texture2D(depthtex1,tc).r; 188 | float r =texture2D(gdepth,tc).r; 189 | vec3 rd = normalize(screen2view(vec3(tc,1.))); 190 | 191 | if(pixdpth>=1. ){ 192 | r=1.; 193 | /*col.rgb = texture2D(colortex4,tc/3.).rgb; 194 | float maxrb = max( col.r, col.b ); 195 | float k = clamp( (col.g-maxrb)*5.0, 0.0, 1.0 ); 196 | float dg = col.g; 197 | col.g = min( col.g, maxrb*0.8 ); 198 | col.rgb += dg - col.g; 199 | col.rgb = mix(col.rgb, getSky(rd,0.), k);*/ 200 | col.rgb = getSky(camdir(rd),0.); 201 | } 202 | float ao=r,sh=1.; 203 | float csh = texture2D(colortex4,tc*.5).r; 204 | //csh = 1.; 205 | if(pixdpth<1.){ 206 | #ifdef AMBIENT_OCCLUSION 207 | ao *= ssao(pixdpth,normal) ; 208 | #endif 209 | sh = shadow(pixdpth)*texture2D(gdepth,tc).g*csh; 210 | #ifdef GLOBAL_ILLUMINATION 211 | vec3 gi = rsm(pixdpth,normal,pbr); 212 | gi+=colorshadow(pixdpth,pbr,sh,rd,normal); 213 | gi*=csh; 214 | gl_FragData[2] = vec4(gi,1.); 215 | #else 216 | gl_FragData[2] = vec4(0.,0.,0.,1.); 217 | #endif 218 | }else{ 219 | gl_FragData[2] = vec4(0,0,0,1.); 220 | } 221 | 222 | col.rgb*=.5; 223 | gl_FragData[0] = col; 224 | gl_FragData[1] = vec4(ao,sh,r,1); 225 | } 226 | -------------------------------------------------------------------------------- /shaders/composite.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/trans.glsl" 4 | #include "lib/sky.glsl" 5 | #include "lib/lmcol.glsl" 6 | 7 | uniform sampler2D colortex0; 8 | uniform sampler2D depthtex1; 9 | 10 | 11 | varying vec2 tc; 12 | 13 | uniform sampler2D noisetex; 14 | uniform sampler2D colortex2; 15 | uniform sampler2D colortex3; 16 | uniform float frameTimeCounter; 17 | uniform int frameCounter; 18 | uniform int worldTime; 19 | uniform float rainStrength; 20 | uniform float wetness; 21 | 22 | 23 | 24 | #define USE_METALS 25 | 26 | uniform vec3 skyColor; 27 | 28 | 29 | 30 | #include "lib/clouds.glsl" 31 | 32 | 33 | #define CLOUD_RAYTRACING_QUALITY 4.0 //[1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0] 34 | #define CLOUD_LIGHTING_QUALITY 2.0 //[1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0] 35 | 36 | float shad(vec3 ro,vec3 rd,float d){ 37 | const float dist = 80.; 38 | vec3 p = ro+dist*rd*d/CLOUD_LIGHTING_QUALITY; 39 | float a =1.; 40 | float sts = dist/CLOUD_LIGHTING_QUALITY; 41 | for(int i = 0;i++dpt&&h2>dpt)) 55 | return vec3(1.); 56 | float t= h; 57 | h=max(h,h2), 58 | h=min(h,dpt), 59 | h2 = minp(t,h2); 60 | if(h2==0.)h=min(h,240.); 61 | float d = fract(bayer16(I*resolution)+120.1*frameTimeCounter); 62 | 63 | float extinct = 1.; 64 | float lightness = 0.; 65 | vec3 p = ro+(h-d*(h2-=h)/CLOUD_RAYTRACING_QUALITY)*rd; 66 | float sts = h2/CLOUD_RAYTRACING_QUALITY; 67 | for(int i = 0;i++dpt&&h2>dpt)) 128 | return vec3(1.); 129 | float t= h; 130 | h=max(h,h2), 131 | h=min(h,dpt), 132 | h2 = minp(t,h2); 133 | if(h2==0.)h=min(h,240.); 134 | float d = fract(bayer16(I*resolution)); 135 | 136 | float extinct = 1.; 137 | float lightness = 0.; 138 | vec3 p = ro+(h-d*(h2-=h)/q)*rd; 139 | float sts = h2/q; 140 | for(int i = 0;i++.9) 196 | fresnel=1.; 197 | else 198 | #endif 199 | fresnel = ((1.0 - f0) * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0) + f0)*(pbr.r*pbr.r); 200 | 201 | if(fresnel>.001) 202 | { 203 | //vec4 cl =base; 204 | //vec3 n = cosineDirection(n,roughness*roughness,gl_FragCoord.xy); 205 | vec3 cl=traceRough(p,rd,tc,ld,1e12,roughness,n); 206 | c += cl; 207 | 208 | } 209 | } 210 | //gl_FragData[0]=vec4(saturate3(c),1.); 211 | } 212 | gl_FragData[0]=vec4(saturate3(c),1.); 213 | 214 | }else{ 215 | if(floor(ntc)==vec2(1,0)){ 216 | vec3 p = cameraPosition+vec3((ntc-vec2(1.5,.5))*resolution,0.).xzy; 217 | gl_FragData[0]=vec4(cloudsh(p,ld,tc),0.,0.,1.); 218 | 219 | }else{ 220 | gl_FragData[0]=vec4(0.,0.,0.,1.); 221 | } 222 | } 223 | 224 | } 225 | -------------------------------------------------------------------------------- /shaders/composite5.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | #include "lib/essentials.glsl" 3 | #include "lib/shadowtransform.glsl" 4 | #include "lib/trans.glsl" 5 | 6 | uniform vec3 shadowLightPosition; 7 | 8 | 9 | 10 | float dither; 11 | 12 | varying vec2 tc; 13 | uniform sampler2D colortex1; 14 | uniform sampler2D depthtex1; 15 | uniform sampler2D depthtex0; 16 | uniform sampler2D colortex0; 17 | uniform sampler2D colortex2; 18 | uniform float frameTimeCounter; 19 | uniform sampler2D shadowtex0; 20 | uniform sampler2D shadowtex1; 21 | 22 | 23 | uniform sampler2D noisetex; 24 | 25 | uniform int frameCounter; 26 | uniform int isEyeInWater; 27 | 28 | uniform float wetness; 29 | uniform float rainStrength; 30 | 31 | 32 | 33 | uniform int worldTime; 34 | 35 | 36 | #include "lib/lmcol.glsl" 37 | #include "lib/clouds.glsl" 38 | 39 | vec3 lc=vec3(0.); 40 | 41 | #define GA 2.39996322973 42 | const mat2 Grot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA)); 43 | #include "lib/shadow.glsl" 44 | 45 | 46 | vec3 lightDir,lightcol; 47 | 48 | #define USE_METALS 49 | 50 | float getCloudShadow(vec3 p) 51 | { 52 | if(p.y>cloud_mid) 53 | return 1.; 54 | vec3 slp = normalize(view2cam(shadowLightPosition)); 55 | p-=slp*p.y/slp.y; 56 | vec2 pc = ((p.xz+.5*resolution)/resolution); 57 | return pc==fract(pc)?saturate(texture2D(colortex1,pc*.5+vec2(.5,0)).r):1.; 58 | } 59 | 60 | 61 | float hash13(vec3 p3){ 62 | p3 = fract(p3 * vec3(.1031, .1030, .0973)); 63 | p3 += dot(p3, p3.yxz+19.19); 64 | return fract(dot(p3,vec3(1))); 65 | 66 | } 67 | 68 | 69 | #define WATER_VOL_STEPS 8 //[2 4 8 16 32] 70 | #define VOLUMETRIC_WATER 71 | 72 | #ifdef VOLUMETRIC_WATER 73 | vec3 volumeWater(vec3 p1, vec3 p2,float sh, vec3 c){ 74 | p1=screen2cam(p1), 75 | p2=screen2cam(p2); 76 | vec3 rd = p2-p1; 77 | vec3 st = rd/float(WATER_VOL_STEPS+1); 78 | float shade =sh; 79 | float stlen = length(st); 80 | p2=p2-st*(dither+1.); 81 | for(int i=1;i1 127 | *(saturate(worley((p+cameraPosition)*.15)*.5+.5) 128 | #if FOG_DETAIL>2 129 | *.75+.25*saturate(worley((p+cameraPosition)*.5)*.5+.5) 130 | #endif 131 | ) 132 | #endif 133 | ; 134 | float den = density*stlen; 135 | float l = shadow2(p)*getCloudShadow(p); 136 | shade=mix(fogColor,lc,rayl*l); 137 | 138 | float ext= exp2(-den); 139 | trans+=m*shade*(1.-ext); 140 | m*=ext; 141 | if(m<.01){ 142 | break; 143 | } 144 | //c=mix(shade,c,ext); 145 | rba +=rb*(.2+.3*wetness)*l*rayl*rayl*(1.-ext); 146 | p+=st; 147 | } 148 | return c*m+trans+rba; 149 | } 150 | vec3 volumeLightSky(vec3 c,vec3 rd){ 151 | 152 | float rdDotUp = abs(normalize(rd).y); 153 | float powe = 1./(1.-rdDotUp*.8); 154 | 155 | vec3 p0 = gbufferModelViewInverse[3].xyz; 156 | vec3 st = (rd-p0)/float(VOL_STEPS); 157 | vec3 shade =vec3(0.); 158 | float rdlen = length(rd); 159 | //p0+=st*fract(dither); 160 | float stlen = length(st); 161 | 162 | 163 | vec3 fogColor = vec3(.058,.063,.08)*(length(lightcol)); 164 | float rayl = saturate(mix(dot(normalize(rd),lightDir),1.,.3)); 165 | rayl=2.*pow(rayl,8.); 166 | rayl+=.6; 167 | 168 | float wetd = wetness*wetness; 169 | wetd = wetd*wetd; 170 | vec3 li = lightcol*lightcol; 171 | vec3 rb = vec3(li.r,0,0)*smoothstep(.05,.0,abs(dot(normalize(rd),lightDir)+.1)); 172 | rb = mix(rb,vec3(0,li.g,0),smoothstep(.05,.0,abs(dot(normalize(rd),lightDir)+.125))); 173 | rb = mix(rb,vec3(0,0,li.b),smoothstep(.04,.0,abs(dot(normalize(rd),lightDir)+.15))); 174 | vec3 lc =lightcol; 175 | vec3 rba = vec3(0); 176 | 177 | float m = 1.; 178 | vec3 trans = vec3(0); 179 | float dist = stlen*fract(dither); 180 | vec3 stn = normalize(st); 181 | float lpd = 0.; 182 | for(int i=0;i1 190 | *(saturate(worley((p+cameraPosition)*.15)*.5+.5) 191 | #if FOG_DETAIL>2 192 | *.75+.25*saturate(worley((p+cameraPosition)*.5)*.5+.5) 193 | #endif 194 | ) 195 | #endif 196 | ; 197 | float den = density*postlen; 198 | float l = shadow2(p)*getCloudShadow(p); 199 | shade=mix(fogColor,lc,rayl*l); 200 | 201 | float ext= exp2(-den); 202 | trans+=m*shade*(1.-ext); 203 | m*=ext; 204 | if(m<.01){ 205 | break; 206 | } 207 | //c=mix(shade,c,ext); 208 | rba +=rb*(.2+.3*wetness)*l*rayl*rayl*(1.-ext); 209 | lpd = pdist; 210 | dist+=stlen; 211 | } 212 | return (c*m+trans+rba); 213 | } 214 | 215 | #endif 216 | 217 | /*DRAWBUFFERS:0*/ 218 | void main(){ 219 | #include "lib/lightcol.glsl" 220 | lightDir=lightdir,lightcol=lightCol; 221 | vec3 c = texture2D(colortex0,tc).rgb; 222 | float pd = texture2D(depthtex0,tc).r; 223 | 224 | 225 | //vec3 hc = vec3(gl_FragCoord.xy,mod(frameCounter*3.,PI)*50.); 226 | dither = fract(dither32(gl_FragCoord.xy)+2.*haltonSeq(2,frameCounter));//hash13(hc-hc.zxy); 227 | 228 | //dither = pd<1.?dither:.35+.3*dither; 229 | 230 | 231 | vec3 n = texture2D(colortex2,tc).rgb*2.-1.; 232 | 233 | float iswater = length(n)<.8?1.:0.; 234 | n = normalize(n); 235 | 236 | lc = lightcol; 237 | 238 | vec3 p = (vec3(tc,pd)); 239 | vec3 viewp = screen2view(p); 240 | vec3 rd = normalize(viewp); 241 | 242 | float depth = depthBlock(pd); 243 | 244 | 245 | if(isEyeInWater>0){ 246 | #ifdef VOLUMETRIC_WATER 247 | c = volumeWater(p,gbufferModelViewInverse[3].xyz,0.,c); 248 | #else 249 | c= mix(vec3(.005,.007,.03)*lightCol,c,exp2(-depth*WATER_THICCNESS)); 250 | #endif 251 | 252 | }else{ 253 | 254 | vec3 rd = camdir(viewp); 255 | float rayl = .2+.8*saturate(mix(dot(normalize(rd),lightDir),1.,.3)); 256 | vec3 fogColor = vec3(.05,.06,.1); 257 | #ifdef VOLUMETRIC_LIGHT 258 | c=pd<1.?volumeLight(c,rd):volumeLightSky(c,rd); 259 | //fogColor = vol.rgb; 260 | #else 261 | float vol=1.-exp2(-depth*.004); 262 | c=mix(c,fogColor,vol); 263 | #endif 264 | 265 | 266 | //if(fresnel>.01) 267 | //c*=0.; 268 | } 269 | gl_FragData[0] = vec4(c,1.);//texture2D(colortex1,tc*.5+vec2(.5,0.)); 270 | // gl_FragData[0] = vec4(sin(view2world(viewp)*60.)*.125+.125,1.);//texture2D(colortex1,tc*.5+vec2(.5,0.)); 271 | 272 | 273 | } 274 | --------------------------------------------------------------------------------