-
-
Save elect86/9a726eabe1dc78cca9cd02fb03ef3c92 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
| #version 330 | |
| #include semantic.glsl | |
| // Outgoing final color. | |
| layout (location = 1) out int outputColor; | |
| in Block | |
| { | |
| flat int id; | |
| } inBlock; | |
| void main() | |
| { | |
| //outputColor = inBlock.id; | |
| outputColor = 9; | |
| } |
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
| gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RESOLVE_ID)); | |
| gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); | |
| gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); | |
| gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_R32I, EC.viewer.size.x, EC.viewer.size.y, 0, GL_RED_INTEGER, | |
| GL_INT, null); | |
| gl3.glGenFramebuffers(Framebuffer.MAX - (samples == 1 ? 1 : 0), framebufferName); | |
| gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); | |
| gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RESOLVE_DEPTH), 0); | |
| gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.RESOLVE_COLOR), 0); | |
| gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, textureName.get(Texture.RESOLVE_ID), 0); | |
| if (gl3.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { | |
| System.err.println("incomplete"); | |
| return false; | |
| } |
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
| gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); | |
| gl3.glDrawBuffer(GL_COLOR_ATTACHMENT1); | |
| gl3.glClearBufferiv(GL_COLOR, 0, clearId.put(0, 0)); // we care clearing only red | |
| gl3.glBindVertexArray(EC.meshManager.vertexArrayName.get(0)); | |
| gl3.glEnable(GL_DEPTH_TEST); | |
| gl3.glUseProgram(program.name); | |
| gl3.glDrawElements(GL_TRIANGLES, EC_Gl3MeshManager.ELEMENT_OPAQUE_COUNT, GL_UNSIGNED_INT, 0); | |
| gl3.glDisable(GL_DEPTH_TEST); |
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
| #version 330 | |
| #include semantic.glsl | |
| layout (location = POSITION) in vec3 position; | |
| uniform Transform0 | |
| { | |
| mat4 view; | |
| mat4 proj; | |
| mat4 viewProj; | |
| }; | |
| uniform Transform1 | |
| { | |
| mat4[TRANSFORM1_SIZE] models; | |
| }; | |
| uniform Parameters | |
| { | |
| // x = mesh baseVertex | |
| // y = selected | |
| // z = active | |
| // w = id | |
| ivec4[INDICES_SIZE] params; | |
| }; | |
| out Block | |
| { | |
| flat int id; | |
| } outBlock; | |
| int getIndex() | |
| { | |
| int iBegin = 0; | |
| int iEnd = params.length() - 1; | |
| int l = iBegin; | |
| int r = iEnd; | |
| int i = 0; | |
| if(params.length > 1) | |
| { | |
| do | |
| { | |
| i = int(((l + r) / 2.0f)); | |
| if (l == (r - 1)) | |
| if (l == 0 && gl_VertexID <= params[l].x || gl_VertexID <= params[l].x && gl_VertexID > params[l - 1].x) | |
| return l; | |
| else if(gl_VertexID > params[l].x && gl_VertexID <= params[r].x) | |
| return r; | |
| else | |
| return 0; | |
| else if (gl_VertexID == params[i].x) | |
| return i; | |
| else if (gl_VertexID < params[i].x) | |
| r = i; | |
| else if (gl_VertexID > params[i].x) | |
| l = i; | |
| } while (l < r); | |
| } | |
| return 0; | |
| } | |
| void main() | |
| { | |
| int index = getIndex(); | |
| mat4 model = models[index]; | |
| //gl_Position = proj * (view * (model * vec4(position, 1))); | |
| gl_Position = vec4(4.0 * float(gl_VertexID % 2) - 1.0, 4.0 * float(gl_VertexID / 2) - 1.0, 0.0, 1.0); | |
| outBlock.id = params[index].w; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment