<\/a>So this was a long time in coming. \u00a0For quite a long time, my procedural geometry generation system has been generating texture coordinates for the objects it makes. \u00a0This is so that (if\/when desired) textures can easily be applied to the generated objects.<\/p>\nTexture coordinates basically work by assigning coordinates to each corner of an image; \u00a0the top left corner is (0,0), the top right is (1,0), the bottom left is (0,1), and the bottom right is (1,1). \u00a0What I’ve been doing is wrapping a texture around the objects I make, so the texture repeats some number of times, and the left and right edges of the texture touch each other.<\/p>\n
The problem is that the vsMeshMaker utility class will not merge together vertices which have different texture coordinates — even if those texture coordinates are actually the same.<\/p>\n
<\/p>\n
For example, in the image above, the top face of that cube has vertices with texture coordinates (0,0), (0.25,0), (0.5,0), (0.75,0), and (1.0,0). \u00a0(yes, there are five vertices defining the top face of the cube — the vertices for (0,0) and (1,0) overlap each other, and are only different for texture mapping purposes).<\/p>\n
This situation was absurdly common; \u00a0two vertices which are exactly the same, except for the point in the texture that they’re referring to. \u00a0And even the texture coordinate is (technically) referring to the same point; \u00a0just expressed differently so that OpenGL renders the correct part of the texture map to the pixels around the vertex. \u00a0And the vsMeshMaker didn’t understand this situation, and so wouldn’t weld the vertices together.<\/p>\n
The usual result of this (which was very common in MMORPG Tycoon 2) was that you’d get a strange lighting discontinuity along one edge of every object in the world. \u00a0In this case, there was a sharp line visible running diagonally along the top of the cube pictured here. \u00a0It’s been that way for months and months, and I’d basically been doing my best to simply look the other way, when taking screenshots. \u00a0At last, I’ve worked out how to get the vsMeshMaker to weld those vertices together correctly, without breaking the texture mapping.<\/p>\n
Very pleased to have it working now. \u00a0And the answer made me feel silly for not having thought of it before; \u00a0don’t actually weld the vertices together, just pretend to have done so, and have the pretend-welded vertices check with each other to determine their final, welded normals.<\/p>\n","protected":false},"excerpt":{"rendered":"
So this was a long time in coming. \u00a0For quite a long time, my procedural geometry generation system has been generating texture coordinates for the objects it makes. \u00a0This is so that (if\/when desired) textures can easily be applied to the generated objects. Texture coordinates basically work by assigning coordinates to each corner of an…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[33,24,25],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-y3","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/2111"}],"collection":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/comments?post=2111"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/2111\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=2111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=2111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=2111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}