diff options
Diffstat (limited to 'client/map/tiles')
| -rw-r--r-- | client/map/tiles/portal.gdshader | 63 | 
1 files changed, 63 insertions, 0 deletions
| diff --git a/client/map/tiles/portal.gdshader b/client/map/tiles/portal.gdshader new file mode 100644 index 00000000..3ffd7d07 --- /dev/null +++ b/client/map/tiles/portal.gdshader @@ -0,0 +1,63 @@ +/* +    Hurry Curry! - a game about cooking +    Copyright 2024 metamuffin + +    This program is free software: you can redistribute it and/or modify +    it under the terms of the GNU Affero General Public License as published by +    the Free Software Foundation, version 3 of the License only. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +    GNU Affero General Public License for more details. + +    You should have received a copy of the GNU Affero General Public License +    along with this program.  If not, see <https://www.gnu.org/licenses/>. + +*/ +shader_type spatial; +render_mode unshaded; + +uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; + +varying vec3 world_camera; +varying vec3 world_position; +varying mat4 untr; + +uniform float type : hint_range(-1.0, 1.0); +uniform float size : hint_range(0.0, 2.0); + +void vertex() { +	MODELVIEW_MATRIX = VIEW_MATRIX * mat4( +		INV_VIEW_MATRIX[0], +		INV_VIEW_MATRIX[1], +		INV_VIEW_MATRIX[2], +		MODEL_MATRIX[3] +	); +	world_position = VERTEX; +	world_camera = (inverse(MODELVIEW_MATRIX) * vec4(0, 0, 0, 1)).xyz; +	untr = MODELVIEW_MATRIX; +} + +void fragment() { +	vec3 ray = world_camera / size; +	vec3 rv = normalize(world_position - world_camera); +	vec3 em = vec3(0.); +	bool hit = false; +	 +	for (int i = 0; i < 100; i++) { +		float st = length(ray) * 0.1; +		ray += normalize(rv) * st; +		if (length(ray) < 1.) { hit = true; break; } +		rv += -normalize(ray) * -type / exp(dot(ray,ray)) * st; +		em += st * smoothstep(1.5,1.2,length(ray)) * 0.2; +	} +	 +	vec4 k = PROJECTION_MATRIX * vec4(rv*1000.0, 1.0); +	k /= k.z; +	vec2 k2 = (k.xy + 1.) / 2.; + +	vec3 col = hit ? vec3(type*0.5+0.5) : texture(screen_texture, k2).rgb; +	col += vec3(0.3,0.0,1.0) * max(em - 0.1,0.); +	ALBEDO = col; +} | 
