Pass directly normal to the fragment shader
This commit is contained in:
+2
-6
@@ -71,16 +71,12 @@ fn main() {
|
|||||||
uniform mat4 persp_matrix;
|
uniform mat4 persp_matrix;
|
||||||
uniform mat4 view_matrix;
|
uniform mat4 view_matrix;
|
||||||
|
|
||||||
// can't skip directly to fragment shader an unmodified variable?
|
|
||||||
in vec3 normal;
|
|
||||||
in uint index;
|
in uint index;
|
||||||
in float altitude;
|
in float altitude;
|
||||||
|
|
||||||
out vec3 v_normal;
|
|
||||||
out vec2 v_tex_coords;
|
out vec2 v_tex_coords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
v_normal = normal;
|
|
||||||
uint index_mod = index % 6u;
|
uint index_mod = index % 6u;
|
||||||
uint index_div = index / 6u;
|
uint index_div = index / 6u;
|
||||||
uint z = index_div / 250u;
|
uint z = index_div / 250u;
|
||||||
@@ -110,7 +106,7 @@ fn main() {
|
|||||||
fragment: "
|
fragment: "
|
||||||
#version 140
|
#version 140
|
||||||
|
|
||||||
in vec3 v_normal;
|
flat in vec3 normal;
|
||||||
in vec2 v_tex_coords;
|
in vec2 v_tex_coords;
|
||||||
out vec4 f_color;
|
out vec4 f_color;
|
||||||
flat in uint biome;
|
flat in uint biome;
|
||||||
@@ -120,7 +116,7 @@ fn main() {
|
|||||||
const vec3 LIGHT = vec3(0.0, -1.0, 0.0);
|
const vec3 LIGHT = vec3(0.0, -1.0, 0.0);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float lum = max(dot(normalize(v_normal), normalize(LIGHT)), 0.0);
|
float lum = max(dot(normalize(normal), normalize(LIGHT)), 0.0);
|
||||||
|
|
||||||
if(biome == 0u) f_color = (0.3 + 0.7 * lum, 1.0) * texture(tex0, v_tex_coords);
|
if(biome == 0u) f_color = (0.3 + 0.7 * lum, 1.0) * texture(tex0, v_tex_coords);
|
||||||
else if(biome == 1u) f_color = (0.3 + 0.7 * lum, 1.0) * texture(tex1, v_tex_coords);
|
else if(biome == 1u) f_color = (0.3 + 0.7 * lum, 1.0) * texture(tex1, v_tex_coords);
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
|
|||||||
biome: u32,
|
biome: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
implement_vertex!(Vertex, altitude, normal, index);
|
implement_vertex!(Vertex, altitude, normal, index, biome);
|
||||||
|
|
||||||
let mut vertex_data: Vec<Vertex> = Vec::new();
|
let mut vertex_data: Vec<Vertex> = Vec::new();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user