Jump to content
  • Advertisement

martyj2009

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

135 Neutral

About martyj2009

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. martyj2009

    New fast way to loop!

    So there's the for loop. Which works great for most of our programming needs. What if there was a way to speed this up by up to HALF.   Well there is, it's called a five loop.   See below the code example. // Change this to decide which loop to use! #define FIVE 0 #if FIVE #define five for #endif #include <time.h> #include <stdio.h> int main(int argc, const char *argv[]) { int loops = 10000000000; int a, b; clock_t start, end; start = clock(); #if FIVE five(int i = 0; i < loops; i++) #else for (int i = 0; i < loops; i++) #endif { int a = i; b = a * 3; } end = clock(); double seconds = double(end - start) / CLOCKS_PER_SEC; printf("Time Diff: %f", seconds); getchar(); } I know some of you may be doubtful, but the proof is in the pudding.   The for loop results:   Now compare that to the Five loop       Forget Moore's law. We can't rely on chip manufactures to keep up with our software needs. Five loop is here to save the day!    
  2. martyj2009

    Purchasing a Tegra 4

    I'd recommend running a micro atx motherboard with a AMD APU. This way it can run regular PC games.
  3. I was wondering if I could get some input on managing terrains with OpenGL.   For terrains I'm using a heightmap. I also have a corresponding texture map which designates the textures to use for each vertex.   The texutres are loaded with a GL_TEXTURE_ARRAY_2D accessed by a textureIndex.   This allows me to change the texture at a given point to a path based texture, grass, ect.   I know other people out there use height of a verticie to indicate the texture to use. My problem with this is, how would I ever designate paths in my terrain?   How does everyone else manage terrains?
  4. martyj2009

    OpenGL Tessellation

    I finally figured out my issue.   It wasn't shaders at all. My problem with tessellation was that I was drawing my objects using GL_TRIANGLES. Tessellation only works on GL_PATCHES.
  5. martyj2009

    OpenGL Tessellation

    I have been using that reference as a tessellation example.    The biggest problem is that my code base is so huge. I have texture arrays for height maps, FBO for shaows, reflections, and a bunch of other stuff which complicate code slightly.   I will check out the AMD GPU shader analyzer. Thanks for the info. I will post an update when I test it
  6. Could you post more code?   Code that you use to draw both the shadow and the ambient occlusion depth map.
  7. martyj2009

    Invisible Geometry

    What I usually do is to make it so only that object is rendering in my scene. Just to make sure it's not hiding behind anything or blending with other objects.   Sometimes having large VBOs will make it so objects don't draw.   The best way to problem solving is to simplefy the problem. Take out all un-needed items from your code temporarly just so you have only the bug to deal with.
  8. martyj2009

    OpenGL Tessellation

    Anyone have any idea? Anything at all I could try? Any feedback would be greatly appreciated.     Edit: --------------------------- I simplefied the code. I still get a black screen when the tessellation shaders are enabled. It renders a scene with them commented out.
  9. martyj2009

    OpenGL Tessellation

    Thank you for the reply. Sorry for the late response. I read your message a few days ago.   The reason I didn't use the layout location identifiers is that I am dynamically getting the location in my C code by the name of the attribute. I also keep my variables named the same. Although it would make for easier to understand shader code if I used them as well. That way users can see at a glance what output matches up with what input.   I will implemented this and post my results.   Thank you very much for the feedback. It is greatly appreciated.   Edit --------------------------------------------   I modified my previous post with the updated shaders. I still get the same issues with tessellation.
  10. martyj2009

    heightmaps and vbo's

    As said above, just use one VBO for the heightmap. This way your program code is looping less to render the heightmap. To assign different textures to the heightmap use a Texture3DArray. Just change the texture index z coordnate for the texture of that specific geometry.
  11. martyj2009

    GLSL vertex attributes

    As far as your question of can you use them before you linking the shader, I believe the answer is no.   I don't think OpenGL doesn't know about attribute locations until you link them.
  12. I'm having a hard time getting OpenGL Tessellation to work. I have been struggling with it for about a month now. I've looked at a lot of example code and what I am doing doesn't seem that different to what they are doing in their code. I was wondering if anyone could be a second pair of eyes and maybe point out why it isn't working. My scene is only rendering a black screen. My shaders are as follows:   Vertex Shader #version 400 #extension GL_ARB_tessellation_shader: enable #extension GL_ARB_separate_shader_objects: enable layout(location = 0) in vec3 vertexPosition; void main() {     gl_Position = vec4(vertexPosition, 1.0); } Tessellation Control Shader #version 400 #extension GL_ARB_separate_shader_objects: enable layout(vertices = 3) out; void main() {     float inLevel = 2;     float outLevel = 2;          gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;          if (gl_InvocationID == 0)     {         gl_TessLevelOuter[0] = outLevel;         gl_TessLevelOuter[1] = outLevel;         gl_TessLevelOuter[2] = outLevel;         gl_TessLevelOuter[3] = outLevel;         gl_TessLevelInner[0] = inLevel;         gl_TessLevelInner[1] = inLevel;     } } Tessellation Eval Shader #version 400 #extension GL_ARB_tessellation_shader: enable #extension GL_ARB_separate_shader_objects: enable layout(triangles, equal_spacing, ccw) in; uniform mat4 uMVPMatrix; void main() {     vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position;     vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position;     vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position;     vec4 newCoord = normalize(p0 + p1 + p2);     gl_Position = newCoord; } Geometry Shader #version 400 #extension GL_ARB_separate_shader_objects: enable layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; uniform mat4 uMVPMatrix; uniform bool UseWaveGeometry; uniform float GameTime; layout(location = 3) out vec4 vColor; float rand(vec2 n) {     return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); } void setUpValues(int index) {     vec4 vertPosit = gl_in[index].gl_Position;          if(UseWaveGeometry)     {         vertPosit.y = vertPosit.y + (GameTime + ((cos(vertPosit.x)) * GameTime) - ((sin(vertPosit.x))*GameTime)*2.2);     }          float cval = int(vertPosit.x) % 2 + int(vertPosit.y)%2;     vColor = vec4(cval, cval, cval, 1.0);     gl_Position = uMVPMatrix * vertPosit; } void main() {     for(int i = 0; i < 3; i++)     {         setUpValues(i);         EmitVertex();     }     EndPrimitive(); } Fragment Shader #version 400 #extension GL_EXT_gpu_shader4: enable #extension GL_ARB_separate_shader_objects: enable uniform float ColorAlpha; layout(location = 3) in vec4 vColor; layout(location = 0) out vec4 FragColor; void main() {     vec4 color = vec4(vColor.r, vColor.g, vColor.b, ColorAlpha);          FragColor = color; } Thank you for your time, Marty
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!