导航菜单

页面标题

页面副标题

Kreate v1.5.0 - PurpleLiquid.java 源代码

正在查看: Kreate v1.5.0 应用的 PurpleLiquid.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\u0014\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u000f\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\u0005X\u0096D¢\u0006\b\n\u0000\u001a\u0004\b\u0013\u0010\u0007¨\u0006\u0014"}, d2 = {"Lcom/mikepenz/hypnoticcanvas/shaders/PurpleLiquid;", "Lcom/mikepenz/hypnoticcanvas/shaders/Shader;", "<init>", "()V", "name", "", "getName", "()Ljava/lang/String;", "authorName", "getAuthorName", "authorUrl", "getAuthorUrl", "credit", "getCredit", "license", "getLicense", "licenseUrl", "getLicenseUrl", "sksl", "getSksl", "hypnoticcanvas-shaders_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public final class PurpleLiquid implements Shader {
    public static final int $stable = 0;
    public static final PurpleLiquid INSTANCE = new PurpleLiquid();
    private static final String sksl = "\nuniform float uTime;\nuniform vec3 uResolution;\n\n\n\nconst float arrow_density = 4.5;\nconst float arrow_length = .45;\n\nconst int iterationTime1 = 20;\nconst int iterationTime2 = 20;\nconst int vector_field_mode = 0;\nconst float scale = 6.;\n\nconst float velocity_x = 0.1;\nconst float velocity_y = 0.2;\n\nconst float mode_2_speed = 2.5;\nconst float mode_1_detail = 200.;\nconst float mode_1_twist = 50.;\n\nconst bool isArraw = true;\n\nconst vec3 luma = vec3(0.2126, 0.7152, 0.0722);\n\n\nfloat f(in vec2 p)\n{\n    return sin(p.x+sin(p.y+uTime*velocity_x)) * sin(p.y*p.x*0.1+uTime*velocity_y);\n}\n\n\nstruct Field {\n    vec2 vel;\n    vec2 pos;\n};\n\n//---------------Field to visualize defined here-----------------\n\nField field(in vec2 p,in int mode)\n{\n    Field field;\n    if(mode == 0){\n    \tvec2 ep = vec2(0.05,0.);\n        vec2 rz= vec2(0);\n        //# centered grid sampling\n        for( int i=0; i<iterationTime1; i++ )\n        {\n            float t0 = f(p);\n            float t1 = f(p + ep.xy);\n            float t2 = f(p + ep.yx);\n            vec2 g = vec2((t1-t0), (t2-t0))/ep.xx;\n            vec2 t = vec2(-g.y,g.x);\n            \n            //# need update 'p' for next iteration,but give it some change.\n            p += (mode_1_twist*0.01)*t + g*(1./mode_1_detail);\n            p.x = p.x + sin( uTime*mode_2_speed/10.)/10.;\n            p.y = p.y + cos(uTime*mode_2_speed/10.)/10.;\n            rz= g; \n        }\n        field.vel = rz;\n        return field;\n    }\n    \n    if(mode == 1){\n        vec2 ep = vec2(0.05,0.);\n        vec2 rz= vec2(0);\n        //# centered grid sampling\n        for( int i=0; i<iterationTime1; i++ )\n        {\n            float t0 = f(p);\n            float t1 = f(p + ep.xy);\n            float t2 = f(p + ep.yx);\n            vec2 g = vec2((t1-t0), (t2-t0))/ep.xx;\n            vec2 t = vec2(-g.y,g.x);\n\n            //# need update 'p' for next iteration,but give it some change.\n            p += (mode_1_twist*0.01)*t + g*(1./mode_1_detail);\n            p.x = p.x + sin( uTime*mode_2_speed/10.)/10.;\n            p.y = p.y + cos(uTime*mode_2_speed/10.)/10.;\n            rz= g;\n        }\n        \n        field.vel = rz;\n        // add curved effect into curved mesh\n        for(int i=1; i<iterationTime2; i++){\n            //# try comment these 2 lines,will give more edge effect\n            p.x+=0.3/float(i)*sin(float(i)*3.*p.y+uTime*mode_2_speed) + 0.5;\n            p.y+=0.3/float(i)*cos(float(i)*3.*p.x + uTime*mode_2_speed) + 0.5;\n        }\n        field.pos = p;\n        return field;\n    }\n    \n    return field;\n}\n//---------------------------------------------------------------\n\nfloat segm(in vec2 p, in vec2 a, in vec2 b) //from iq\n{\n\tvec2 pa = p - a;\n\tvec2 ba = b - a;\n\tfloat h = clamp(dot(pa,ba)/dot(ba,ba), 0., 1.);\n\treturn length(pa - ba*h)*20.*arrow_density;\n}\n\nfloat fieldviz(in vec2 p,in int mode)\n{\n    vec2 ip = floor(p*arrow_density)/arrow_density + .5/arrow_density;   \n    vec2 t = field(ip,mode).vel;\n    float m = min(0.1,pow(length(t),0.5)*(arrow_length/arrow_density));\n    vec2 b = normalize(t)*m;\n    float rz = segm(p, ip, ip+b);\n    vec2 prp = (vec2(-b.y,b.x));\n    rz = min(rz,segm(p, ip+b, ip+b*0.65+prp*0.3));\n    return clamp(min(rz,segm(p, ip+b, ip+b*0.65-prp*0.3)),0.,1.);\n}\n\n\nvec3 getRGB(in Field fld,in int mode){\n\n    if(mode == 0){\n        vec2 p = fld.vel;\n        vec3 origCol = vec3(p * 0.5 + 0.5, 1.5);\n        return origCol;\n    }\n    \n    if(mode == 1){\n        vec2 p = fld.pos;\n        float r=cos(p.x+p.y+1.)*.5+.5;\n        float g=sin(p.x+p.y+1.)*.5+.5;\n        float b=(sin(p.x+p.y)+cos(p.x+p.y))*.3+.5;\n        vec3 col = sin(vec3(-.3,0.1,0.5)+p.x-p.y)*0.65+0.35;\n        return vec3(r,g,b);\n    }\n\n    return vec3(0, 0, 0);\n}\n\nvec4 main( vec2 fragCoord )\n{\n\tvec2 p = fragCoord.xy / uResolution.xy-0.5 ;\n\tp.x *= uResolution.x/uResolution.y;\n    p *= scale;\n    \n    vec2 uv = fragCoord.xy / uResolution.xy;\n    vec3 col;\n    float fviz;\n    \n    int vector_mode = 0;\n    Field fld = field(p,vector_mode);\n    col = getRGB(fld,vector_mode) * 0.85;    \n\treturn vec4(col,1.0);\n}\n    ";

    private PurpleLiquid() {
    }

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

    @Override
    public float getSpeedModifier() {
        return Shader.DefaultImpls.getSpeedModifier(this);
    }

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

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

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

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

    @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;
    }
}