diff --git a/README.md b/README.md index f22c764..d456662 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,47 @@ + +![lights_plus_bloom](base/images/lights_p_bloom.png) + ------------------------------------------------------------------------------- CIS565: Project 6: Deferred Shader ------------------------------------------------------------------------------- + +The goal of this project was to explore and learn about deferred shading techniques + +For this project I've implemented: +* Bloom +* "Toon" Shading (with basic silhouetting) +* Point light sources + +I have a g-buffer slot added, but didn't end up using it for anything, so that +doesn't exactly count. + +--- +Images: +--- +Toon Shading: +![toon_shading](base/images/toon_shading.png) + +Toon Shading with Bloom ( just for fun ): +![toon_plus_bloom](base/images/toon_plus_bloom.png) + +--- +Video: +--- +A painfully buggy video attempting to show off various features ( I've gotta redo this one ). +http://youtu.be/yHgk-cvPy9Q + +--- +Performance Analysis: +--- +Mode vs FPS: +* No Bloom: ~59 +* Bloom width 10: ~25 +* Bloom width 25: ~12 +* Bloom width 50: ~5 +* Silhouetting: ~40 +* ... + + Fall 2013 ------------------------------------------------------------------------------- Due Friday 11/15/2013 diff --git a/base/PROJ_NIX/565DefferedShader b/base/PROJ_NIX/565DefferedShader new file mode 100755 index 0000000..c7fc124 Binary files /dev/null and b/base/PROJ_NIX/565DefferedShader differ diff --git a/base/images/lights_p_bloom.png b/base/images/lights_p_bloom.png new file mode 100644 index 0000000..5aebd74 Binary files /dev/null and b/base/images/lights_p_bloom.png differ diff --git a/base/images/toon_plus_bloom.png b/base/images/toon_plus_bloom.png new file mode 100644 index 0000000..237d5dd Binary files /dev/null and b/base/images/toon_plus_bloom.png differ diff --git a/base/images/toon_shading.png b/base/images/toon_shading.png new file mode 100644 index 0000000..ab14f2a Binary files /dev/null and b/base/images/toon_shading.png differ diff --git a/base/res/cornell/cornell_box.obj b/base/res/cornell/cornell_box.obj index 43e021f..c697be9 100644 --- a/base/res/cornell/cornell_box.obj +++ b/base/res/cornell/cornell_box.obj @@ -61,7 +61,7 @@ v 556.0 548.8 0 #f -1 -2 -3 -4 o green_wall -usemtl green +usemtl red v 0.0 0.0 559.2 v 0.0 0.0 0.0 v 0.0 548.8 0.0 @@ -77,7 +77,7 @@ v 556.0 548.8 0.0 f -4 -3 -2 -1 o short_block -usemtl white +usemtl green v 130.0 165.0 65.0 v 82.0 165.0 225.0 diff --git a/base/res/shaders/ambient.frag b/base/res/shaders/ambient.frag index 69b878c..59516c5 100644 --- a/base/res/shaders/ambient.frag +++ b/base/res/shaders/ambient.frag @@ -21,6 +21,7 @@ uniform sampler2D u_Depthtex; uniform sampler2D u_Normaltex; uniform sampler2D u_Positiontex; uniform sampler2D u_Colortex; +uniform sampler2D u_idtex; uniform sampler2D u_RandomNormaltex; uniform sampler2D u_RandomScalartex; @@ -38,10 +39,9 @@ uniform float u_LightIl; in vec2 fs_Texcoord; out vec4 out_Color; -/////////////////////////////////////// - - +out vec4 out_Normal; +/////////////////////////////////////// uniform float zerothresh = 1.0f; uniform float falloff = 0.1f; @@ -110,6 +110,7 @@ void main() { float diffuse = max(0.0, dot(normalize(light),normal)); out_Color = vec4(color*(strength*diffuse + ambient),1.0f); } + out_Normal = vec4( normal, 0.0 ); return; } diff --git a/base/res/shaders/diagnostic.frag b/base/res/shaders/diagnostic.frag index ac73727..4a85b05 100644 --- a/base/res/shaders/diagnostic.frag +++ b/base/res/shaders/diagnostic.frag @@ -10,6 +10,7 @@ #define DISPLAY_COLOR 3 #define DISPLAY_TOTAL 4 #define DISPLAY_LIGHTS 5 +#define DISPLAY_ID 6 ///////////////////////////////////// @@ -21,6 +22,7 @@ uniform sampler2D u_Depthtex; uniform sampler2D u_Normaltex; uniform sampler2D u_Positiontex; uniform sampler2D u_Colortex; +uniform sampler2D u_idtex; uniform sampler2D u_RandomNormaltex; uniform sampler2D u_RandomScalartex; @@ -41,8 +43,6 @@ out vec4 out_Color; /////////////////////////////////////// - - uniform float zerothresh = 1.0f; uniform float falloff = 0.1f; @@ -101,6 +101,7 @@ void main() { vec3 normal = sampleNrm(fs_Texcoord); vec3 position = samplePos(fs_Texcoord); vec3 color = sampleCol(fs_Texcoord); + vec3 id = texture(u_idtex,fs_Texcoord).xyz; vec3 light = u_Light.xyz; float lightRadius = u_Light.w; @@ -118,6 +119,9 @@ void main() { out_Color = vec4(color, 1.0); break; case(DISPLAY_LIGHTS): + case(DISPLAY_ID): + out_Color = vec4(id, 1.0); + break; case(DISPLAY_TOTAL): break; } diff --git a/base/res/shaders/pass.frag b/base/res/shaders/pass.frag index e37dcbf..8a29fa4 100644 --- a/base/res/shaders/pass.frag +++ b/base/res/shaders/pass.frag @@ -9,10 +9,12 @@ in vec4 fs_Position; out vec4 out_Normal; out vec4 out_Position; out vec4 out_Color; +out vec4 out_Sobel; void main(void) { out_Normal = vec4(normalize(fs_Normal),0.0f); out_Position = vec4(fs_Position.xyz,1.0f); //Tuck position into 0 1 range out_Color = vec4(u_Color,1.0); + out_Sobel = vec4(0.0, 0.0, 0.0, 0.0); } diff --git a/base/res/shaders/pass.vert b/base/res/shaders/pass.vert index e36825f..8120d25 100644 --- a/base/res/shaders/pass.vert +++ b/base/res/shaders/pass.vert @@ -8,14 +8,17 @@ uniform mat4x4 u_InvTrans; in vec3 Position; in vec3 Normal; +//in unsigned short id; out vec3 fs_Normal; out vec4 fs_Position; +//out unsigned short fs_id; void main(void) { fs_Normal = (u_InvTrans*vec4(Normal,0.0f)).xyz; vec4 world = u_Model * vec4(Position, 1.0); vec4 camera = u_View * world; fs_Position = camera; + //fs_id = id; gl_Position = u_Persp * camera; } diff --git a/base/res/shaders/point.frag b/base/res/shaders/point.frag index 98b90e0..2e17779 100644 --- a/base/res/shaders/point.frag +++ b/base/res/shaders/point.frag @@ -21,6 +21,7 @@ uniform sampler2D u_Depthtex; uniform sampler2D u_Normaltex; uniform sampler2D u_Positiontex; uniform sampler2D u_Colortex; +uniform sampler2D u_idtex; uniform sampler2D u_RandomNormaltex; uniform sampler2D u_RandomScalartex; @@ -39,9 +40,6 @@ in vec2 fs_Texcoord; out vec4 out_Color; /////////////////////////////////////// - - - uniform float zerothresh = 1.0f; uniform float falloff = 0.1f; @@ -93,6 +91,7 @@ float getRandomScalar(vec2 texcoords) { ////////////////////////////////// const float occlusion_strength = 1.5f; void main() { + vec3 lightdir; float exp_depth = texture(u_Depthtex, fs_Texcoord).r; float lin_depth = linearizeDepth(exp_depth,u_Near,u_Far); @@ -102,14 +101,41 @@ void main() { vec3 color = sampleCol(fs_Texcoord); vec3 light = u_Light.xyz; float lightRadius = u_Light.w; + + out_Color = vec4(0,0,0,1.0); + out_Color = vec4(0,0,0,1.0); if( u_DisplayType == DISPLAY_LIGHTS ) { //Put some code here to visualize the fragment associated with this point light + // This does something sensible for some reason + out_Color = vec4( 0.0f, 1.0f, 0.0f, 1.0f ); } else { //Put some code here to actually compute the light from the point light + // Start with simple diffuse lighting + + // Don't render things pointing away from us + if ( dot(position, normal) > 0.0f ) + return; + + lightdir = light - position; + // Only render those fragments that are close enough ... doesn't seem to do the right thing :/ + float radius = length(lightdir)/lightRadius; + if ( radius > 1.0 ) + return; + + // Light magnitude with linear falloff + // TODO: better lighting falloff + float mag = u_LightIl*(1.0-radius); + + // Diffuse term in light + float diffuse = max(dot( normalize(lightdir.xyz), normal ), 0.0f); + // TODO: Specular term ... do later ... + + out_Color = vec4(mag*diffuse*color, 1.0); + } return; } diff --git a/base/res/shaders/post.frag b/base/res/shaders/post.frag index 2bf5afc..c4e89a7 100644 --- a/base/res/shaders/post.frag +++ b/base/res/shaders/post.frag @@ -16,33 +16,54 @@ // Uniforms, Attributes, and Outputs //////////////////////////////////// uniform sampler2D u_Posttex; +uniform sampler2D u_Colortex; +uniform sampler2D u_Depthtex; +uniform sampler2D u_Normaltex; uniform sampler2D u_RandomNormaltex; uniform sampler2D u_RandomScalartex; +uniform float u_Far; +uniform float u_Near; + +uniform mat4 u_View; + uniform int u_ScreenWidth; uniform int u_ScreenHeight; +uniform int u_BloomEnable; + in vec2 fs_Texcoord; out vec4 out_Color; /////////////////////////////////////// - - - uniform float zerothresh = 1.0f; uniform float falloff = 0.1f; - ///////////////////////////////////// // UTILITY FUNCTIONS ///////////////////////////////////// +//Helper function to automatically sample and unpack normals +vec3 sampleNrm(vec2 texcoords) { + return texture(u_Normaltex,texcoords).xyz; +} //Helper function to automicatlly sample and unpack positions vec3 sampleCol(vec2 texcoords) { return texture(u_Posttex,texcoords).xyz; } +//Depth used in the Z buffer is not linearly related to distance from camera +//This restores linear depth +float linearizeDepth(float exp_depth, float near, float far) { + return (2 * near) / (far + near - exp_depth * (far - near)); +} + +float sampleDepth(vec2 texcoords) { + float exp_depth = texture(u_Depthtex, fs_Texcoord).r; + return linearizeDepth( exp_depth, u_Near, u_Far ); +} + //Get a random normal vector given a screen-space texture coordinate //Actually accesses a texture of random vectors vec3 getRandomNormal(vec2 texcoords) { @@ -68,7 +89,104 @@ void main() { vec3 color = sampleCol(fs_Texcoord); float gray = dot(color, vec3(0.2125, 0.7154, 0.0721)); float vin = min(2*distance(vec2(0.5), fs_Texcoord), 1.0); - out_Color = vec4(mix(pow(color,vec3(1.0/1.8)),vec3(gray),vin), 1.0); + + + //depth = sqrt(sampleDepth( fs_Texcoord )); + //out_Color = vec4(depth, depth, depth, 1.0 ); + //out_Color = vec4(sampleNrm( fs_Texcoord ), 1.0); + + /* + // Bloom + if ( u_BloomEnable == 1 ) { + out_Color = vec4(mix(pow(color,vec3(1.0/1.8)),vec3(gray),vin), 1.0); + return; + } + */ + /* + int blur_range = 25; + vec3 blur_val = vec3( 0.0, 0.0, 0.0 ); + // Super-duper Naive implementation of bloom + for ( int i=0; i < blur_range; i++ ) { + for ( int j=0; j < blur_range; j++ ) { + float x = fs_Texcoord.x+(i-blur_range/2)/float(u_ScreenWidth); + float y = fs_Texcoord.y+(j-blur_range/2)/float(u_ScreenHeight); + vec3 sample_color = texture(u_Colortex,vec2(x,y)).xyz; + if ( sample_color.g > 0.1 && sample_color.r < 0.1) + blur_val += sample_color/float(blur_range); + } + } + color += blur_val; + */ + //out_Color = vec4(color+blur_val, 1.0); + + + // Cell shading + + int num_shades = 15; + out_Color = vec4(round(color.x*num_shades)/num_shades, round(color.y*num_shades)/num_shades, round(color.z*num_shades)/num_shades, 1.0 ); + + + // Naive sobel on normals + mat3 sobel_kernel = mat3( 1.0, 2.0, 1.0 , + 0.0, 0.0, 0.0 , + -1.0,-2.0,-1.0 ); + float Gx = 0.0; + float Gy = 0.0; + float depth; + vec3 N; + // Compute Gx + for ( int i=0; i<3; i++ ) { + for ( int j=0; j<3; j++ ) { + + N = sampleNrm( vec2( fs_Texcoord.x+(i-1)/float(u_ScreenWidth) , fs_Texcoord.y+(j-1)/float(u_ScreenHeight)) ); + depth = dot( N, vec3(1.0, 1.0, 1.0) ); + Gx += sobel_kernel[i,j]*depth; + Gy += sobel_kernel[j,i]*depth; + } + } + float G = sqrt( Gx*Gx + Gy*Gy ); + //out_Color = vec4( Gx, Gx, Gx, 1.0 ); + //out_Color = vec4( Gy, Gy, Gy, 1.0 ); + if ( G > 0.05 ) + out_Color = vec4( 0.0, 0.0, 0.0, 1.0 ); + + + + // Screen space ambient occlusion + /* + float depth = sampleDepth( fs_Texcoord ); + //out_Color = vec4(depth, depth, depth, 1.0 ); + // Naive solution, sample on a grid and calculate occlusion_strength based on how much closer pixels around this pixel are + int num_samples = 20; + float sample_period = 5; + float sample_depth; + int gt_samples = 0; + for ( int i=0; i depth ) + gt_samples += 1; + } + } + float occlusion = (float(gt_samples)) / float( num_samples*num_samples ); + out_Color = vec4( occlusion, occlusion, occlusion, 1.0 ); + */ + /* + depth = depth*occlusion_strength; + out_Color = vec4(depth, depth, depth, 1.0 ); + */ + + + // Sample hemisphere around normal + + + + + //out_Color = vec4(getRandomNormal( fs_Texcoord ),1.0); + //out_Color = vec4( color, 1.0 ); + //out_Color = vec4(mix(pow(occlusion_strength*color,vec3(1.0/1.8)),vec3(gray),vin), 1.0); + + return; } diff --git a/base/src/main.cpp b/base/src/main.cpp index 9a0f6a0..7b53244 100644 --- a/base/src/main.cpp +++ b/base/src/main.cpp @@ -212,8 +212,11 @@ GLuint normalTexture = 0; GLuint positionTexture = 0; GLuint colorTexture = 0; GLuint postTexture = 0; -GLuint FBO[2] = {0, 0}; +// Additional G-Buffer +GLuint sobelTexture = 0; + +GLuint FBO[2] = {0, 0}; GLuint pass_prog; GLuint point_prog; @@ -249,6 +252,7 @@ void initShader() { glBindAttribLocation(pass_prog, mesh_attributes::POSITION, "Position"); glBindAttribLocation(pass_prog, mesh_attributes::NORMAL, "Normal"); glBindAttribLocation(pass_prog, mesh_attributes::TEXCOORD, "Texcoord"); + //glBindAttribLocation(pass_prog, mesh_attributes::ID, "id"); Utility::attachAndLinkProgram(pass_prog,shaders); @@ -295,6 +299,8 @@ void freeFBO() { glDeleteTextures(1,&positionTexture); glDeleteTextures(1,&colorTexture); glDeleteTextures(1,&postTexture); + // Additional G-Buffer + glDeleteTextures(1,&sobelTexture); glDeleteFramebuffers(1,&FBO[0]); glDeleteFramebuffers(1,&FBO[1]); } @@ -367,6 +373,9 @@ void initFBO(int w, int h) { glGenTextures(1, &positionTexture); glGenTextures(1, &colorTexture); + // Additional G-Buffer + glGenTextures(1, &sobelTexture); + //Set up depth FBO glBindTexture(GL_TEXTURE_2D, depthTexture); @@ -412,6 +421,17 @@ void initFBO(int w, int h) { glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F , w, h, 0, GL_RGBA, GL_FLOAT,0); + //Set up sobel FBO + glBindTexture(GL_TEXTURE_2D, sobelTexture); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F , w, h, 0, GL_RGBA, GL_FLOAT,0); + // creatwwe a framebuffer object glGenFramebuffers(1, &FBO[0]); glBindFramebuffer(GL_FRAMEBUFFER, FBO[0]); @@ -421,11 +441,16 @@ void initFBO(int w, int h) { GLint normal_loc = glGetFragDataLocation(pass_prog,"out_Normal"); GLint position_loc = glGetFragDataLocation(pass_prog,"out_Position"); GLint color_loc = glGetFragDataLocation(pass_prog,"out_Color"); - GLenum draws [3]; + // Additional G-Buffer + GLint sobel_loc = glGetFragDataLocation(pass_prog,"out_Sobel"); + + GLenum draws [4]; draws[normal_loc] = GL_COLOR_ATTACHMENT0; draws[position_loc] = GL_COLOR_ATTACHMENT1; draws[color_loc] = GL_COLOR_ATTACHMENT2; - glDrawBuffers(3, draws); + //cout << sobel_loc << endl; + draws[sobel_loc] = GL_COLOR_ATTACHMENT3; + glDrawBuffers(4, draws); // attach the texture to FBO depth attachment point int test = GL_COLOR_ATTACHMENT0; @@ -438,6 +463,10 @@ void initFBO(int w, int h) { glBindTexture(GL_TEXTURE_2D, colorTexture); glFramebufferTexture(GL_FRAMEBUFFER, draws[color_loc], colorTexture, 0); + // Additional G-Buffer + glBindTexture(GL_TEXTURE_2D, sobelTexture); + glFramebufferTexture(GL_FRAMEBUFFER, draws[sobel_loc], sobelTexture, 0); + // check FBO status FBOstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); if(FBOstatus != GL_FRAMEBUFFER_COMPLETE) { @@ -461,21 +490,25 @@ void initFBO(int w, int h) { glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F , w, h, 0, GL_RGBA, GL_FLOAT,0); - // creatwwe a framebuffer object + // create a framebuffer object glGenFramebuffers(1, &FBO[1]); glBindFramebuffer(GL_FRAMEBUFFER, FBO[1]); // Instruct openGL that we won't bind a color texture with the currently bound FBO glReadBuffer(GL_BACK); color_loc = glGetFragDataLocation(ambient_prog,"out_Color"); + //normal_loc = glGetFragDataLocation(ambient_prog,"out_Normal"); GLenum draw[1]; draw[color_loc] = GL_COLOR_ATTACHMENT0; + //draw[normal_loc] = GL_COLOR_ATTACHMENT1; glDrawBuffers(1, draw); // attach the texture to FBO depth attachment point test = GL_COLOR_ATTACHMENT0; glBindTexture(GL_TEXTURE_2D, postTexture); glFramebufferTexture(GL_FRAMEBUFFER, draw[color_loc], postTexture, 0); + //glBindTexture(GL_TEXTURE_2D, normalTexture); + //glFramebufferTexture(GL_FRAMEBUFFER, draw[normal_loc], normalTexture, 0); // check FBO status FBOstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -572,7 +605,7 @@ mat4x4 get_mesh_world() { float FARP; float NEARP; void draw_mesh() { - FARP = 100.0f; + FARP = 30.0f; NEARP = 0.1f; glUseProgram(pass_prog); @@ -601,6 +634,7 @@ void draw_mesh() { enum Display display_type = DISPLAY_TOTAL; +int bloom_enable = 0; void setup_quad(GLuint prog) { @@ -617,6 +651,7 @@ void setup_quad(GLuint prog) glUniform1f(glGetUniformLocation(prog, "u_Far"), FARP); glUniform1f(glGetUniformLocation(prog, "u_Near"), NEARP); glUniform1i(glGetUniformLocation(prog, "u_DisplayType"), display_type); + glUniform1i(glGetUniformLocation(prog, "u_BloomEnable"), bloom_enable); glUniformMatrix4fv(glGetUniformLocation(prog, "u_Persp"),1, GL_FALSE, &persp[0][0] ); glActiveTexture(GL_TEXTURE0); @@ -642,6 +677,11 @@ void setup_quad(GLuint prog) glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, random_scalar_tex); glUniform1i(glGetUniformLocation(prog, "u_RandomScalartex"),5); + + glActiveTexture(GL_TEXTURE6); + glBindTexture(GL_TEXTURE_2D, sobelTexture); + glUniform1i(glGetUniformLocation(prog, "u_sobeltex"),6); + } void draw_quad() { @@ -769,14 +809,22 @@ void display(void) 0.0, 0.0, 1.0, 0.0, 0.5, 0.5, 0.0, 1.0); - draw_light(vec3(2.5, -2.5, 5.0), 0.50, sc, vp, NEARP); + for( int i=0; i < 5; i++ ) { + for( int j=0; j < 5; j++ ) { + for( int k=0; k < 5; k++ ) { + //draw_light(vec3(2.5, -0.5, 5.0), 1.0, sc, vp, NEARP); + float scl = 2.0; + draw_light(vec3(scl*(i-0.5), -scl*(j-0.5), scl*(k-0.5)), 1.0, sc, vp, NEARP); + } + } + } glDisable(GL_SCISSOR_TEST); vec4 dir_light(0.1, 1.0, 1.0, 0.0); dir_light = cam.get_view() * dir_light; dir_light = normalize(dir_light); dir_light.w = 0.3; - float strength = 0.09; + float strength = 0.1; setup_quad(ambient_prog); glUniform4fv(glGetUniformLocation(ambient_prog, "u_Light"), 1, &(dir_light[0])); glUniform1f(glGetUniformLocation(ambient_prog, "u_LightIl"), strength); @@ -793,14 +841,27 @@ void display(void) setTextures(); glUseProgram(post_prog); + mat4 view = cam.get_view(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); + glUniform1f(glGetUniformLocation(post_prog, "u_Far"), FARP); + glUniform1f(glGetUniformLocation(post_prog, "u_Near"), NEARP); + glUniformMatrix4fv(glGetUniformLocation(post_prog,"u_View"),1,GL_FALSE,&view[0][0]); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, postTexture); glUniform1i(glGetUniformLocation(post_prog, "u_Posttex"),0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, depthTexture); + glUniform1i(glGetUniformLocation(post_prog, "u_Depthtex"),1); + + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, normalTexture); + glUniform1i(glGetUniformLocation(post_prog, "u_Normaltex"),2); + glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, random_normal_tex); glUniform1i(glGetUniformLocation(post_prog, "u_RandomNormaltex"),4); @@ -908,12 +969,22 @@ void keyboard(unsigned char key, int x, int y) { case('5'): display_type = DISPLAY_LIGHTS; break; + case('6'): + display_type = DISPLAY_ID; + break; case('0'): display_type = DISPLAY_TOTAL; break; case('x'): doIScissor ^= true; break; + case('b'): + if ( bloom_enable == 0 ) { + bloom_enable = 1; + } else { + bloom_enable = 0; + } + break; case('r'): initShader(); break; diff --git a/base/src/main.h b/base/src/main.h index 0a96a3a..e401173 100644 --- a/base/src/main.h +++ b/base/src/main.h @@ -35,8 +35,8 @@ typedef struct { std::vector normals; std::vector texcoords; std::vector indices; - std::string texname; - glm::vec3 color; + std::string texname; + glm::vec3 color; } mesh_t; typedef struct { @@ -67,7 +67,8 @@ namespace mesh_attributes { enum { POSITION, NORMAL, - TEXCOORD + TEXCOORD, + ID }; } namespace quad_attributes { @@ -83,7 +84,8 @@ enum Display { DISPLAY_POSITION = 2, DISPLAY_COLOR = 3, DISPLAY_TOTAL = 4, - DISPLAY_LIGHTS = 5 + DISPLAY_LIGHTS = 5, + DISPLAY_ID = 6 }; char* loadFile(char *fname, GLint &fSize);