Scratch fisheye effect

Acts just like the fisheye effect from Scratch

NOTICE: This shader uses edited code from another source (Under GNU AFFERO GENERAL PUBLIC LICENSE)
Source: https://github.com/scratchfoundation/scratch-render/blob/develop/src/shaders/sprite.frag

Shader code
shader_type canvas_item;

uniform float amount = 0.0;

void fragment() {
	float newAmount = (amount / 100.0) + 1.0;
	
	vec2 texcoord0 = UV;
	vec2 kCenter = vec2(0.5);
	
	vec2 vec = (texcoord0 - kCenter) / kCenter;
	float vecLength = length(vec);
	float r = pow(min(vecLength, 1.0), newAmount) * max(1.0, vecLength);
	vec2 unit = vec / vecLength;

	texcoord0 = kCenter + r * unit * kCenter;
	
	COLOR = texture(TEXTURE, texcoord0);
}
Live Preview
Tags
Scratch
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from The2AndOnly

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments