1 (edited by vincentno1 2016-06-17 02:15:58)

Topic: How to draw a custom layer(fog-like) on map?

Hi,
I just bought this awesome asset on Unity.
It's great! Thanks for your great work.

I am trying to build a location base game. So I need to add an extra layer which stands for fog on the map.
and once user been to the place (I will use GPS to get the position) the fog will go away.
(Just like you are playing a computer game, something like Warcraft.)
Could you give me some hints how should I build this?
Since I am pretty new to Unity, any hint from anyone will be very helpful.
Thanks in advance.

Sincerely,
Vincent

Post's attachments

Attachment icon FullSizeRender.jpg 146.85 kb, 231 downloads since 2016-06-16 

Re: How to draw a custom layer(fog-like) on map?

Hello.

I think the hints here will not be enough.
We will make an example of how to do it.
It takes time.
I hope within 24 hours we will give you an example.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to draw a custom layer(fog-like) on map?

Omg!
Are you some kind of angel?!
Thank you very much!

Re: How to draw a custom layer(fog-like) on map?

Example attached.
Requires Online Maps v2.4.0.41+.
If you do not have it, just update Online Maps through the built-in update system.

Post's attachments

Attachment icon FogOverlay.cs 6.76 kb, 384 downloads since 2016-06-17 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to draw a custom layer(fog-like) on map?

May I say you're godlike to me?!
Thanks for this big help!
It might takes months for me to figure out by myself.
Although it's late in night here, I am too exciting too sleep now.

One more question,
if I want to improve the performance (since I will have lots of point to set as unfog)
should I start from make Radius and fogTextResolution vary with different zoom size?
Any other suggestion where I should work on?
Thank you very much again.

Sincerely,
Vincent

Re: How to draw a custom layer(fog-like) on map?

Yes, this code should be optimized.
This is just the initial implementation of the idea.

Yes, you can have a different radius and fogTextureResolution.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to draw a custom layer(fog-like) on map?

Hi Alex,

I am working on optimizing this fogOverlay.
I used SQLite to optimize ways to store and search for points(visited).
But I really have no clue how to optimize the rendering part make it faster and more fog-like.
Do you have any thought on it might help me?

Thanks,
Vincent

Re: How to draw a custom layer(fog-like) on map?

Hello.

You have a few ways optimize the algorithm, for example:
1. Reduce the number of points.
Convert geographic coordinates to tile coordinates.
If the distance to the last drawn point less than 3-10 pixels, ignore this point.
2. Cache fog texture for the previously generated tiles.
3. In some places, this code can be optimized to reduce the amount of computation.

What do you mean «more fog-like».
Please explain in detail.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to draw a custom layer(fog-like) on map?

Thank you for these hints!
Working hard on it now.

By «more fog-like» I mean draw a fog overlay looks like natural fog, instead of flat white layer.
I am trying loading texture to default fog and then adjust the transparency around the points.
Since you have great experience on Unity, wondering if you think of anything other approach I can try? Maybe some masking function might be useful? If you could give me some keywords, that will be a big help!

Thank you!

Sincerely,
Vincent

Re: How to draw a custom layer(fog-like) on map?

Hello.

Actually, I do not see a problem to do it.
In «Start» generates «defaultFog».
You comment (remove) these lines and use the fog texture (with Read / Write Enabled - ON).
That's all. You have fog texture.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to draw a custom layer(fog-like) on map?

Oh! That's what I am trying.
Was wondering if there is other better way to do it.
But it looks like it is very good already.
Thank you!!

Re: How to draw a custom layer(fog-like) on map?

Could you please add a short piece of code with a simple change of the circle into square?

It seems to me overly complicated and something is telling me that if I wanted to show "tile" square instead of the circle, it could be less performance-demanding.

Re: How to draw a custom layer(fog-like) on map?

Hello.

This will give you the acceleration of only one operation (multiplication) per pixel, and will not affect performance.
To greatly increase performance, you need to use optimization tricks (for example see post 8).

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to draw a custom layer(fog-like) on map?

Alex Vertax wrote:

Hello.

This will give you the acceleration of only one operation (multiplication) per pixel, and will not affect performance.
To greatly increase performance, you need to use optimization tricks (for example see post 8).

Thanks. I have a list of tiles in zoom 17 that has been visited and I want to show them in all possible zooms as you do here.

I find it difficult to change your code to do this simple thing though.

Re: How to draw a custom layer(fog-like) on map?

Example attached.
I hope this helps.

Post's attachments

Attachment icon FogOverlay2.cs 8.71 kb, 400 downloads since 2017-04-07 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.