Advertisement
Guest User

Untitled

a guest
Apr 1st, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 120
  2.  
  3. varying vec4 color;
  4. varying vec4 texcoord;
  5. varying vec4 lmcoord;
  6. varying vec3 worldPosition;
  7.  
  8.  
  9. attribute vec4 mc_Entity;
  10.  
  11. uniform int worldTime;
  12. uniform vec3 cameraPosition;
  13. uniform float frameTimeCounter;
  14. uniform float rainStrength;
  15. uniform mat4 gbufferModelView;
  16. uniform mat4 gbufferModelViewInverse;
  17. uniform mat4 shadowModelView;
  18. uniform mat4 shadowModelViewInverse;
  19. uniform mat4 gbufferProjection;
  20. uniform mat4 gbufferProjectionInverse;
  21.  
  22. uniform float aspectRatio;
  23.  
  24. uniform sampler2D noisetex;
  25.  
  26. varying vec3 normal;
  27. varying vec3 tangent;
  28. varying vec3 binormal;
  29. varying vec2 waves;
  30. varying vec3 worldNormal;
  31.  
  32. varying float distance;
  33. //varying float idCheck;
  34.  
  35. varying float materialIDs;
  36.  
  37. varying mat3 tbnMatrix;
  38. varying vec4 vertexPos;
  39. varying vec3 vertexViewVector;
  40.  
  41.  
  42. #define WAVING_GRASS
  43. #define WAVING_WHEAT
  44. #define WAVING_LEAVES
  45.  
  46. vec4 newpos(in vec4 orig){
  47.   float distortionScale = 0.45f;                 //change this when needed -- 0.0f - 1.0f is the sensible range
  48.   float n1, n2, n3;
  49.   vec4 noise = fract(sin(mat4(2.0f, 3.0f, 5.0f, 7.0f, 11.0f, 13.0f, 17.0f, 19.0f, 23.0f, 29.0f, 31.0f, 37.0f, 41.0f, 43.0f, 47.0f, 53.0f)*orig)*43758.5453f);
  50.   n1 = sqrt(-2.0f * log(noise.x)) * sin(6.2831853f*noise.y);
  51.   n2 = sqrt(-2.0f * log(noise.x)) * cos(6.2831853f*noise.y);
  52.   n3 = sqrt(-2.0f * log(noise.z)) * sin(6.2831853f*noise.w);
  53.   return clamp(0.16666666f*vec4(n1, n2, n3, 0.0f),-0.5f, 0.5f)*distortionScale;
  54. }
  55.  
  56. vec4 cubic(float x)
  57. {
  58.     float x2 = x * x;
  59.     float x3 = x2 * x;
  60.     vec4 w;
  61.     w.x =   -x3 + 3*x2 - 3*x + 1;
  62.     w.y =  3*x3 - 6*x2       + 4;
  63.     w.z = -3*x3 + 3*x2 + 3*x + 1;
  64.     w.w =  x3;
  65.     return w / 6.f;
  66. }
  67.  
  68. vec4 BicubicTexture(in sampler2D tex, in vec2 coord)
  69. {
  70.     int resolution = 64;
  71.  
  72.     coord *= resolution;
  73.  
  74.     float fx = fract(coord.x);
  75.     float fy = fract(coord.y);
  76.     coord.x -= fx;
  77.     coord.y -= fy;
  78.  
  79.     vec4 xcubic = cubic(fx);
  80.     vec4 ycubic = cubic(fy);
  81.  
  82.     vec4 c = vec4(coord.x - 0.5, coord.x + 1.5, coord.y - 0.5, coord.y + 1.5);
  83.     vec4 s = vec4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x + ycubic.y, ycubic.z + ycubic.w);
  84.     vec4 offset = c + vec4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) / s;
  85.  
  86.     vec4 sample0 = texture2D(tex, vec2(offset.x, offset.z) / resolution);
  87.     vec4 sample1 = texture2D(tex, vec2(offset.y, offset.z) / resolution);
  88.     vec4 sample2 = texture2D(tex, vec2(offset.x, offset.w) / resolution);
  89.     vec4 sample3 = texture2D(tex, vec2(offset.y, offset.w) / resolution);
  90.  
  91.     float sx = s.x / (s.x + s.y);
  92.     float sy = s.z / (s.z + s.w);
  93.  
  94.     return mix( mix(sample3, sample2, sx), mix(sample1, sample0, sx), sy);
  95. }
  96.  
  97.  
  98.  
  99.  
  100. //  vec4 result = mix(texCenter, texRight, vec4(f.x));
  101. //  return result;
  102. // }
  103.  
  104.  
  105. vec4 TextureSmooth(in sampler2D tex, in vec2 coord)
  106. {
  107.     int level = 0;
  108.     vec2 res = vec2(64.0f);
  109.     coord = coord * res;
  110.     vec2 i = floor(coord);
  111.     vec2 f = fract(coord);
  112.     f = f * f * (3.0f - 2.0f * f);
  113.     //f = 1.0f - (cos(f * 3.1415f) * 0.5f + 0.5f);
  114.  
  115.     //i -= vec2(0.5f);
  116.  
  117.     vec2 icoordCenter       = i / res;
  118.     vec2 icoordRight        = (i + vec2(1.0f, 0.0f)) / res;
  119.     vec2 icoordUp           = (i + vec2(0.0f, 1.0f)) / res;
  120.     vec2 icoordUpRight      = (i + vec2(1.0f, 1.0f)) / res;
  121.  
  122.  
  123.     vec4 texCenter  = texture2DLod(tex, icoordCenter,   level);
  124.     vec4 texRight   = texture2DLod(tex, icoordRight,    level);
  125.     vec4 texUp      = texture2DLod(tex, icoordUp,       level);
  126.     vec4 texUpRight = texture2DLod(tex, icoordUpRight,  level);
  127.  
  128.     texCenter = mix(texCenter, texUp, vec4(f.y));
  129.     texRight  = mix(texRight, texUpRight, vec4(f.y));
  130.  
  131.     vec4 result = mix(texCenter, texRight, vec4(f.x));
  132.     return result;
  133. }
  134.  
  135. float Impulse(in float x, in float k)
  136. {
  137.     float h = k*x;
  138.     return pow(h*exp(1.0f-h), 5.0f);
  139. }
  140.  
  141. float RepeatingImpulse(in float x, in float scale)
  142. {
  143.     float time = x;
  144.           time = mod(time, scale);
  145.  
  146.     return Impulse(time, 3.0f / scale);
  147. }
  148.  
  149. void main() {
  150.  
  151.  
  152.  
  153.     texcoord = gl_TextureMatrix[0] * gl_MultiTexCoord0;
  154.  
  155.     lmcoord = gl_TextureMatrix[1] * gl_MultiTexCoord1;
  156.    
  157.   //Calculate offset with trilinear interpolation from full block corners.
  158.   vec4 fg,ff,p1,p2,p3,p4,p5,p6,p7,p8,p12,p34,p56,p78,p1234,p5678,offset;
  159.   if (mc_Entity.x == 0.0) offset = vec4(0.0f); //Don't offset chests
  160.   else {
  161.     fg = floor(gl_Vertex);
  162.     ff = fract(gl_Vertex);
  163.     p1 = newpos(fg);
  164.     p2 = newpos(fg + vec4(1.0f, 0.0f, 0.0f, 0.0f));
  165.     p3 = newpos(fg + vec4(0.0f, 1.0f, 0.0f, 0.0f));
  166.     p4 = newpos(fg + vec4(1.0f, 1.0f, 0.0f, 0.0f));
  167.     p5 = newpos(fg + vec4(0.0f, 0.0f, 1.0f, 0.0f));
  168.     p6 = newpos(fg + vec4(1.0f, 0.0f, 1.0f, 0.0f));
  169.     p7 = newpos(fg + vec4(0.0f, 1.0f, 1.0f, 0.0f));
  170.     p8 = newpos(fg + vec4(1.0f, 1.0f, 1.0f, 0.0f));
  171.     p12    = p1    + (p2-p1)       * ff.x;
  172.     p34    = p3    + (p4-p3)       * ff.x;
  173.     p56    = p5    + (p6-p5)       * ff.x;
  174.     p78    = p7    + (p8-p7)       * ff.x;
  175.     p1234  = p12   + (p34-p12)     * ff.y;
  176.     p5678  = p56   + (p78-p56)     * ff.y;
  177.     offset = p1234 + (p5678-p1234) * ff.z;
  178.   }
  179.    
  180.     vec4 viewpos = gbufferModelViewInverse * gl_ModelViewMatrix * (gl_Vertex + offset);
  181.     vec4 position = viewpos;
  182.  
  183.     worldPosition = viewpos.xyz + cameraPosition.xyz;
  184.  
  185.    
  186.     //Entity checker
  187.     // if (mc_Entity.x == 1920.0f)
  188.     // {
  189.     //  texcoord.st = vec2(0.2f);
  190.     // }
  191.    
  192.     //Gather materials
  193.     materialIDs = 1.0f;
  194.  
  195.     //Grass
  196.     if  (  mc_Entity.x == 31.0
  197.  
  198.         || mc_Entity.x == 38.0f     //Rose
  199.         || mc_Entity.x == 37.0f     //Flower
  200.         || mc_Entity.x == 1925.0f   //Biomes O Plenty: Medium Grass
  201.         || mc_Entity.x == 1920.0f   //Biomes O Plenty: Thorns, barley
  202.         || mc_Entity.x == 1921.0f   //Biomes O Plenty: Sunflower
  203.  
  204.         )
  205.     {
  206.         materialIDs = max(materialIDs, 2.0f);
  207.     }
  208.    
  209.     //Wheat
  210.     if (mc_Entity.x == 59.0) {
  211.         materialIDs = max(materialIDs, 2.0f);
  212.     }  
  213.    
  214.     //Leaves
  215.     if   ( mc_Entity.x == 18.0
  216.  
  217.         || mc_Entity.x == 1962.0f //Biomes O Plenty: Leaves
  218.         || mc_Entity.x == 1924.0f //Biomes O Plenty: Leaves
  219.         || mc_Entity.x == 1923.0f //Biomes O Plenty: Leaves
  220.         || mc_Entity.x == 1926.0f //Biomes O Plenty: Leaves
  221.         || mc_Entity.x == 1936.0f //Biomes O Plenty: Giant Flower Leaves
  222.  
  223.          ) {
  224.         materialIDs = max(materialIDs, 3.0f);
  225.     }  
  226.  
  227.    
  228.     //Gold block
  229.     if (mc_Entity.x == 41) {
  230.         materialIDs = max(materialIDs, 20.0f);
  231.     }
  232.    
  233.     //Iron block
  234.     if (mc_Entity.x == 42) {
  235.         materialIDs = max(materialIDs, 21.0f);
  236.     }
  237.    
  238.     //Diamond Block
  239.     if (mc_Entity.x == 57) {
  240.         materialIDs = max(materialIDs, 22.0f);
  241.     }
  242.    
  243.     //Emerald Block
  244.     if (mc_Entity.x == -123) {
  245.         materialIDs = max(materialIDs, 23.0f);
  246.     }
  247.    
  248.    
  249.    
  250.     //sand
  251.     if (mc_Entity.x == 12) {
  252.         materialIDs = max(materialIDs, 24.0f);
  253.     }
  254.  
  255.     //sandstone
  256.     if (mc_Entity.x == 24 || mc_Entity.x == -128) {
  257.         materialIDs = max(materialIDs, 25.0f);
  258.     }
  259.    
  260.     //stone
  261.     if (mc_Entity.x == 1) {
  262.         materialIDs = max(materialIDs, 26.0f);
  263.     }
  264.    
  265.     //cobblestone
  266.     if (mc_Entity.x == 4) {
  267.         materialIDs = max(materialIDs, 27.0f);
  268.     }
  269.    
  270.     //wool
  271.     if (mc_Entity.x == 35) {
  272.         materialIDs = max(materialIDs, 28.0f);
  273.     }
  274.  
  275.  
  276.     //torch
  277.     if (mc_Entity.x == 50) {
  278.         materialIDs = max(materialIDs, 30.0f);
  279.     }
  280.  
  281.     //lava
  282.     if (mc_Entity.x == 10 || mc_Entity.x == 11) {
  283.         materialIDs = max(materialIDs, 31.0f);
  284.     }
  285.  
  286.     //glowstone and lamp
  287.     if (mc_Entity.x == 89 || mc_Entity.x == 124) {
  288.         materialIDs = max(materialIDs, 32.0f);
  289.     }
  290.  
  291.     //fire
  292.     if (mc_Entity.x == 51) {
  293.         materialIDs = max(materialIDs, 33.0f);
  294.     }
  295.  
  296.  
  297.  
  298.     float tick = frameTimeCounter;
  299.    
  300.    
  301. float grassWeight = mod(texcoord.t * 16.0f, 1.0f / 16.0f);
  302.  
  303. float lightWeight = clamp((lmcoord.t * 33.05f / 32.0f) - 1.05f / 32.0f, 0.0f, 1.0f);
  304.       lightWeight *= 1.1f;
  305.       lightWeight -= 0.1f;
  306.       lightWeight = max(0.0f, lightWeight);
  307.       lightWeight = pow(lightWeight, 5.0f);
  308.      
  309.       // if (texcoord.t < 0.65f) {
  310.       //    grassWeight = 1.0f;
  311.       // } else {
  312.       //    grassWeight = 0.0f;
  313.       // }   
  314.  
  315.       if (grassWeight < 0.01f) {
  316.         grassWeight = 1.0f;
  317.       } else {
  318.         grassWeight = 0.0f;
  319.       }
  320.  
  321. const float pi = 3.14159265f;
  322.  
  323. position.xyz += cameraPosition.xyz;
  324.    
  325. #ifdef WAVING_GRASS
  326.     //Waving grass
  327.     if (materialIDs == 2.0f)
  328.     {
  329.         vec2 angleLight = vec2(0.0f);
  330.         vec2 angleHeavy = vec2(0.0f);
  331.         vec2 angle      = vec2(0.0f);
  332.  
  333.         vec3 pn0 = position.xyz;
  334.              pn0.x -= frameTimeCounter / 3.0f;
  335.  
  336.         vec3 stoch = BicubicTexture(noisetex, pn0.xz / 64.0f).xyz;
  337.         vec3 stochLarge = BicubicTexture(noisetex, position.xz / (64.0f * 6.0f)).xyz;
  338.  
  339.         vec3 pn = position.xyz;
  340.              pn.x *= 2.0f;
  341.              pn.x -= frameTimeCounter * 15.0f;
  342.              pn.z *= 8.0f;
  343.  
  344.         vec3 stochLargeMoving = BicubicTexture(noisetex, pn.xz / (64.0f * 10.0f)).xyz;
  345.  
  346.  
  347.  
  348.         vec3 p = position.xyz;
  349.              p.x += sin(p.z / 2.0f) * 1.0f;
  350.              p.xz += stochLarge.rg * 5.0f;
  351.  
  352.         float windStrength = mix(0.85f, 1.0f, rainStrength);
  353.         float windStrengthRandom = stochLargeMoving.x;
  354.               windStrengthRandom = pow(windStrengthRandom, mix(2.0f, 1.0f, rainStrength));
  355.               windStrength *= mix(windStrengthRandom, 0.5f, rainStrength * 0.25f);
  356.               //windStrength = 1.0f;
  357.  
  358.         //heavy wind
  359.         float heavyAxialFrequency           = 8.0f;
  360.         float heavyAxialWaveLocalization    = 0.9f;
  361.         float heavyAxialRandomization       = 13.0f;
  362.         float heavyAxialAmplitude           = 15.0f;
  363.         float heavyAxialOffset              = 15.0f;
  364.  
  365.         float heavyLateralFrequency         = 6.732f;
  366.         float heavyLateralWaveLocalization  = 1.274f;
  367.         float heavyLateralRandomization     = 1.0f;
  368.         float heavyLateralAmplitude         = 6.0f;
  369.         float heavyLateralOffset            = 0.0f;
  370.  
  371.         //light wind
  372.         float lightAxialFrequency           = 5.5f;
  373.         float lightAxialWaveLocalization    = 1.1f;
  374.         float lightAxialRandomization       = 21.0f;
  375.         float lightAxialAmplitude           = 5.0f;
  376.         float lightAxialOffset              = 5.0f;
  377.  
  378.         float lightLateralFrequency         = 5.9732f;
  379.         float lightLateralWaveLocalization  = 1.174f;
  380.         float lightLateralRandomization     = 0.0f;
  381.         float lightLateralAmplitude         = 1.0f;
  382.         float lightLateralOffset            = 0.0f;
  383.  
  384.         float windStrengthCrossfade = clamp(windStrength * 2.0f - 1.0f, 0.0f, 1.0f);
  385.         float lightWindFade = clamp(windStrength * 2.0f, 0.2f, 1.0f);
  386.  
  387.         angleLight.x += sin(frameTimeCounter * lightAxialFrequency      - p.x * lightAxialWaveLocalization      + stoch.x * lightAxialRandomization)    * lightAxialAmplitude       + lightAxialOffset;
  388.         angleLight.y += sin(frameTimeCounter * lightLateralFrequency    - p.x * lightLateralWaveLocalization    + stoch.x * lightLateralRandomization)  * lightLateralAmplitude     + lightLateralOffset;
  389.  
  390.         angleHeavy.x += sin(frameTimeCounter * heavyAxialFrequency      - p.x * heavyAxialWaveLocalization      + stoch.x * heavyAxialRandomization)    * heavyAxialAmplitude       + heavyAxialOffset;
  391.         angleHeavy.y += sin(frameTimeCounter * heavyLateralFrequency    - p.x * heavyLateralWaveLocalization    + stoch.x * heavyLateralRandomization)  * heavyLateralAmplitude     + heavyLateralOffset;
  392.  
  393.         angle = mix(angleLight * lightWindFade, angleHeavy, vec2(windStrengthCrossfade));
  394.         angle *= 2.0f;
  395.  
  396.         // //Rotate block pivoting from bottom based on angle
  397.         position.x += (sin((angle.x / 180.0f) * 3.141579f)) * grassWeight * lightWeight                     * 1.0f  ;
  398.         position.z += (sin((angle.y / 180.0f) * 3.141579f)) * grassWeight * lightWeight                     * 1.0f  ;
  399.         position.y += (cos(((angle.x + angle.y) / 180.0f) * 3.141579f) - 1.0f)  * grassWeight * lightWeight * 1.0f  ;
  400.     }
  401.    
  402. #endif 
  403.  
  404.  
  405.  
  406. #ifdef WAVING_WHEAT
  407. //Wheat//
  408.     if (mc_Entity.x == 59.0 && texcoord.t < 0.35) {
  409.         float speed = 0.1;
  410.        
  411.         float magnitude = sin((tick * pi / (28.0)) + position.x + position.z) * 0.12 + 0.02;
  412.               magnitude *= grassWeight * 0.2f;
  413.               magnitude *= lightWeight;
  414.         float d0 = sin(tick * pi / (122.0 * speed)) * 3.0 - 1.5 + position.z;
  415.         float d1 = sin(tick * pi / (152.0 * speed)) * 3.0 - 1.5 + position.x;
  416.         float d2 = sin(tick * pi / (122.0 * speed)) * 3.0 - 1.5 + position.x;
  417.         float d3 = sin(tick * pi / (152.0 * speed)) * 3.0 - 1.5 + position.z;
  418.         position.x += sin((tick * pi / (28.0 * speed)) + (position.x + d0) * 0.1 + (position.z + d1) * 0.1) * magnitude;
  419.         position.z += sin((tick * pi / (28.0 * speed)) + (position.z + d2) * 0.1 + (position.x + d3) * 0.1) * magnitude;
  420.     }
  421.    
  422.     //small leaf movement
  423.     if (mc_Entity.x == 59.0 && texcoord.t < 0.35) {
  424.         float speed = 0.04;
  425.        
  426.         float magnitude = (sin(((position.y + position.x)/2.0 + tick * pi / ((28.0)))) * 0.025 + 0.075) * 0.2;
  427.               magnitude *= grassWeight;
  428.               magnitude *= lightWeight;
  429.         float d0 = sin(tick * pi / (112.0 * speed)) * 3.0 - 1.5;
  430.         float d1 = sin(tick * pi / (142.0 * speed)) * 3.0 - 1.5;
  431.         float d2 = sin(tick * pi / (112.0 * speed)) * 3.0 - 1.5;
  432.         float d3 = sin(tick * pi / (142.0 * speed)) * 3.0 - 1.5;
  433.         position.x += sin((tick * pi / (18.0 * speed)) + (-position.x + d0)*1.6 + (position.z + d1)*1.6) * magnitude * (1.0f + rainStrength * 2.0f);
  434.         position.z += sin((tick * pi / (18.0 * speed)) + (position.z + d2)*1.6 + (-position.x + d3)*1.6) * magnitude * (1.0f + rainStrength * 2.0f);
  435.         position.y += sin((tick * pi / (11.0 * speed)) + (position.z + d2) + (position.x + d3)) * (magnitude/3.0) * (1.0f + rainStrength * 2.0f);
  436.     }
  437.  
  438.  
  439.  
  440. #endif
  441.    
  442.    
  443.  
  444. #ifdef WAVING_LEAVES
  445. //Leaves//
  446.        
  447.     if (materialIDs == 3.0f && texcoord.t < 1.90 && texcoord.t > -1.0) {
  448.         float speed = 0.05;
  449.  
  450.  
  451.               //lightWeight = max(0.0f, 1.0f - (lightWeight * 5.0f));
  452.        
  453.         float magnitude = (sin((position.y + position.x + tick * pi / ((28.0) * speed))) * 0.15 + 0.15) * 0.30 * lightWeight;
  454.               magnitude *= grassWeight;
  455.               magnitude *= lightWeight;
  456.         float d0 = sin(tick * pi / (112.0 * speed)) * 3.0 - 1.5;
  457.         float d1 = sin(tick * pi / (142.0 * speed)) * 3.0 - 1.5;
  458.         float d2 = sin(tick * pi / (132.0 * speed)) * 3.0 - 1.5;
  459.         float d3 = sin(tick * pi / (122.0 * speed)) * 3.0 - 1.5;
  460.         position.x += sin((tick * pi / (18.0 * speed)) + (-position.x + d0)*1.6 + (position.z + d1)*1.6) * magnitude * (1.0f + rainStrength * 1.0f);
  461.         position.z += sin((tick * pi / (17.0 * speed)) + (position.z + d2)*1.6 + (-position.x + d3)*1.6) * magnitude * (1.0f + rainStrength * 1.0f);
  462.         position.y += sin((tick * pi / (11.0 * speed)) + (position.z + d2) + (position.x + d3)) * (magnitude/2.0) * (1.0f + rainStrength * 1.0f);
  463.        
  464.     }
  465.    
  466.  
  467.     //lower leaf movement
  468.     if (materialIDs == 3.0f) {
  469.         float speed = 0.075;
  470.  
  471.  
  472.        
  473.         float magnitude = (sin((tick * pi / ((28.0) * speed))) * 0.05 + 0.15) * 0.075 * lightWeight;
  474.               magnitude *= 1.0f - grassWeight;
  475.               magnitude *= lightWeight;
  476.         float d0 = sin(tick * pi / (122.0 * speed)) * 3.0 - 1.5;
  477.         float d1 = sin(tick * pi / (142.0 * speed)) * 3.0 - 1.5;
  478.         float d2 = sin(tick * pi / (162.0 * speed)) * 3.0 - 1.5;
  479.         float d3 = sin(tick * pi / (112.0 * speed)) * 3.0 - 1.5;
  480.         position.x += sin((tick * pi / (13.0 * speed)) + (position.x + d0)*0.9 + (position.z + d1)*0.9) * magnitude;
  481.         position.z += sin((tick * pi / (16.0 * speed)) + (position.z + d2)*0.9 + (position.x + d3)*0.9) * magnitude;
  482.         position.y += sin((tick * pi / (15.0 * speed)) + (position.z + d2) + (position.x + d3)) * (magnitude/1.0);
  483.     }
  484.  
  485. #endif 
  486.  
  487.     vec4 locposition = gl_ModelViewMatrix * gl_Vertex;
  488.    
  489.     distance = sqrt(locposition.x * locposition.x + locposition.y * locposition.y + locposition.z * locposition.z);
  490.  
  491.     position.xyz -= cameraPosition.xyz;
  492.  
  493.  
  494.     gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
  495.    
  496.  
  497.  
  498.  
  499.     color = gl_Color;
  500.  
  501.     // float colorDiff = abs(color.r - color.g);
  502.     //    colorDiff += abs(color.r - color.b);
  503.     //    colorDiff += abs(color.g - color.b);
  504.  
  505.     // if (colorDiff < 0.001f && mc_Entity.x != -1.0f && mc_Entity.x != 63 && mc_Entity.x != 68 && mc_Entity.x != 323) {
  506.  
  507.     //  float lum = color.r + color.g + color.b;
  508.     //        lum /= 3.0f;
  509.  
  510.     //  if (lum < 0.92f) {
  511.     //      color.rgb = vec3(1.0f);
  512.     //  }
  513.  
  514.     // }   
  515.    
  516.     gl_FogFragCoord = gl_Position.z;
  517.    
  518.    
  519.     normal = normalize(gl_NormalMatrix * gl_Normal);
  520.     worldNormal = gl_Normal;
  521.  
  522.     //if(distance < 80.0f){
  523.         if (gl_Normal.x > 0.5) {
  524.             //  1.0,  0.0,  0.0
  525.             tangent  = normalize(gl_NormalMatrix * vec3( 0.0,  0.0,  1.0));
  526.             binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0,  0.0));
  527.         } else if (gl_Normal.x < -0.5) {
  528.             // -1.0,  0.0,  0.0
  529.             tangent  = normalize(gl_NormalMatrix * vec3( 0.0,  0.0,  1.0));
  530.             binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0,  0.0));
  531.         } else if (gl_Normal.y > 0.5) {
  532.             //  0.0,  1.0,  0.0
  533.             tangent  = normalize(gl_NormalMatrix * vec3( 1.0,  0.0,  0.0));
  534.             binormal = normalize(gl_NormalMatrix * vec3( 0.0,  0.0,  1.0));
  535.         } else if (gl_Normal.y < -0.5) {
  536.             //  0.0, -1.0,  0.0
  537.             tangent  = normalize(gl_NormalMatrix * vec3( 1.0,  0.0,  0.0));
  538.             binormal = normalize(gl_NormalMatrix * vec3( 0.0,  0.0,  1.0));
  539.         } else if (gl_Normal.z > 0.5) {
  540.             //  0.0,  0.0,  1.0
  541.             tangent  = normalize(gl_NormalMatrix * vec3( 1.0,  0.0,  0.0));
  542.             binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0,  0.0));
  543.         } else if (gl_Normal.z < -0.5) {
  544.             //  0.0,  0.0, -1.0
  545.             tangent  = normalize(gl_NormalMatrix * vec3( 1.0,  0.0,  0.0));
  546.             binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0,  0.0));
  547.         }
  548.     //}
  549.  
  550.    
  551.     tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
  552.                      tangent.y, binormal.y, normal.y,
  553.                      tangent.z, binormal.z, normal.z);
  554.  
  555.     vertexPos = gl_Vertex; 
  556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement