Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const GLchar *vertSource = \
  2.         "#version 110\n"
  3.         "\n"
  4.         "attribute vec3 Vert;\n"
  5.         "attribute vec2 TexCoords;\n"
  6.         "attribute vec2 LMCoords;\n"
  7.         "\n"
  8.         "varying float FogFragCoord;\n"
  9.         "varying vec2 tc_tex; varying vec2 tc_lm;"
  10.         "\n"
  11.         "void main()\n"
  12.         "{\n"
  13.         "   tc_tex = TexCoords;\n"
  14.         "   tc_lm = LMCoords;\n"
  15.         "   gl_Position = gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);\n"
  16.         "   FogFragCoord = gl_Position.w;\n"
  17.         "}\n";
  18.    
  19.     const GLchar *fragSource = \
  20.         "#version 110\n"
  21.         "\n"
  22.         "uniform sampler2D Tex;\n"
  23.         "uniform sampler2D LMTex;\n"
  24.         "uniform sampler2D FullbrightTex;\n"
  25.         "uniform bool UseFullbrightTex;\n"
  26.         "uniform bool UseOverbright;\n"
  27.         "uniform bool UseAlphaTest;\n"
  28.         "uniform float Alpha;\n"
  29.         "\n"
  30.         "varying float FogFragCoord;\n"
  31.         "varying vec2 tc_tex; varying vec2 tc_lm;"
  32.         "\n"
  33.         "void main()\n"
  34.         "{\n"
  35.         "   vec4 result = texture2D(Tex, tc_tex.xy);\n"
  36.         "   if (UseAlphaTest && (result.a < 0.666))\n"
  37.         "       discard;\n"
  38.         "   result *= texture2D(LMTex, tc_lm.xy);\n"
  39.         "   if (UseOverbright)\n"
  40.         "       result.rgb *= 2.0;\n"
  41.         "   if (UseFullbrightTex)\n"
  42.         "       result += texture2D(FullbrightTex, tc_tex.xy);\n"
  43.         "   result = clamp(result, 0.0, 1.0);\n"
  44.         "   float fog = exp(-gl_Fog.density * gl_Fog.density * FogFragCoord * FogFragCoord);\n"
  45.         "   fog = clamp(fog, 0.0, 1.0);\n"
  46.         "   result = mix(gl_Fog.color, result, fog);\n"
  47.         "   result.a = Alpha;\n" // FIXME: This will make almost transparent things cut holes though heavy fog
  48.         "   gl_FragColor = result;\n"
  49.         "}\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement