1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

ULTRA FAILED Halo Shader!

Discussion in 'Modding [KAG Classic]' started by Asu, May 20, 2012.

Thread Status:
Not open for further replies.
  1. Asu

    Asu THD Team THD Team Forum Moderator

    Messages:
    1,578
    //Edit from Kouji: Moved to modding
    Hello all!
    I'm not good for write english, i'm french and 11...

    Hmm.. No i failed : It's not a halo shader, i builded a cel shading shader xD

    screen-12-05-20-11-30-31.png
    Open : \KAG\Base\Scripts\hq2x.frag with notepad or other,
    and copy that :
    uniform sampler2D baseMap;

    const float mx = 0.5; // start smoothing wt.
    const float k = -0.4; // wt. decrease factor
    const float max_w = 45; // max filter weigth
    const float min_w =-0.25; // min filter weigth
    const float lum_add = 35; // effects smoothing

    void main()
    {
    vec3 c00 = texture2D(baseMap, gl_TexCoord[1].xy).xyz;
    vec3 c10 = texture2D(baseMap, gl_TexCoord[1].zw).xyz;
    vec3 c20 = texture2D(baseMap, gl_TexCoord[2].xy).xyz;
    vec3 c01 = texture2D(baseMap, gl_TexCoord[4].zw).xyz;
    vec3 c11 = texture2D(baseMap, gl_TexCoord[0].xy).xyz;
    vec3 c21 = texture2D(baseMap, gl_TexCoord[2].zw).xyz;
    vec3 c02 = texture2D(baseMap, gl_TexCoord[4].xy).xyz;
    vec3 c12 = texture2D(baseMap, gl_TexCoord[3].zw).xyz;
    vec3 c22 = texture2D(baseMap, gl_TexCoord[3].xy).xyz;
    vec3 dt = vec3(1.0, 1.0, 1.0);

    float md1 = dot(abs(c00 - c22), dt);
    float md2 = dot(abs(c02 - c20), dt);

    float w1 = dot(abs(c22 - c11), dt) * md2;
    float w2 = dot(abs(c02 - c11), dt) * md1;
    float w3 = dot(abs(c00 - c11), dt) * md2;
    float w4 = dot(abs(c20 - c11), dt) * md1;

    float t1 = w1 + w3;
    float t2 = w2 + w4;
    float ww = max(t1, t2) + 0.0001;

    c11 = (w1 * c00 + w2 * c20 + w3 * c22 + w4 * c02 + ww * c11) / (t1 + t2 + ww);

    float lc1 = k / (0.12 * dot(c10 + c12 + c11, dt) + lum_add);
    float lc2 = k / (0.12 * dot(c01 + c21 + c11, dt) + lum_add);

    w1 = clamp(lc1 * dot(abs(c11 - c10), dt) + mx, min_w, max_w);
    w2 = clamp(lc2 * dot(abs(c11 - c21), dt) + mx, min_w, max_w);
    w3 = clamp(lc1 * dot(abs(c11 - c12), dt) + mx, min_w, max_w);
    w4 = clamp(lc2 * dot(abs(c11 - c01), dt) + mx, min_w, max_w);

    gl_FragColor.rgb = w1 * c10 + w2 * c21 + w3 * c12 + w4 * c01 + (1.0 - w1 - w2 - w3 - w4) * c11;
    gl_FragColor.a = 1.0;
    }
    You can set the halo bigger with modify 'const float max_w'.

    I KNOW THIS SHADER IS VERY FAILED XD.

    [Click on the picture for zoom.]
     
    Hella, Wonkyth, AnRK and 2 others like this.
  2. Ghozt

    Ghozt Haxor

    Messages:
    1,083
    It actually looks pretty cool up close, I don't think this would be practical though, but good job, and for an 11 year old!
    Awesome job!
     
  3. AnRK

    AnRK Shark Slayer

    Messages:
    641
    Anyone that can do any coding or speak any other language at all at 11 is impressive.
     
    Miauw62, Froghead48 and Ghozt like this.
  4. Pitbull7

    Pitbull7 Shopkeep Stealer

    Messages:
    84
    Yeah good Job.
    I still cant code for my life
     
    Ghozt likes this.
  5. Fate

    Fate Studying seashells

    Messages:
    593
    Mm definitely interesting to look at. Keep experimenting! Failure leads to success.
     
    BeasterDenBeast likes this.
  6. Boxpipe

    Boxpipe single, female, lawyer

    Messages:
    293
    All you need are the values within these lines:

    Code:
    [...]
    const float mx = 0.5; // start smoothing wt.
    const float k = -0.4; // wt. decrease factor
    const float max_w = 45; // max filter weigth
    const float min_w =-0.25; // min filter weigth
    const float lum_add = 35; // effects smoothing
    [...]
    Everything else is the exact same.
     
  7. Yeah I agree with a lot of the comments here. Speaking another language and coding is really impressive for someone at the age of 11. I'm 15, purely speak English and know nothing about coding, so good work AsuMagic!
    This shading actually doesn't look so bad. I would consider this far from a failure. I may even try this one day when I can be bothered to alter files, hahaha. Keep it up, and you can only get better and better at whatever you're trying to do.
     
    ImAwesome and Ghozt like this.
  8. The_Khan

    The_Khan Bison Rider

    Messages:
    757
    Me too! Good work though mate. Looks a but blurry though. :P
     
  9. Ghozt

    Ghozt Haxor

    Messages:
    1,083
    The_Khan,

    It only looks blurry because of the actual sprite itself, like the name suggests, a halo, a halo from my knowledge is a enclosed shape/object that encircles a specific object.
    I.e: Halo, from Halo, well that explains itself.
    A halo around an angels head.

    So the picture looks blurry, but in fact is not, I thought this to but I just quickly zoomed in on my iPod and it was very well done, I said something similar in my first post. (No. 1)
     
  10. DawnOfNights

    DawnOfNights Shopkeep Stealer

    Messages:
    83
    Wow, I always wanted to see if it was possible to edit the shader, good job!

    PS: just to show off, i started speaking my first language when i was 9 months old and became bilingual at the age of 4 :P
    so i beat you all!

    But i still can't code :(
     
  11. MCrypa

    MCrypa Bison Rider

    Messages:
    559
    WHAT IS THIS MADNESS :3
     
  12. Asu

    Asu THD Team THD Team Forum Moderator

    Messages:
    1,578
    I'm very good for modding GML (Game Maker), batch too, a bit of C++, GLSL and Java.
    :bison: :skeleton: :zchicken::migrant:
    I want to learn how to modding Delphi or other...

    I tried to install an other shader, for bloom, but this doesn't work... I think i tried to install a non-global shader... I think..
     
  13. Brandon816

    Brandon816 Ballista Bolt Thrower

    Messages:
    262
    It's actually okay when not zoomed in, but could still use a little bit of de-fuzz. Keep working on it and you should be able to get something that looks nice, even close up.
     
  14. Boxpipe

    Boxpipe single, female, lawyer

    Messages:
    293
    Not trying to come off as an asshole but god damn, there was no coding done at ALL, all he did was read the comments and adjust those first 5 lines' values, anyone could've done it, so stop going on about how "I can't code but you damn well can".

    It's just silly.
     
    Arcite, Rayne and jerloch like this.
  15. Asu

    Asu THD Team THD Team Forum Moderator

    Messages:
    1,578
    Boxpipe, ....
    Me and my brother are coding a new shader, we are trying to make a bloom shader.
    Please don't yell on everyone without know what i can make... In minecraft i made a shader of : Bloom, Depth of field ( i used trigonometry with my brother ( 13 years and me 11 ):D ), amelioration of TimeOfDay, i'm modding epic mod for king arthur gold ( Cool shops :flex: , airplanes :flex: , Epic map generation :flex:), i'm modding a video game, because, Stop yell on all the world.. I repeat i'm 11, i can speak english more or lower correctly, i can make programs. Please, get informations before yell at people for nothing... ...
     
  16. MCrypa

    MCrypa Bison Rider

    Messages:
    559
    Typical:
    "I'm going to say I suck. That way, everyone will give me compliments"
     
    Worm likes this.
  17. Ranged66

    Ranged66 Bison Rider

    Messages:
    447
    i am 11, dutch, learned english at my 9-10th, know somewhat BASIC and a little more Visual Basic.
     
  18. Asu

    Asu THD Team THD Team Forum Moderator

    Messages:
    1,578
    Only a little people is <12 years, and a very very very little bit of people can make programs, but <12 years people modding... *invasion of very*..
    French is very hard to learn, because we can't really speak english when you are 11 and french...
     
  19. Worm

    Worm Derpship Commander Donator

    Messages:
    546
    I'm using optical glasses (im near-sighted) and that's raping my eyes. In bad way. Very bad way.
    Good if you could put a *bit* lower halo, beacuse it's hard to see for anyone who has optical glasses.
     
  20. Boxpipe

    Boxpipe single, female, lawyer

    Messages:
    293
    Please don't tell me how "great" you think you are, I really don't care, I'm simply pointing out that all you did was read the comments and tweak the 5 simple values provided which anyone could've done. Which doesn't make you some god-tier prodigy programmer who deserves all this praise.
     
    Rayne, Grindle, Arcite and 3 others like this.
Thread Status:
Not open for further replies.