Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex hangs the browser #23

Open
tdhooper opened this issue Nov 21, 2019 · 2 comments
Open

Regex hangs the browser #23

tdhooper opened this issue Nov 21, 2019 · 2 comments

Comments

@tdhooper
Copy link

const results = regex.exec(rawFragmentShader);

I'm trying to run some non-ISF shaders through the parser which cause this line to hang the browser. Instead of doing this validity check and grabbing the metadata block with an expensive regex, why not use the startIndex and endIndex endpoints you define later?

If you're wondering why I'm trying to parse non-ISF shaders, consider a live-update application where someone makes a typo, or in my case where I'm supporting multiple shader metadata formats, and only want to invoke ISF if it's a valid ISF shader.

@msfeldstein
Copy link
Owner

How do you get it to hang? I tried deleting the whole comment section on interactiveshaderformat.com and it seems to work (error) just fine but not hang

@tdhooper
Copy link
Author

Here's the part of my shader which is causing it to hang, try pasting this into interactiveshaderformat.com



float mHead(vec3 p) {

    p = pp;
    p += vec3(-.165,.0715,-.346);
    float eyeball = length(p) - .088;
    if (isMap) isEye = eyeball < d;
    d = min(d, eyeball);


    // ear
    p = pp;
    p += vec3(-.405,.12,.10);
    pR(p.xy, -.12);
    pR(p.xz, .35);
    pR(p.yz, -.3);
    vec3 pe = p;

    // base
    float ear = p.s + smoothstep(-.05, .1, p.y) * .015 - .005;
    float earback = -ear - mix(.001, .025, smoothstep(.3, -.2, p.y));

    // inner
    pR(p.xz, -.5);
    float iear = ellip(p.zy - vec2(.01,-.03), vec2(.045,.05));
    iear = smin(iear, length(p.zy - vec2(.04,-.09)) - .02, .09);
    float ridge = iear;
    iear = smin(iear, length(p.zy - vec2(.1,-.03)) - .06, .07);
    ear = smax2(ear, -iear, .04);
    earback = smin(earback, iear - .04, .02);

    // ridge
    p = pe;
    pR(p.xz, .2);
    ridge = ellip(p.zy - vec2(.01,-.03), vec2(.045,.055));
    ridge = smin3(ridge, -pRi(p.zy, .2).x - .01, .015);
    ridge = smax3(ridge, -ellip(p.zy - vec2(-.01,.1), vec2(.12,.08)), .02);

    float ridger = .01;

    ridge = max(-ridge, ridge - ridger);

    ridge = smax2(ridge, abs(p.x) - ridger/2., ridger/2.);

    ear = smin(ear, ridge, .045);



    return d;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants