公业员吧 关注:126贴子:4,626
大家拿这个源码去做shaders吧,不谢.


IP属地:安徽来自Android客户端1楼2016-02-27 19:05回复
    float signOf(float x){
    if(x >= 0.0){return 1.0;}
    return 0.0;
    }
    const vec3 lightDir = vec3(-1.0, -0.0, -1.0);
    highp float randff(highp float n){
    return fract(sin(n) * 3782.288); //fract(sin(n) * 3782.0);
    }
    highp float cos_between_vecs(highp vec3 v1, highp vec3 v2){
    return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) / length(v1) / length(v2);
    }
    highp float CalcLightByNormal(highp vec3 lightdir, highp vec3 normal){
    return min(1.0, acos(cos_between_vecs(lightdir, normal)) / 3.14195);
    }
    vec4 AddLight(vec4 texcolor, vec4 lightmap, float light, float shadow){
    vec4 ambient = texcolor * lightmap;
    vec4 torch = texcolor * vec4(1.0, light * light, 0.0, 1.0);
    vec4 fog = vec4(1.0, min(1.0, sqrt(light)), 0.2, 1.0);
    if(shadow < 0.05){light = 0.0; ambient *= 1.1;}
    return mix(ambient, torch, light) + fog * light * 0.5;
    }
    highp float smoothrand(highp float pos){
    highp float start = floor(pos);
    #ifdef FANCY
    highp float smooth = smoothstep(0.0, 1.0, fract(pos));
    #else
    highp float smooth = fract(pos);
    #endif
    return mix(randff(start), randff(start + 1.0), smooth);
    }
    highp float smoothrand2d(highp float horizont, highp float forward){
    highp float start = floor(forward);
    #ifdef FANCY
    highp float smooth = smoothstep(0.0, 1.0, fract(forward));
    #else
    highp float smooth = fract(forward);
    #endif
    return mix(smoothrand(horizont + randff(start) * 1000.0), smoothrand(horizont + randff(start + 1.0) * 1000.0), smooth);
    }
    highp float CheapWaterMap(highp vec3 pos){
    pos.z += TIME * 0.4;
    highp float wave1 = smoothrand2d(pos.z, pos.x / 6.0);
    highp float wave2 = sin(wave1) * 0.5 + 0.5;
    float interp = sin(TIME * 3.0 + sin(pos.z * 0.3728) + sin(pos.x * 0.4264)) * 0.5 + 0.5;
    return mix(wave1, wave2, interp);
    }
    highp vec3 WaterNormalMap(highp vec3 pos){
    highp float value = (CheapWaterMap(pos + vec3(0.0, 0.0, 0.1)) - CheapWaterMap(pos)) * 7.5;
    return vec3(0.0, 1.0, -value);
    }


    IP属地:安徽来自Android客户端2楼2016-02-27 19:05
    回复
      三楼


      IP属地:安徽来自Android客户端3楼2016-02-27 19:05
      回复
        at


        IP属地:安徽来自Android客户端4楼2016-02-27 19:05
        收起回复
          绅士席


          IP属地:安徽来自Android客户端5楼2016-02-27 19:09
          收起回复
            看不懂有什么用                   欢迎大家加入反我的世界盒子m社吧,此处是黑炸妈盒子的最佳选择,连接:http://tieba.baidu.com/f?kw=%B7%B4%CE%D2%B5%C4%CA%C0%BD%E7%BA%D0%D7%D3m%C9%E7&pn=0&
               ḻ͔̦͎̯͍̦͕̊̅ͦ͛͂̍͐̑̔͛̚̕͘k̨͎̳͈̫̫̤̙̪̞̦̳͙̭͓̜̙̞̄̽̊͐̍̓̋͊̎͘ͅa̩̮̘̗͈͙̠̲̠̹̹͚̣̜͖̳̞͇͂͊͒̈́̽̏ͮ̑́̉̾ͣ̽͆̀͘͟͢j̧̛͕̻̻̯̤̹̮̤ͬ̿ͮ͌̔ͧͤ͌ͤͭ͆ͤ̍͜͡fͭͨ̓͋̊҉̸̡̡̮̪͉̣͉̣͇͖̪͖̲͚l͌̎̑ͣͣ̏̀̈́̄͏̶̷̧͇̻̱̰́k̛̯̝͔̰̬̱͔̲̠̤̠̝͚͎͉ͭ͑ͫ̆̉̓;̷̸̨̀͒̏̃ͦ̈́̾̀́̎͢҉͚̼͉s̵͖̺̥͔͇̰̹̮͙͉̻̼̭̻͕̮͇ͨͬͪ͗̇̑̽͋̀j̶̋̊͌ͧͨͭ̓̅͐ͥ̂̔̊ͧ͊҉̶̵̞̩̦̳̺̳̬a̷̬̩̣̫͇̯̥ͯ̽͌̔ͪͯ́́͠l͖͍͕̠̦̼̗͋̍ͨ͘͜k̿̿̎͒ͤ̓̅̀͂ͧ͋̏ͫͣ̔͏̶̥̺͓̘̺͘ḑ̵͎̜̥͕͈̝̫͎̺̮̱̤̠̠͖̳ͮͧͫ͂͒ͤͣ̌̽ͨͪ͒̚͘͘͟j̸̧̻̥̣̪͍͕͇̮͙̹̪̄̄̉̒̊ͩ̅͆̚͟͝ͅf͈̼̩̯̒̎̇̆͆ͪ̈́͛̉̍̏́̄̈́̽̔̍̎̂͘͠n̸̸̡̛̪͕̯̫̹̥͔͚͙̦̩ͬ̆͗͌̔ͫ͆̀́͑̈́ͤ́ͯ̇ͧ͞s̶͚̭̥͉̰̝̺͍̭̤̹̘̮̪͖͖͉̲̾͂̐̋̉̊ͦͥ͘͢a̸̛̯͕̜̭̙̺̬ͫͧ͆ͨ͘͟͝ͅͅḻ͔̦͎̯͍̦͕̊̅ͦ͛͂̍͐̑̔͛̚̕͘k̨͎̳͈̫̫̤̙̪̞̦̳͙̭͓̜̙̞̄̽̊͐̍̓̋͊̎͘ͅ
               --来自tfy十客户端


            IP属地:湖北来自Android客户端6楼2016-02-27 19:09
            收起回复

                                 欢迎大家加入反我的世界盒子m社吧,此处是黑炸妈盒子的最佳选择,连接:http://tieba.baidu.com/f?kw=%B7%B4%CE%D2%B5%C4%CA%C0%BD%E7%BA%D0%D7%D3m%C9%E7&pn=0&
                 ḻ͔̦͎̯͍̦͕̊̅ͦ͛͂̍͐̑̔͛̚̕͘k̨͎̳͈̫̫̤̙̪̞̦̳͙̭͓̜̙̞̄̽̊͐̍̓̋͊̎͘ͅa̩̮̘̗͈͙̠̲̠̹̹͚̣̜͖̳̞͇͂͊͒̈́̽̏ͮ̑́̉̾ͣ̽͆̀͘͟͢j̧̛͕̻̻̯̤̹̮̤ͬ̿ͮ͌̔ͧͤ͌ͤͭ͆ͤ̍͜͡fͭͨ̓͋̊҉̸̡̡̮̪͉̣͉̣͇͖̪͖̲͚l͌̎̑ͣͣ̏̀̈́̄͏̶̷̧͇̻̱̰́k̛̯̝͔̰̬̱͔̲̠̤̠̝͚͎͉ͭ͑ͫ̆̉̓;̷̸̨̀͒̏̃ͦ̈́̾̀́̎͢҉͚̼͉s̵͖̺̥͔͇̰̹̮͙͉̻̼̭̻͕̮͇ͨͬͪ͗̇̑̽͋̀j̶̋̊͌ͧͨͭ̓̅͐ͥ̂̔̊ͧ͊҉̶̵̞̩̦̳̺̳̬a̷̬̩̣̫͇̯̥ͯ̽͌̔ͪͯ́́͠l͖͍͕̠̦̼̗͋̍ͨ͘͜k̿̿̎͒ͤ̓̅̀͂ͧ͋̏ͫͣ̔͏̶̥̺͓̘̺͘ḑ̵͎̜̥͕͈̝̫͎̺̮̱̤̠̠͖̳ͮͧͫ͂͒ͤͣ̌̽ͨͪ͒̚͘͘͟j̸̧̻̥̣̪͍͕͇̮͙̹̪̄̄̉̒̊ͩ̅͆̚͟͝ͅf͈̼̩̯̒̎̇̆͆ͪ̈́͛̉̍̏́̄̈́̽̔̍̎̂͘͠n̸̸̡̛̪͕̯̫̹̥͔͚͙̦̩ͬ̆͗͌̔ͫ͆̀́͑̈́ͤ́ͯ̇ͧ͞s̶͚̭̥͉̰̝̺͍̭̤̹̘̮̪͖͖͉̲̾͂̐̋̉̊ͦͥ͘͢a̸̛̯͕̜̭̙̺̬ͫͧ͆ͨ͘͟͝ͅͅḻ͔̦͎̯͍̦͕̊̅ͦ͛͂̍͐̑̔͛̚̕͘k̨͎̳͈̫̫̤̙̪̞̦̳͙̭͓̜̙̞̄̽̊͐̍̓̋͊̎͘ͅ
                 --来自tfy十客户端


              IP属地:湖北来自Android客户端7楼2016-02-27 19:10
              回复


                IP属地:安徽来自Android客户端8楼2016-02-27 19:11
                回复
                  加精@java爱


                  IP属地:安徽来自Android客户端9楼2016-02-27 19:11
                  回复
                    不知不觉6级了


                    IP属地:安徽来自Android客户端10楼2016-02-27 19:12
                    收起回复
                      干啥的


                      来自Android客户端11楼2016-02-27 19:13
                      收起回复


                        来自Android客户端12楼2016-02-27 20:07
                        收起回复
                          蜜汁被@


                          IP属地:广东13楼2016-02-27 21:28
                          回复
                            完全看不懂的路过...(´-﹏-`;)


                            IP属地:重庆来自Android客户端14楼2016-02-27 21:34
                            收起回复
                              这什么奇怪的东西,我什么都不会,别叫我


                              15楼2016-02-27 21:48
                              收起回复