Is this look realistic? It was made in UPBGE 0.36.1 and took 3 hours to make. Tell me in the comments!!
i used this script for make barrel effect for game check it:
Barrel.glsl
uniform sampler2D bgl_RenderedTexture; // Texture from the screen uniform float focalLength = 0.6; // Focal length (default: 0.6) uniform float centerX = 0.5; // Center X (default: 0.5) uniform float centerY = 0.5; // Center Y (default: 0.5) uniform float scale = 0.8; // Texture scale (default: 0.8) uniform float k1 = 0.7; // Radial distortion constant 1 (default: 0.7) uniform float k2 = -0.5; // Radial distortion constant 2 (default: -0.5) in vec2 fragTexCoord; // Input texture coordinate from vertex shader out vec4 fragColor; // Output color void main() { vec2 texcoord = fragTexCoord; // Current texture coordinates // Center the coordinates and scale them vec2 xy = (texcoord - vec2(centerX, centerY)) / vec2(focalLength) * scale; // Calculate radial distortion float r2 = dot(xy, xy); // Squared distance float r4 = r2 * r2; // Fourth power of distance float coeff = (k1 * r2 + k2 * r4); // Radial distortion coefficient // Apply distortion and restore the coordinates xy = xy + xy * coeff; xy = xy * focalLength + vec2(centerX, centerY); // Clamp coordinates to make sure they stay within [0, 1] xy = clamp(xy, 0.0, 1.0); // This ensures no out-of-bounds access // Sample the texture using the distorted coordinates fragColor = texture(bgl_RenderedTexture, xy); }
This barrel effect script is not working and I don’t know where the error is