Skip to content

Attempt to make an influence map in Unity like the one in Endless space.

License

Notifications You must be signed in to change notification settings

Niwala/InfluenceMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InfluenceMap

Attempt to make an influence map in Unity like the one in Endless space.

This project is a proof of concept. A small personal challenge. The code is delivered as is and no big optimization has been done on it.

Kpxi7sArxr

How it works

I make multiple passes between two textures to achieve this result.

  • In the first pass I render all the discs with negative values as an SDF using the smin function of Inigo Quilez.

Unity_aHrTsTaNJe

The values being in negative, the preview above has been reversed for a more comprehensive rendering.

  • I take only the lowest channels (and therefore the ones closest to the center of their discs) and output a flat value. If green is the channel with the lowest value, I get pure green (0.0, 1.0, 0.0, 0.0). This gives me clean blobs where the zones do not overlap.

Unity_jzaNsi3uZl

The black area is the alpha channel. It is not visible but is also used.

  • I blur to get nice even gradients. The gradient is done in two passes (vertical then horizontal for preformance reasons)

Unity_QTCxuzKiiS

  • Then it is very easy in the last pass to reverse the gradients and isolate nice edges too.

Unity_iDYWt0fMDG

Here I use custom colors by channels, so I could put white instead of the alpha channel.

Second version

I made a second version in an attempt not to be limited to 4 colors. I also replaced the blur by a jumpFlooding, in order to have a fast result for the gradients and more exact borders between the blobs.

This version relies much more on a compute shader & compute buffer. It can potentially become very heavy quickly. In the other hand, it should be possible to easily compute it on a small buffer and resized afterwards only for the last step.

Unity_bhcBV2bIOk.mp4

vlc_WcpmQUuGqQ

About

Attempt to make an influence map in Unity like the one in Endless space.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published