Infinite terrain
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 color;
|
||||
|
||||
in vec3 position_pass;
|
||||
in vec3 camera_position_pass;
|
||||
in vec3 normal_pass;
|
||||
in vec2 uv_pass;
|
||||
|
||||
float min_brightness = 0.05;
|
||||
vec3 sun_position = vec3(1000.0, 1000.0, 1000.0);
|
||||
|
||||
float shine_dampener = 10;
|
||||
float reflectivity = 5;
|
||||
|
||||
uniform sampler2D sampler;
|
||||
|
||||
void main() {
|
||||
color = texture(sampler, uv_pass);
|
||||
|
||||
vec3 to_sun_vector = normalize(sun_position - position_pass);
|
||||
|
||||
float intensity = clamp(dot(to_sun_vector, normal_pass), 0.25, 1.0);
|
||||
color.xyz *= intensity;
|
||||
|
||||
//vec3 to_camera_vector = normalize(camera_position_pass - position_pass);
|
||||
//vec3 reflection = reflect(-to_sun_vector, normal_pass);
|
||||
|
||||
//float specular_intensity = max(dot(to_camera_vector, reflection), 0.0);
|
||||
|
||||
//specular_intensity = pow(specular_intensity, shine_dampener);
|
||||
|
||||
//specular_intensity *= reflectivity;
|
||||
|
||||
//if (dot(normal_pass, to_camera_vector) >= 0.3)
|
||||
//color.xyz += vec3(1.0, 1.0, 1.0) * specular_intensity;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,31 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 vertex_position;
|
||||
layout(location = 1) in vec3 vertex_normal;
|
||||
layout(location = 2) in vec2 vertex_tex_coord;
|
||||
|
||||
uniform mat4 model_matrix;
|
||||
uniform mat4 view_matrix;
|
||||
uniform mat4 proj_matrix;
|
||||
|
||||
uniform vec3 camera_position;
|
||||
|
||||
out vec3 position_pass;
|
||||
out vec3 camera_position_pass;
|
||||
out vec3 normal_pass;
|
||||
out vec2 uv_pass;
|
||||
|
||||
void main() {
|
||||
mat4 mvp = proj_matrix * view_matrix * model_matrix;
|
||||
|
||||
vec3 world_position = (model_matrix * vec4(vertex_position, 1.0)).xyz;
|
||||
gl_Position = mvp * vec4(vertex_position, 1.0);
|
||||
|
||||
normal_pass = normalize((model_matrix * vec4(vertex_normal, 0.0)).xyz);
|
||||
|
||||
position_pass = world_position;
|
||||
|
||||
camera_position_pass = (inverse(view_matrix) * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
|
||||
|
||||
uv_pass = vertex_tex_coord;
|
||||
}
|
||||
Reference in New Issue
Block a user