Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330
- // Uniforms
- uniform mat4 matrixView;
- uniform sampler2D texture0;
- uniform vec3 materialAmbient;
- uniform vec3 materialDiffuse;
- uniform float time;
- uniform int upper;
- uniform int middle;
- uniform float shadowStrength;
- uniform bool brightnessTest;
- uniform bool bloomView;
- // Input Variables
- in vec4 color;
- in vec4 position;
- in vec3 normal;
- in vec2 texCoord0;
- // Output Variable
- out vec4 outColor;
- // point light declaration
- struct POINT
- {
- int on;
- vec3 position;
- vec3 diffuse;
- vec3 specular;
- };
- uniform POINT lightPoint;
- // point light function
- vec4 PointLight(POINT light)
- {
- // diffuse light
- vec4 color = vec4(0, 0, 0, 1);
- vec3 L = normalize((matrixView * vec4(light.position, 1)) - position).xyz;
- float NdotL = dot(L, normal);
- if (NdotL > 0)
- {
- color += vec4 (light.diffuse * materialDiffuse, 1) * NdotL;
- }
- else
- {
- // add slight extended lighting past cut-off point, totalling around 3/5ths of a sphere
- // immitating light bending in atmosphere.
- // increase positive NdotL multiplier to bring ratio closer to original cut-off
- // with this, increase -NdotL alpha multiplier to blend darker side to transparency
- color = vec4(materialDiffuse * light.diffuse, 1.0) * (NdotL * 1.0) - vec4(0.0, 0.0, 0.0, (-NdotL * 4.0));
- // sunset
- 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);
- }
- // specular specular
- //vec3 V = normalize(-position.xyz);
- //vec3 R = reflect(-L, finalNormal);
- //float RdotV = dot(R, V);
- //if (NdotL > 0 && RdotV > 0)
- //{
- // color += vec4(light.specular * materialSpecular * pow(RdotV, shininess), 1);
- //}
- return color;
- }
- void main(void)
- {
- outColor = color;
- if (lightPoint.on == 1) outColor += PointLight(lightPoint);
- // give the inner clouds .y value some 'bounce'
- //float frequency = 4.0;
- //float amplitude = 0.01;
- // perhaps too costly, moved equivelent to main.cpp
- //if (upper == 1) outColor *= texture(texture0, vec2(texCoord0.x + time / 300000.0, texCoord0.y));
- //if (middle == 1) outColor *= texture(texture0, vec2(texCoord0.x + time / 150000.0, texCoord0.y + amplitude * sin(texCoord0.x * frequency + time / 3000)));
- if (upper == 1) outColor *= texture(texture0, texCoord0);
- if (middle == 1) outColor *= texture(texture0, texCoord0);
- // brightness test for bloom PPE
- if (brightnessTest)
- {
- float brightness = dot(outColor.rgb, vec3(0.2126, 0.7152, 0.0722));
- if (brightness > 1.0) outColor = outColor;
- if (bloomView)
- {
- // in order for the brightness test to pass through the alpha parts atmosphere, it needs to be treated in the same way
- // as within the pointlight struct. where the light is closest, put alpha at 1, where the alpha of the atmosphere is 0
- // (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
- // IF THE VIEW IS INNER EARTH (bloomview = true)
- // ELSE give an alpha of 0 to be able to see through the atmopshere alpha
- vec3 L = normalize((matrixView * vec4(lightPoint.position, 1)) - position).xyz;
- float NdotL = dot(L, normal);
- if (NdotL > 0) outColor = vec4(0.0, 0.0, 0.0, 1.0);
- else outColor = vec4(0.0, 0.0, 0.0, 0.0);
- }
- if (!bloomView) outColor = vec4(0.0, 0.0, 0.0, 0.0);
- //outColor = vec4(0.0, 0.0, 0.0, 1.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement