Created
July 21, 2020 19:59
-
-
Save Phildo/236fe195587c4ba0e04e14d22e079b9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//generated via stb_voxel_render.h stbvox_get_vertex_shader() using the following #defines: | |
// | |
//#define STBVOX_CONFIG_MODE 0 | |
//#define STBVOX_CONFIG_DISABLE_TEX2 | |
// | |
#version 150 | |
in uvec4 attr_face; | |
in uint attr_vertex; | |
uniform vec3 transform[3]; | |
uniform vec4 camera_pos; | |
uniform vec3 normal_table[32]; | |
uniform mat4x4 model_view; | |
flat out uvec4 facedata; | |
out vec3 voxelspace_pos; | |
out vec3 vnormal; | |
out float texlerp; | |
out float amb_occ; | |
void main() | |
{ | |
facedata = attr_face; | |
vec3 offset; | |
offset.x = float( (attr_vertex ) & 127u ); | |
offset.y = float( (attr_vertex >> 7u) & 127u ); | |
offset.z = float( (attr_vertex >> 14u) & 511u ); | |
amb_occ = float( (attr_vertex >> 23u) & 63u ) / 63.0; | |
texlerp = float( (attr_vertex >> 29u) ) / 7.0; | |
vnormal = normal_table[(facedata.w>>2u) & 31u]; | |
voxelspace_pos = offset * transform[0]; | |
vec3 position = voxelspace_pos + transform[1]; | |
gl_Position = model_view * vec4(position,1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment