导航菜单

页面标题

页面副标题

Kreate v1.5.0 - BubbleRings.java 源代码

正在查看: Kreate v1.5.0 应用的 BubbleRings.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mikepenz.hypnoticcanvas.shaders;

import com.mikepenz.hypnoticcanvas.RuntimeEffect;
import com.mikepenz.hypnoticcanvas.shaders.Shader;
import kotlin.Metadata;

@Metadata(d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\r\n\u0002\u0010\u0007\n\u0002\b\u0005\bÇ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003R\u0014\u0010\u0004\u001a\u00020\u00058VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0006\u0010\u0007R\u0014\u0010\b\u001a\u00020\u00058VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\t\u0010\u0007R\u0014\u0010\n\u001a\u00020\u00058VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u000b\u0010\u0007R\u0014\u0010\f\u001a\u00020\u00058VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\r\u0010\u0007R\u0014\u0010\u000e\u001a\u00020\u00058VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u000f\u0010\u0007R\u0014\u0010\u0010\u001a\u00020\u00058VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0011\u0010\u0007R\u0014\u0010\u0012\u001a\u00020\u00138VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0014\u0010\u0015R\u0014\u0010\u0016\u001a\u00020\u0005X\u0096D¢\u0006\b\n\u0000\u001a\u0004\b\u0017\u0010\u0007¨\u0006\u0018"}, d2 = {"Lcom/mikepenz/hypnoticcanvas/shaders/BubbleRings;", "Lcom/mikepenz/hypnoticcanvas/shaders/Shader;", "<init>", "()V", "name", "", "getName", "()Ljava/lang/String;", "authorName", "getAuthorName", "authorUrl", "getAuthorUrl", "credit", "getCredit", "license", "getLicense", "licenseUrl", "getLicenseUrl", "speedModifier", "", "getSpeedModifier", "()F", "sksl", "getSksl", "hypnoticcanvas-shaders_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public final class BubbleRings implements Shader {
    public static final int $stable = 0;
    public static final BubbleRings INSTANCE = new BubbleRings();
    private static final String sksl = "\nuniform float uTime;\nuniform vec3 uResolution;\n\n// --------------------------------------------------------\n// HG_SDF\n// https://www.shadertoy.com/view/Xs3GRB\n// --------------------------------------------------------\nvoid pR(inout vec2 p, float a) {\n    p = cos(a)*p + sin(a)*vec2(p.y, -p.x);\n}\n\nfloat smax(float a, float b, float r) {\n    vec2 u = max(vec2(r + a,r + b), vec2(0));\n    return min(-r, max (a, b)) + length(u);\n}\n\n\n// --------------------------------------------------------\n// Spectrum colour palette\n// IQ https://www.shadertoy.com/view/ll2GD3\n// --------------------------------------------------------\n\nvec3 pal( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d ) {\n    return a + b*cos( 6.28318*(c*t+d) );\n}\n\nvec3 spectrum(float n) {\n    return pal( n, vec3(0.5,0.5,0.5),vec3(0.5,0.5,0.5),vec3(1.0,1.0,1.0),vec3(0.0,0.33,0.67) );\n}\n\n\n// --------------------------------------------------------\n// Main SDF\n// https://www.shadertoy.com/view/wsfGDS\n// --------------------------------------------------------\n\nvec4 inverseStereographic(vec3 p, out float k) {\n    k = 2.0/(1.0+dot(p,p));\n    return vec4(k*p,k-1.0);\n}\n\nfloat fTorus(vec4 p4) {\n    float d1 = length(p4.xy) / length(p4.zw) - 1.;\n    float d2 = length(p4.zw) / length(p4.xy) - 1.;\n    float d = d1 < 0. ? -d1 : d2;\n    d /= 3.14159265359;\n    return d;\n}\n\nfloat fixDistance(float d, float k) {\n    float sn = sign(d);\n    d = abs(d);\n    d = d / k * 1.82;\n    d += 1.;\n    d = pow(d, .5);\n    d -= 1.;\n    d *= 5./3.;\n    d *= sn;\n    return d;\n}\n\nfloat map(float time, vec3 p) {\n    float k;\n    vec4 p4 = inverseStereographic(p,k);\n\n    pR(p4.zy, time * -3.14159265359 / 2.);\n    pR(p4.xw, time * -3.14159265359 / 2.);\n\n    // A thick walled clifford torus intersected with a sphere\n\n    float d = fTorus(p4);\n    d = abs(d);\n    d -= .2;\n    d = fixDistance(d, k);\n    d = smax(d, length(p) - 1.85, .2);\n\n    return d;\n}\n\n\n// --------------------------------------------------------\n// Rendering\n// --------------------------------------------------------\n\nmat3 calcLookAtMatrix(vec3 ro, vec3 ta, vec3 up) {\n    vec3 ww = normalize(ta - ro);\n    vec3 uu = normalize(cross(ww,up));\n    vec3 vv = normalize(cross(uu,ww));\n    return mat3(uu, vv, ww);\n}\n\n\nvec4 main( vec2 fragCoord ) {\n    float time = mod(uTime / 2., 1.);\n\n    vec3 camPos = vec3(1.8, 5.5, -5.5) * 1.75;\n    vec3 camTar = vec3(.0,0,.0);\n    vec3 camUp = vec3(-1,0,-1.5);\n    mat3 camMat = calcLookAtMatrix(camPos, camTar, camUp);\n    float focalLength = 5.;\n    vec2 p = (-uResolution.xy + 2. * fragCoord.xy) / uResolution.y;\n\n    vec3 rayDirection = normalize(camMat * vec3(p, focalLength));\n    vec3 rayPosition = camPos;\n    float rayLength = 0.;\n\n    float distance = 0.;\n    vec3 color = vec3(0);\n\n    vec3 c;\n\n    // Keep iteration count too low to pass through entire model,\n    // giving the effect of fogged glass\n    const float ITER = 82.;\n    const float FUDGE_FACTORR = .8;\n    const float INTERSECTION_PRECISION = .001;\n    const float MAX_DIST = 20.;\n\n    for (float i = 0.; i < ITER; i++) {\n\n        // Step a little slower so we can accumilate glow\n        rayLength += max(INTERSECTION_PRECISION, abs(distance) * FUDGE_FACTORR);\n        rayPosition = camPos + rayDirection * rayLength;\n        distance = map(time, rayPosition);\n\n        // Add a lot of light when we're really close to the surface\n        c = vec3(max(0., .01 - abs(distance)) * .5);\n        c *= vec3(1.4,2.1,1.7); // blue green tint\n\n        // Accumilate some purple glow for every step\n        c += vec3(.6,.25,.7) * FUDGE_FACTORR / 160.;\n        c *= smoothstep(20., 7., length(rayPosition));\n\n        // Fade out further away from the camera\n        float rl = smoothstep(MAX_DIST, .1, rayLength);\n        c *= rl;\n\n        // Vary colour as we move through space\n        c *= spectrum(rl * 6. - .6);\n\n        color += c;\n\n        if (rayLength > MAX_DIST) {\n            break;\n        }\n    }\n\n    // Tonemapping and gamma\n    color = pow(color, vec3(1. / 1.8)) * 2.;\n    color = pow(color, vec3(2.)) * 3.;\n    color = pow(color, vec3(1. / 2.2));\n\n    return vec4(color, 1);\n}\n    ";

    @Override
    public float getSpeedModifier() {
        return 0.1f;
    }

    private BubbleRings() {
    }

    @Override
    public void applyUniforms(RuntimeEffect runtimeEffect, float f, float f2, float f3) {
        Shader.DefaultImpls.applyUniforms(this, runtimeEffect, f, f2, f3);
    }

    @Override
    public String getName() {
        return "Bubble rings";
    }

    @Override
    public String getAuthorName() {
        return "tdhooper";
    }

    @Override
    public String getAuthorUrl() {
        return "https://www.shadertoy.com/user/tdhooper";
    }

    @Override
    public String getCredit() {
        return "https://www.shadertoy.com/view/WdB3Dw";
    }

    @Override
    public String getLicense() {
        return "Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License";
    }

    @Override
    public String getLicenseUrl() {
        return "https://www.shadertoy.com/terms";
    }

    @Override
    public String getSksl() {
        return sksl;
    }
}