terravisor/shaders/fragment.glsl

79 lines
2.2 KiB
Plaintext
Raw Normal View History

2024-08-15 13:53:52 -04:00
#version 450 core
in vec3 fragPosition;
out vec4 FragColor;
void main() {
FragColor = vec4(fragPosition * 0.5f + 0.5f, 1.0f);
}
// layout(binding = 0) uniform sampler2D heightTexture;
// layout(location = 1) uniform float time;
// layout(std140, binding = 0) uniform SceneUniforms
// {
// mat4 PV; //camera projection * view matrix
// vec4 eye_w; //world-space eye position
// };
// layout(std140, binding = 1) uniform LightUniforms
// {
// vec4 La; //ambient light color
// vec4 Ld; //diffuse light color
// vec4 Ls; //specular light color
// vec4 light_w; //world-space light position
// };
// layout(std140, binding = 2) uniform MaterialUniforms
// {
// vec4 ka; //ambient material color
// vec4 kd; //diffuse material color
// vec4 ks; //specular material color
// float shininess; //specular exponent
// };
// in vec3 frag_position;
// in VertexData {
// vec2 tex_coord;
// } inData;
// out vec4 frag_color; //the output color for this fragment
// void main(void)
// {
// //Compute per-fragment Phong lighting
// // vec4 ktex = vec4(vec3(texture(heightTexture, inData.tex_coord).r, 1.0);
2024-08-13 18:09:49 -04:00
2024-08-15 13:53:52 -04:00
// // vec4 ambient_term = ka*ktex*La;
2024-08-12 21:40:37 -04:00
2024-08-15 13:53:52 -04:00
// // const float eps = 1e-8; //small value to avoid division by 0
// // float d = distance(light_w.xyz, inData.pw.xyz);
// // float atten = 1.0/(d*d+eps); //d-squared attenuation
2024-08-12 21:40:37 -04:00
2024-08-15 13:53:52 -04:00
// // vec3 nw = normalize(inData.nw); //world-space unit normal vector
// // vec3 lw = normalize(light_w.xyz - inData.pw.xyz); //world-space unit light vector
// // vec4 diffuse_term = atten*kd*ktex*Ld*max(0.0, dot(nw, lw));
2024-08-12 21:40:37 -04:00
2024-08-15 13:53:52 -04:00
// // vec3 vw = normalize(eye_w.xyz - inData.pw.xyz); //world-space unit view vector
// // vec3 rw = reflect(-lw, nw); //world-space unit reflection vector
2024-08-12 21:40:37 -04:00
2024-08-15 13:53:52 -04:00
// // vec4 specular_term = atten*ks*Ls*pow(max(0.0, dot(rw, vw)), shininess);
2024-08-12 21:40:37 -04:00
2024-08-15 13:53:52 -04:00
// // frag_color = ambient_term + diffuse_term + specular_term;
2024-08-15 00:56:29 -04:00
2024-08-15 13:53:52 -04:00
// float height = texture(heightTexture, inData.tex_coord).r;
2024-08-15 00:56:29 -04:00
2024-08-15 13:53:52 -04:00
// //frag_color = vec4(inData.tex_coord, 0.0f, 1.0f);
2024-08-15 00:56:29 -04:00
2024-08-15 13:53:52 -04:00
// // if (height > 0.8) frag_color = vec4(vec3(1.0f-height), 1.0f);
// // else frag_color = vec4(vec3(height), 1.0f);
// frag_color = vec4(height, height, height, 1.0);
// }
2024-08-12 21:40:37 -04:00