polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

terrain.v.glsl (1108B)


      1 #include profile
      2 
      3 in vec3 position;
      4 in vec3 normal;
      5 
      6 #include uniforms.glsl
      7 
      8 out shader_data {
      9 
     10 #include shadervars.glsl
     11 
     12 } data_out;
     13 
     14 void main()
     15 {
     16     const int nlands = 6;
     17 
     18     // const vec4 land[nlands] = vec4[](
     19     //   vec4(0.9176, 0.8156, 0.6588, 1.0),  // 1 - sand
     20     //   vec4(0.4627, 0.3333, 0.1686, 20.0)  // 3 - dirt
     21     // );
     22 
     23     const vec4 land[nlands] = vec4[](
     24       vec4(0.0, 0.5, 0.79, 0.0),          // 0 - water
     25       vec4(0.9176, 0.8156, 0.6588, 1.0),  // 1 - sand
     26       vec4(0.7, 0.7, 0.156, 2.0),    // 2 - grass
     27       vec4(0.4627, 0.3333, 0.1686, 20.0), // 3 - dirt
     28       vec4(0.5, 0.5, 0.5, 80.0),         // 4 - stone
     29       vec4(1.0, 1.0, 1.0, 380.0)          // 5 - snow
     30     );
     31 
     32     vec3 color = land[0].xyz;
     33     for (int i = 0; i < nlands-1; i++) {
     34 		color =
     35 			mix(color,
     36 			    land[i+1].xyz,
     37 			    smoothstep(land[i].w, land[i+1].w, position.z));
     38 	}
     39 
     40 	// vec3 color = vec3(position.z*0.05, position.z*0.0055, position.z*0.0001) * 0.5;
     41 
     42 
     43      // vec3 color = vec3(position.z, position.z, position.z) * 0.005;
     44 
     45 #include standard_vtxos.glsl
     46 
     47     gl_Position = mvp * v4_pos;
     48 }