Advertisement
Guest User

Untitled

a guest
Apr 10th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. #version 330
  2.  
  3. // Uniforms
  4. uniform mat4 matrixView;
  5. uniform sampler2D texture0;
  6.  
  7. uniform vec3 materialAmbient;
  8. uniform vec3 materialDiffuse;
  9.  
  10. uniform float time;
  11. uniform int upper;
  12. uniform int middle;
  13. uniform float shadowStrength;
  14. uniform bool brightnessTest;
  15. uniform bool bloomView;
  16.  
  17. // Input Variables
  18. in vec4 color;
  19. in vec4 position;
  20. in vec3 normal;
  21. in vec2 texCoord0;
  22.  
  23. // Output Variable
  24. out vec4 outColor;
  25.  
  26.  
  27.  
  28.  
  29. // point light declaration
  30. struct POINT
  31. {
  32. int on;
  33. vec3 position;
  34. vec3 diffuse;
  35. vec3 specular;
  36. };
  37. uniform POINT lightPoint;
  38.  
  39.  
  40.  
  41.  
  42. // point light function
  43. vec4 PointLight(POINT light)
  44. {
  45.  
  46. // diffuse light
  47. vec4 color = vec4(0, 0, 0, 1);
  48. vec3 L = normalize((matrixView * vec4(light.position, 1)) - position).xyz;
  49. float NdotL = dot(L, normal);
  50. if (NdotL > 0)
  51. {
  52. color += vec4 (light.diffuse * materialDiffuse, 1) * NdotL;
  53. }
  54. else
  55. {
  56. // add slight extended lighting past cut-off point, totalling around 3/5ths of a sphere
  57. // immitating light bending in atmosphere.
  58. // increase positive NdotL multiplier to bring ratio closer to original cut-off
  59. // with this, increase -NdotL alpha multiplier to blend darker side to transparency
  60. color = vec4(materialDiffuse * light.diffuse, 1.0) * (NdotL * 1.0) - vec4(0.0, 0.0, 0.0, (-NdotL * 4.0));
  61. // sunset
  62. color += vec4(clamp(0.0 - (NdotL * 2.0), 0.0, 0.3), clamp(0.0 - (NdotL * 2.0), 0.0, 0.07), 0.0, 0.0);
  63. }
  64.  
  65. // specular specular
  66. //vec3 V = normalize(-position.xyz);
  67. //vec3 R = reflect(-L, finalNormal);
  68. //float RdotV = dot(R, V);
  69. //if (NdotL > 0 && RdotV > 0)
  70. //{
  71. // color += vec4(light.specular * materialSpecular * pow(RdotV, shininess), 1);
  72. //}
  73.  
  74. return color;
  75. }
  76.  
  77.  
  78.  
  79. void main(void)
  80. {
  81. outColor = color;
  82.  
  83. if (lightPoint.on == 1) outColor += PointLight(lightPoint);
  84.  
  85. // give the inner clouds .y value some 'bounce'
  86. //float frequency = 4.0;
  87. //float amplitude = 0.01;
  88.  
  89. // perhaps too costly, moved equivelent to main.cpp
  90. //if (upper == 1) outColor *= texture(texture0, vec2(texCoord0.x + time / 300000.0, texCoord0.y));
  91. //if (middle == 1) outColor *= texture(texture0, vec2(texCoord0.x + time / 150000.0, texCoord0.y + amplitude * sin(texCoord0.x * frequency + time / 3000)));
  92.  
  93. if (upper == 1) outColor *= texture(texture0, texCoord0);
  94. if (middle == 1) outColor *= texture(texture0, texCoord0);
  95.  
  96. // brightness test for bloom PPE
  97. if (brightnessTest)
  98. {
  99. float brightness = dot(outColor.rgb, vec3(0.2126, 0.7152, 0.0722));
  100. if (brightness > 1.0) outColor = outColor;
  101. if (bloomView)
  102. {
  103. // in order for the brightness test to pass through the alpha parts atmosphere, it needs to be treated in the same way
  104. // as within the pointlight struct. where the light is closest, put alpha at 1, where the alpha of the atmosphere is 0
  105. // (dark side of the planet) give it an alpha of 0 in the brightness test, to give chance for the earth lights to pass the brightness test
  106. // IF THE VIEW IS INNER EARTH (bloomview = true)
  107. // ELSE give an alpha of 0 to be able to see through the atmopshere alpha
  108. vec3 L = normalize((matrixView * vec4(lightPoint.position, 1)) - position).xyz;
  109. float NdotL = dot(L, normal);
  110.  
  111. if (NdotL > 0) outColor = vec4(0.0, 0.0, 0.0, 1.0);
  112. else outColor = vec4(0.0, 0.0, 0.0, 0.0);
  113. }
  114. if (!bloomView) outColor = vec4(0.0, 0.0, 0.0, 0.0);
  115. //outColor = vec4(0.0, 0.0, 0.0, 1.0);
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement