2 // Note:: All channels marked with an ** are currently not filled out by the engine.
5 // ____________________________________________________________________________________________
10 // Vector Information _________________________________________________________________________
11 // ( A bunch of vectors that give you the location of different entities )
12 uniform vec3 bounds_NWU; // North-West-Upper coordinate of the playspace (worldspace)
13 uniform vec3 bounds_SEL; // South-East-Lower coordinate of the playspace (worldspace)
14 uniform vec2 bounds_NWU_SS; // North-West coordinate of the playspace (screen space)
15 uniform vec2 bounds_SEL_SS; // South-East coordinate of the playspace (screen space)
17 uniform vec2 pos_spawn_ct; // Location of the CT Spawn (0-1)
18 uniform vec2 pos_spawn_t; // Location of the T Spawn (0-1)
19 uniform vec2 bombsite_a; // Location of bomsite A (0-1)
20 uniform vec2 bombsite_b; // Location of bombsite B (0-1)
23 // Image Inputs _______________________________________________________________________________
24 // ( Standard generated maps from the engine )
25 uniform sampler2D tex_background; // Background texture
26 uniform sampler2D tex_playspace; // Playspace
27 // R: Height (Regular)
28 // G: Height (Reverse rendering order)
29 // **B: Baked Lighting
30 // A: Playable Space (0 or 1)
32 uniform sampler2D tex_objectives; // Objectives
33 // R: Buzones (0 or 1)
36 // A: Buyzones & Bombsites (mask 0-1)
38 uniform sampler2D tex_props; // Props
39 // **R: Height (0-1 normalized)
42 // **A: Props (0 or 1)
44 uniform sampler2D tex_gradient; // Gradient input
45 // RGBA: 256x1 image defining a gradient
47 uniform sampler2D texture0; // Custom Image input 3 (**RGBA)
48 uniform sampler2D texture1; // Custom Image input 4 (**RGBA)
49 uniform sampler2D texture2; // Custom Image input 5 (**RGBA)
52 // ____________________________________________________________________________________________
53 // ( A collection of simple blend modes )
55 vec3 lerp(vec3 a, vec3 b, float w)
60 vec4 blend_normal(vec4 a, vec4 b, float s)
62 return vec4(lerp(a.rgb, b.rgb, b.a * s), a.a + (b.a * s));
65 vec4 blend_add(vec4 a, vec4 b, float s)
67 return vec4(a.rgb + (b.rgb * s), a.a);
70 // -------------------------------------- sample helpers --------------------------------------
72 vec4 sample_gradient(float height)
74 return vec4(texture(tex_gradient, vec2(height, 0)));
77 float get_playspace(vec4 sample_playspace) { return sample_playspace.a; }
78 float get_playspace_height(vec4 sample_playspace) { return sample_playspace.a * sample_playspace.r; }
79 float get_playspace_inverse_height(vec4 sample_playspace) { return sample_playspace.a * sample_playspace.g; }
81 float get_height(vec4 sample_playspace) { return sample_playspace.g; }
82 float get_baked_light(vec4 sample_playspace) { return sample_playspace.r; }
84 // -------------------------------------- kernel filters --------------------------------------
85 // Given an 0-1 mask, return a 'glow value'
86 float kernel_filter_glow(sampler2D sampler, int channelID = 0, int sample_size = 16)
88 vec2 pixel_size = 1.0 / vec2(textureSize(sampler, 0));
91 int sample_double = sample_size * 2;
94 for(int x = 0; x <= sample_double; x++){
95 for(int y = 0; y <= sample_double; y++){
96 sT += texture(sampler, TexCoords + vec2((-sample_size + x) * pixel_size.x, (-sample_size + y) * pixel_size.y))[channelID];
100 sT /= (sample_double * sample_double);
105 // Given a 0-1 mask, return an outline drawn around that mask
106 float kernel_filter_outline(sampler2D sampler, int channelID = 0, int sample_size = 2)
108 vec2 pixel_size = 1.0 / vec2(textureSize(sampler, 0));
111 int sample_double = sample_size * 2;
114 for(int x = 0; x <= sample_double; x++){
115 for(int y = 0; y <= sample_double; y++){
116 sT += //texture(sampler, TexCoords + vec2((-sample_size + x) * pixel_size.x, (-sample_size + y) * pixel_size.y))[channelID];
117 (sample_size - min(length(vec2(-sample_size + x, -sample_size + y)), sample_size)) *
118 texture(sampler, TexCoords + vec2((-sample_size + x) * pixel_size.x, (-sample_size + y) * pixel_size.y))[channelID];
122 return max(min(sT, 1) - texture(sampler, TexCoords)[channelID], 0);
126 // ____________________________________________________________________________________________
127 // ( Write all your shader code & functions here )
128 vec4 outline_color = vec4(0.8, 0.8, 0.8, 0.6);
129 vec4 ao_color = vec4(0.0, 0.0, 0.0, 1.0);
131 vec4 buyzone_color = vec4(0.180, 0.828, 0.225, 0.667);
132 vec4 objective_color = vec4(0.770, 0.295, 0.171, 1.000);
136 vec4 sBackground = vec4(texture(tex_background, TexCoords));
137 vec4 sPlayspace = vec4(texture(tex_playspace, TexCoords));
138 vec4 sObjectives = vec4(texture(tex_objectives, TexCoords));
140 vec4 final = sBackground;
141 final = blend_normal(final, ao_color, kernel_filter_glow(tex_playspace, 3, 16)); // Drop shadow
142 final = blend_normal(final, sample_gradient(get_playspace_height(sPlayspace)), get_playspace(sPlayspace)); // Playspace
143 final = blend_normal(final, outline_color, kernel_filter_outline(tex_playspace, 3, 2)); // Outline
145 //final = blend_normal(final, objective_color, sObjectives.r * sObjectives.a); // Objectives
146 //final = blend_normal(final, buyzone_color, sObjectives.g * sObjectives.a); // Buyzones
147 // Return the final output color