New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can objects (roads, buildings) be textured? #31

Closed
johnsnook opened this Issue Sep 14, 2016 · 9 comments

Comments

Projects
None yet
2 participants
@johnsnook

johnsnook commented Sep 14, 2016

This may be totally due to my ignorance of unity materials and textures, which is vast, but I can't seem to get a textured material to render properly on roads or buildings.

Sorry to create an "issue" out of it, Baran.

@brnkhy brnkhy self-assigned this Sep 14, 2016

@brnkhy

This comment has been minimized.

Owner

brnkhy commented Sep 14, 2016

No problem man ;)
I'll give a tldr first; the problem is the UV generation. (I'm not expert on UVs or materials by the way so might be missing some stuff)

Road UV's should be quite easy really, I can easily do that. Landuse UV is harder, not sure about those. Water is extremely easy as well. But the real problem is the building UVs

I did a little experiment on building UVs last night; http://imgur.com/AFZBScY
It's such a huge issue though, would take quite a few paragraphs to describe it here.
First of all, we can't use same texture for everything so we'll have to copy materials and change textures.
then we'll have to divide mesh into to, roof & sides to be able to use repeating properly. If we decided not to go repeating textures (the image above uses that), we'll need extra vertices everywhere, especially on side walls.
I feel like the first option would be much easier but that's still require quite an effort. I'll most likely publish that repeating UV thing in the image just for simple usage (noisy texture instead of pure color would made everything look better for example) but a real solution would take soo much time. If there's anyone interested (and a little bit experienced in vertex/UV math) in that, I can tell the whole story for a head start.

Roads would be easy as I said, but they'll look ugly even if I do the UVs as they are disconnected in most place. And that's the osm data, not my generation code so cannot really fix that without huge effort either :(

I fucking love working with vertices, indices, triangles,uvs or generating meshes in general but damn they take sooo much time.

Still, as I said, I can get roads and water UV working in a day I believe.

@johnsnook

This comment has been minimized.

johnsnook commented Sep 15, 2016

Well, I've been enjoying looking through your code in the various factories for inspiration. I can certainly appreciate the amount of effort. I know zip about UVs though. I'll try to do some research and see if I can get up to speed fast enough to be of any use.

@brnkhy

This comment has been minimized.

Owner

brnkhy commented Sep 15, 2016

I pushed the simple UV thing on dev branch last night, it's in the building factory (that should be tidied up though, that function is a total mess, hard to read and confusing at the moment)
what it does is simply applying that texture in every 1unit square area. That's like the simplest thing one can do, hardly any uv calculation/math there. But that's actually one of the better ways to do it BUT we need roof as a separate entity/material for that. We can do that repeating texture thing in side walls but same texture wont work for roof. and we cant do it if we divide texture into, say 4 segments using one for walls and one for roof.

so wait wait, I'll try to clarify it all; to me there is two ways of solving this problem (considering just one building at the moment though);

  1. Use separate mesh/material for roof, then use representative texture for both. I already did the repetition part but create roof as another entity might be costly for us. That's like 2x draw calls, materials and extra calculations. (well we can merge ALL roofs in the city I guess)

2)subdivide side walls (this would be haaaard..... I guess) and use one texture/atlas for roof&side walls. Admittedly this sounds worse and worse as I keep writing. we'll have to create sooooo many extra vertices just to save extra draw calls..... damn I have no idea which one is better really.

As you can see, I'm confused as hell john, help me out with this :)
(I wonder if we have anyone pro in these matters, stalking around. would really love some input)

@johnsnook

This comment has been minimized.

johnsnook commented Sep 15, 2016

Am I looking at the right documentation for the TriangleNet you're using? It looks like very useful stuff.

Also, noob question, will that dll compile onto android? If yes, is it because it's an "unmanaged" dll? or do you have to put the source in?

@brnkhy

This comment has been minimized.

Owner

brnkhy commented Sep 15, 2016

it should compile on android yea, both managed and unmanaged dll would I believe. If not, we can always use the source code, I just thought it'll be easier with one file instead of dozens in the source.

@johnsnook

This comment has been minimized.

johnsnook commented Sep 15, 2016

So, I've been playing with your dev buildingfactory and have found a different issue that effects this one and performance: If a building is on multiple tiles then multiple buildings are generated.

I'm using tilesize of 600 and a zoom of 18 here. I pulled the buildings apart in the scene so you could see them. Obviously, I've got the mergemeshes flag set true. This building just happened to straddle 4 different tiles, so 4 different meshes were generated.

bug

Should I create a new issue for this?

@johnsnook

This comment has been minimized.

johnsnook commented Sep 15, 2016

I want to say however, that textures on buildings is working (when mergmeshes == true). I can resize the textures using the tiling property. Roofs would be cool but great work in such a short time. Fixing the multiple buildings problem will get rid of the weird shimmer.

And, as far as I can tell, buildings are the only thing being duplicated. Roads and water seem unaffected, since they're just 2d polygons.

@brnkhy

This comment has been minimized.

Owner

brnkhy commented Sep 15, 2016

Double buildings is a known issue (but not logged, my bad). It was actually "fixed" by a simple hashset check but then I realized, destroyed buildings wasn't removed off that list so deleted it all together. Fix is rather easy, all we need is a simple destroyed event on tile objects but.... I was being lazy.

well yea textures are "working" but it's rather useless at this state. That building in your screenshot looks like a slice of cheese :)

@brnkhy brnkhy added the enhancement label Sep 15, 2016

@brnkhy

This comment has been minimized.

Owner

brnkhy commented Oct 4, 2016

pushed on the master branch, we can open new issues for further improvements

@brnkhy brnkhy closed this Oct 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment