• What Are You Working On August 2012
    2,271 replies, posted
Well, all lines appears to go up, so I don't think I have that problem: [img_thumb]http://i.imgur.com/wlPxl.png[/img_thumb]
Wait How about you calculate the normals for every triangle a vertex is a part of and then average those? [editline]13th August 2012[/editline] if your tris are of uniform size it should look good-ish [editline]13th August 2012[/editline] The internet tells me this is what you should do [editline]13th August 2012[/editline] So basically you need, what, four points in addition to the vertex in question
[QUOTE=Capsup;37217332]Well, all lines appears to go up, so I don't think I have that problem: [img_thumb]http://i.imgur.com/wlPxl.png[/img_thumb][/QUOTE] Is there an easy way of making OGL display the normals as lines like you have done?
[QUOTE=esalaka;37217351]Wait How about you calculate the normals for every triangle a vertex is a part of and then average those? [editline]13th August 2012[/editline] if your tris are of uniform size it should look good-ish [editline]13th August 2012[/editline] The internet tells me this is what you should do [editline]13th August 2012[/editline] So basically you need, what, four points in addition to the vertex in question[/QUOTE] You mean like so? [code] for( int i = 0; i < MAP_Z * MAP_X; i++ ) { normals.push_back( glm::vec3( 0.0, 0.0, 0.0 ) ); } for (int z = 0; z < MAP_Z; z++) { for (int x = 0; x < MAP_X; x++) { glm::vec3 A = glm::vec3( terrain[x][z][0], terrain[x][z][1], terrain[x][z][2] ); glm::vec3 B = glm::vec3( terrain[x+1][z][0], terrain[x+1][z][1], terrain[x+1][z][2] ); glm::vec3 C = glm::vec3( terrain[x][z+1][0], terrain[x][z+1][1], terrain[x][z+1][2] ); glm::vec3 D = glm::vec3( terrain[x+1][z+1][0], terrain[x+1][z+1][1], terrain[x+1][z+1][2] ); normals[ z * MAP_Z + x ] += ( glm::normalize( glm::cross( B - A, C - A ) ) ); normals[ z * MAP_Z + x + 1 ] += ( glm::normalize( glm::cross( A - B, D - B ) ) ); normals[ ( z + 1 ) * MAP_Z + x ] += ( glm::normalize( glm::cross( A - C, D - C ) ) ); normals[ ( z + 1 ) * MAP_Z + x + 1 ] += ( glm::normalize( glm::cross( B - D, C - D ) ) ); } } for( int i = 0; i < MAP_Z * MAP_X; i++ ) { glm::normalize( normals[i] ); } [/code] I tried that too if that's the case. [editline]13th August 2012[/editline] [QUOTE=Richy19;37217545]Is there an easy way of making OGL display the normals as lines like you have done?[/QUOTE] I'm just doing it like this: [code] linevertices.push_back( terrain[x][z][0] ); linevertices.push_back( terrain[x][z][1] ); linevertices.push_back( terrain[x][z][2] ); linevertices.push_back( terrain[x][z][0] + 1 * normals[count].x ); linevertices.push_back( terrain[x][z][1] + 1 * normals[count].y ); linevertices.push_back( terrain[x][z][2] + 1 * normals[count].z ); [/code] and then just rendering it as lines.
[QUOTE=esalaka;37217351]Wait How about you calculate the normals for every triangle a vertex is a part of and then average those? [editline]13th August 2012[/editline] if your tris are of uniform size it should look good-ish [editline]13th August 2012[/editline] The internet tells me this is what you should do [editline]13th August 2012[/editline] So basically you need, what, four points in addition to the vertex in question[/QUOTE] Why? Why would you have the ability to render terrain with perpixel lighting and then combine normals to make it perface? Just calculate the normal for each point using the surrounding points in the terrain, THEN make the triangles and render them.
[QUOTE=Capsup;37217623]You mean like so? I tried that too if that's the case. [editline]13th August 2012[/editline] I'm just doing it like this: [code] linevertices.push_back( terrain[x][z][0] ); linevertices.push_back( terrain[x][z][1] ); linevertices.push_back( terrain[x][z][2] ); linevertices.push_back( terrain[x][z][0] + 1 * normals[count].x ); linevertices.push_back( terrain[x][z][1] + 1 * normals[count].y ); linevertices.push_back( terrain[x][z][2] + 1 * normals[count].z ); [/code] and then just rendering it as lines.[/QUOTE] Ohh you using inmediate mode?
[QUOTE=Richy19;37217694]Ohh you using inmediate mode?[/QUOTE] Not at all. I'm using the core profile version 3.2.
Not sure if this belongs here, but i made a simple roguelike in minecraft using lua. :v: [img_thumb]http://frameaway.org/ftp/ShareX/Tekkit_2012-08-13_22-50-54.png[/img_thumb]
Oh man, that's awesome. LuaCraft?
[QUOTE=Dj-J3;37217707]Not sure if this belongs here, but i made a simple roguelike in minecraft using lua. :v: [img_thumb]http://frameaway.org/ftp/ShareX/Tekkit_2012-08-13_22-50-54.png[/img_thumb][/QUOTE] It does. Nice job. [editline]13th August 2012[/editline] [QUOTE=Matt-;37217727]Oh man, that's awesome. LuaCraft?[/QUOTE] Computercraft I think.
[QUOTE=Darwin226;37217689]Why? Why would you have the ability to render terrain with perpixel lighting and then combine normals to make it perface? Just calculate the normal for each point using the surrounding points in the terrain, THEN make the triangles and render them.[/QUOTE] How would I go about that? Honestly, I have no idea what I'm doing anymore. I just want this to work in SOME sense so I can move on to other things. I'm tired of normals and lighting. :(
[QUOTE=Capsup;37217753]How would I go about that? Honestly, I have no idea what I'm doing anymore. I just want this to work in SOME sense so I can move on to other things. I'm tired of normals and lighting. :([/QUOTE] So basically what I did was this. Make a 2D array of points with varying heights. Then for each point, the the normal using the cross product. Since every point belongs to 4 different triangles (except the corner ones), you need to calculate the normal by averaging the normals of those 4 triangles and then normalizing it again. Then, after you attack normal data to each points, you just render the terrain as triangle strip. The pipeline will handle the interpolation. I hope that makes sense.
[QUOTE=Darwin226;37217689]Just calculate the normal for each point using the surrounding points in the terrain, THEN make the triangles and render them.[/QUOTE] You do realise that the surrounding points in the terrain constitute "each triangle a vertex is a part of", right? If you take four points around point A you can form four triangles out of them (as you suggested; or you could presume the triangles already exist), get their normals and then normalise the resulting sum vector. Aren't we saying the same thing?
More progress on my weird game. This time a short video showing the concept of the gameplay: [media]http://www.youtube.com/watch?v=N5VttvaH_E8[/media] [img]http://i.imgur.com/xA74i.png[/img]
[QUOTE=Darwin226;37217794]So basically what I did was this. Make a 2D array of points with varying heights. Then for each point, the the normal using the cross product. Since every point belongs to 4 different triangles (except the corner ones), you need to calculate the normal by averaging the normals of those 4 triangles and then normalizing it again. Then, after you attack normal data to each points, you just render the terrain as triangle strip. The pipeline will handle the interpolation. I hope that makes sense.[/QUOTE] But isn't that what I'm doing in my latest code paste?
[QUOTE=Matt-;37217727]Oh man, that's awesome. LuaCraft?[/QUOTE] Computercraft. I'm using the Tekkit client though. Computercraft is included in that.
[QUOTE=esalaka;37217804]You do realise that the surrounding points in the terrain constitute "each triangle a vertex is a part of", right? If you take four points around point A you can form four triangles out of them (as you suggested; or you could presume the triangles already exist), get their normals and then normalise the resulting sum vector. Aren't we saying the same thing?[/QUOTE] Yeah. We are actually. Sorry. I thought you meant that he should get 3 normals for each point on the triangle and then average those to get the triangles normal. [editline]13th August 2012[/editline] [QUOTE=Capsup;37217842]But isn't that what I'm doing in my latest code paste?[/QUOTE] I don't think so. You need 5 points in total when you only have 4.
I made my interface simpler, rather than those random buttons, I instead added a context menu: [img]http://i.imgur.com/r85VW.png[/img] How is this? The only problem now, is I need to have a search button to search the history (not just for a specific item); does anyone see a place I can put it that won't look like utter shit?
[t]http://i.imgur.com/wuVJR.png[/t] Finally got text to work.
[QUOTE=Darwin226;37218017]Yeah. We are actually. Sorry. I thought you meant that he should get 3 normals for each point on the triangle and then average those to get the triangles normal. [editline]13th August 2012[/editline] I don't think so. You need 5 points in total when you only have 4.[/QUOTE] What about something like this? [code] for (int z = 1; z < MAP_Z-1; z++) { for (int x = 1; x < MAP_X-1; x++) { glm::vec3 A = glm::vec3( terrain[x][z][0], terrain[x][z][1], terrain[x][z][2] ); glm::vec3 B = glm::vec3( terrain[x+1][z][0], terrain[x+1][z][1], terrain[x+1][z][2] ); glm::vec3 C = glm::vec3( terrain[x][z+1][0], terrain[x][z+1][1], terrain[x][z+1][2] ); glm::vec3 D = glm::vec3( terrain[x-1][z][0], terrain[x-1][z][1], terrain[x-1][z][2] ); glm::vec3 E = glm::vec3( terrain[x][z-1][0], terrain[x][z-1][1], terrain[x][z-1][2] ); glm::vec3 normal = glm::normalize( glm::normalize( glm::cross( B - A, C - A ) ) + glm::normalize( glm::cross( C - A, D - A ) ) + glm::normalize( glm::cross( D - A, E - A ) ) + glm::normalize( glm::cross( E - A, B - A ) ) ); normals.push_back( normal ); } } [/code] Right now I'm just ignoring the edge cases though.
[QUOTE=Capsup;37218713]What about something like this? [code] for (int z = 1; z < MAP_Z-1; z++) { for (int x = 1; x < MAP_X-1; x++) { glm::vec3 A = glm::vec3( terrain[x][z][0], terrain[x][z][1], terrain[x][z][2] ); glm::vec3 B = glm::vec3( terrain[x+1][z][0], terrain[x+1][z][1], terrain[x+1][z][2] ); glm::vec3 C = glm::vec3( terrain[x][z+1][0], terrain[x][z+1][1], terrain[x][z+1][2] ); glm::vec3 D = glm::vec3( terrain[x-1][z][0], terrain[x-1][z][1], terrain[x-1][z][2] ); glm::vec3 E = glm::vec3( terrain[x][z-1][0], terrain[x][z-1][1], terrain[x][z-1][2] ); glm::vec3 normal = glm::normalize( glm::normalize( glm::cross( B - A, C - A ) ) + glm::normalize( glm::cross( C - A, D - A ) ) + glm::normalize( glm::cross( D - A, E - A ) ) + glm::normalize( glm::cross( E - A, B - A ) ) ); normals.push_back( normal ); } } [/code] Right now I'm just ignoring the edge cases though.[/QUOTE] Yeah. That seems right.
That seems to make sense. As long as ABC, ACD, ADE and AEB actually are the bounding four triangles.
[QUOTE=esalaka;37218899]That seems to make sense. As long as ABC, ACD, ADE and AEB actually are the bounding four triangles.[/QUOTE] Well, they should be atleast. My terrain array is just a 3D array which has the vertices for all my triangles. So that it just goes like this: [img_thumb]http://i.imgur.com/kaeF8.png[/img_thumb] Still, this is what it looks like: [img_thumb]http://i.imgur.com/OChIe.jpg[/img_thumb] Not much better to be honest. So I'm really at a loss about what I'm doing wrong here. I must admit I also wonder what the heck is happening to that couple of completely black triangles there.
Batch is pretty awesome sometimes.. [img]http://new.tinygrab.com/7cfbd51783753252c5440c29535ff98f138495114c.png[/img] Only took me like a minute to write, and now I can listen to high-quality music when going to sleep! [sp]And not to forget all those LEDs in my PC and backlight from my keyboard to keep me awake! :v[/sp] [editline]14th August 2012[/editline] No, I did not take those values directly from WMP, I have to enter that myself. I'm not a master batcher.
[QUOTE=Darkwater124;37219079]Batch is pretty awesome sometimes.. [img]http://new.tinygrab.com/7cfbd51783753252c5440c29535ff98f138495114c.png[/img] Only took me like a minute to write, and now I can listen to high-quality music when going to sleep! [sp]And not to forget all those LEDs in my PC and backlight from my keyboard to keep me awake! :v[/sp] [editline]14th August 2012[/editline] No, I did not take those values directly from WMP, I have to enter that myself. I'm not a master batcher.[/QUOTE] Or use Linux/Lubuntu and sudo shutdown, and be able to close your lapop lid without it sleeping :v:
[QUOTE=Capsup;37219051]Well, they should be atleast. My terrain array is just a 3D array which has the vertices for all my triangles.[/QUOTE] I mean, the order should be something like B = (x + 1, y) C = (x, y + 1) D = (x - 1, y) E = (x, y - 1) Which... it seems to be. Huh.
[QUOTE=Richy19;37219163]Or use Linux/Lubuntu and sudo shutdown, and be able to close your lapop lid without it sleeping :v:[/QUOTE] Or, you know.. Turn that off in power management in windows? :v: [editline]13th August 2012[/editline] [QUOTE=esalaka;37219180]I mean, the order should be something like B = (x + 1, y) C = (x, y + 1) D = (x - 1, y) E = (x, y - 1) Which... it seems to be. Huh.[/QUOTE] Yeah... I'm at a loss here.
[QUOTE=Mr Kirill;37217831]More progress on my weird game. This time a short video showing the concept of the gameplay:[/QUOTE] Needs Bezier curves.
[QUOTE=COBRAa;37218519]I made my interface simpler, rather than those random buttons, I instead added a context menu: [img]http://i.imgur.com/r85VW.png[/img] How is this? The only problem now, is I need to have a search button to search the history (not just for a specific item); does anyone see a place I can put it that won't look like utter shit?[/QUOTE] I dont get the difference between right and left menu, cant you just move "new stuff" to top of "mice" make your textboxes smaller and put search to top right ?
[QUOTE=Capsup;37219051]Well, they should be atleast. My terrain array is just a 3D array which has the vertices for all my triangles. So that it just goes like this: [img_thumb]http://i.imgur.com/kaeF8.png[/img_thumb] Still, this is what it looks like: [img_thumb]http://i.imgur.com/OChIe.jpg[/img_thumb] Not much better to be honest. So I'm really at a loss about what I'm doing wrong here. I must admit I also wonder what the heck is happening to that couple of completely black triangles there.[/QUOTE] Are you sure you're attaching those normals to each of those points? This looks like it might be a problem in how you render the terrain in the end.
Sorry, you need to Log In to post a reply to this thread.