I know right? If that is the case then there is hope for the rest of us! Or all else fails, we beg for pictures/downloads.
In other news, I discovered a feedback loop in my precipitation system. Instead of wrapping the world twice with the winds to account for the world wrap, I think I will run the winds 3 times from 3 separate starting longitudes and then average the 3. I think that should take care of the wrap without the feedback loop.
Hey , no itāll update, you can drag the grid left/right/up/down and it will move over the sphere, but getting it to wrap is what I meant.
The wrapping bit is a bit tougherā¦
All I did was take the math that the āTiling a Sphereā¦ā guy posted and applied it to World Position Offset in a material.
Iāve attached the material (4.6.1). A few things:
Just like the posted code, it assumes the center of the world is 0,0,0
thereās a slight modification to better adapt to things with Z height
You can adjust the radius in the material (or an instance as a param) but I magic numbered the multiplier for the mask
If your level has more than one Actor, make sure to turn off Occlusion culling if you want to keep things from flashing on and off. Not advised for really making a game unless you want to handle occlusion on your ownā¦ but for something like this, you probably would handle culling anything outside of the sphere.
&stc=1
Edit: Oh yea, that Culling bit is under Edit Menu -> Project Settings -> Rendering
That is just plain epic. And the material seems to be quite manageable compared to many that I have seen. I still donāt know what 99% of the nodes are really doing, but whatever!
And yeah, I saw the occlusion culling when I scrolled north and the oceans disappeared followed shortly by everything else. I donāt really know anything about that, but it seems like a problem that could be dealt with.
So a few questionsā¦
How do I alter the world position in the material? Also, can I feed the position to the material from blueprint(different map sizes would require different parameters)?
What exactly is the mask portion doing? It was greyed out in the materials that I pasted it into so I am not sure if it is working or not.
What exactly is the problem with wrapping it around? You mean around to form a sphere instead of a hemisphere? That might not even be necessary if I can just hide the flat tiles in the background and get everything to dynamically update as I scroll around. Of course, it would be all around better if I could actually wrap it into a sphere though(background, camera stuff, etc)
I didnāt see it update as I moved around, but I donāt currently have a way to drag the things around. That sounds like you would have to move all the tiles past the world positionā¦ is it possible to just move the materialās base world position past the tiles?
Thanks again ! I didnāt think this would even be possible in blueprint/editor and I had just about written off ever making the map into a sphere, but now I see it is not only possible, but something I could probably pull off(especially with help here and there from pros like you ).
That looks amazing! If you needed something to immediately diffreantiate yourself from Civ in screenshots you just found it! I might just go back to my original plans and make a globe-based game myself when Iām done with the marketplace release. Canāt wait to see how it looks on my own grids. Thanks for doing this, !
So ideas. I think I understand why actual wrapping is a problem. I still wonder if the hexes in the top and bottom rows could somehow be smashed down to fit into the poles of the sphere while still keeping them as hexes. I could probably treat the whole smashed region as a single space. I donāt know how the actual math involved with that would work though, so someone would have to have a genius solution on hand.
Anyway, I think using this projection method would work pretty well as long its hemisphere reaches from pole to pole. Then scrolling around would just look like you are spinning a globe, apart from scrolling near the poles. I will have to play around and see how it looks. This would still require me to have 2 shadow maps and the teleporting, barring some better idea, but it could be manageable as long as the projection doesnāt add any large performance load.
So, in order to get the flat portion of the map out of the background, could the projection somehow be inverted so that the flat map is behind the camera but the hemisphere displays in the front of the camera? It seems like the world offset would just have to be pushed down in the Z by some value and it might work?
Yeah, this would be a pretty awesome selling point. I think there are quite a few people floating around the forums who could take this and run with it. I didnāt realize the material editor let you just bend spacetime to your will.
Did the offset bit, and added a few params for the various settings. You can still move the mesh under it and the sphere will stay put, but now itāll be at the X,Y offset you want. Also thereās a bit for masking the flat projection out, and a param for modifying itās radius.
Iām working on how to make the Z height work more properly, so I didnāt include an offset for Z really. If you offset it on Z, weird things happen.
Remember to make an instance of this material so you can quickly use the parameter values in it, or else itāll take forever to get things where you want them
And, yea, there will be some oddities using this projection, like the poles of your map will have more land mass than anything else on the āsphereā and will continue left to right forever =) But, I think thatās fine for a fun way to view the world. And you can always just back this bit of the material out.
Took me a bit, but I figured out where I was being dumb, I was forgetting to subtract out the original world position of the vert, so it ended up kind of doubling the size of the sphere (and everything else).
Should make it easy to get the Z height bit working.
Cool. I havenāt dealt with material instances, but they seem pretty useful. I will upgrade my system and use your material as the parent.
I see how to add a Texture Parameter to the material, but how do I get more complicated Material Parameters into the material instance? For instance, a texture parameter is fine for most of my tiles because they just have a texture, but the water tiles have a lot more going on. Is there a way to stuff all of that into a single parameter or do I need a Parent Material for each type of material?
So the Offset just uses the RGB channels to hold the data? R=X, G=Y, and B=Z?
I feel like it is a bit too curved and/or tall. Like it is a little more than a hemisphere. Maybe due to being a little too high in the Z? If you look at it from certain angles it looks like it is 70-80% of a globe even though it should technically only be 50%(hemisphere). Or maybe my eyes are badā¦
Implementing the material instance system was pretty enlightening. Just figuring out how to work parameters makes the whole thing make more sense.
So I think before I go any further working on the other things, I need to see if I can get the rotation/movement around the sphere working.
Can I access the Offset Parameter from blueprint? Is the best way really to move the whole map around the world position? If so, what is the best way to grab and move that many objects?
you can use the HeightMultiplier parameter to squish it a bit, but donāt offset Z, it does really bad things. If youāve made a material instance, if you edit it, under Parameter Groups -> Sphere youāll find all the exposed parameters. If your mesh is +/-Z the sphere will distort, itās best if the Z of your mesh is generally 0+ (with -Z becoming really odd).
And yea, the offset parameter is RGB -> XYZ
Finally the Param MaskRadiusMultiplier looks to be really good around .407
Collision obviously doesnāt project with the material. Can it be mirrored to the material? I have a feeling if I took it that far I would be moving the projection out of the material and splining the whole thing.
Spline meshes wonāt project(the rivers). Probably because they are already having their world position offset? Can these two methods be combined?
Tiles phase in and out of view randomly and dependent upon camera/character location. Often times only a handful of tiles phase out, and other times all tiles of the same instance(ie Deserts) phase out together.
There is something weird that is teleporting me small distances away when I move close to the sphere.
My collision volumes(which I use for my color overlays & collision) donāt seem to like being projected. They basically donāt show up except for a split second when I am moving around very close to the sphere. They also sometimes blink in and out in random chunks when zoomed far out.
Lots of visual artifacts around the base of the sphere.
The base of the sphere projection seems to be some distance off the actual map. It is hard to gauge but I am guessing a few hundred UU higher on the Z. I donāt know if that was intentional or if it could cause any problems.
I set the HeightMultiplier to 1 and that seems better. I will play around with it and see if I can find a good level. I am probably going to want to squish it just enough to make both polar ice caps visible in the above image.
.407 on the Mask seems like a good fit. I am wondering how much of the visual artifacts around the base are being caused by the mask being too close to the projection transition point, so I might mask it just a bit more to see if it helps.
So is it possible to set the Offset parameter in a master material from blueprint? I was searching for nodes but couldnāt find anything. I will go digging in the docs some more because I am pretty sure I read that such communication is possible.
I basically just need a way to lock character location to the offset in the materials. Changing the offset seems to be the best bet, but other than that, what options are there? Moving all tens of thousands of tiles/actors/etc around the world position?
Collision is something that Iāve thought about, and basically, youād need to run the same math on your collision shapes, to get them into position, but then rotate them into position by having them face towards (or away from) the center of the sphere (the offset point). The fact youāre using hexes and the distortion caused by the math would probably mean some level of offset to scale would be needed or the culling of collision outside of a truly usable area at the top of the sphere.
If I get a moment today Iāll see if I can toss something together to show what I mean.
Got the scrolling working, and it looks and feels amazing!
I housed all the parameters in the material with a Material Parameter Collection. Then I put the Parameter Collection in the master materials and plugged it into all the relevant points. Then, in my Character blueprint I called on the parameter from the Parameter Collection and tied the position of the Offset Parameter to the Character position and used a Tick to update the parameter on the fly. So, as the character moves around, the Offset position moves with it. It looks like the world is sitting directly underneath you spinning around as you move. It is pretty sweet.
So now that I have it moving, I was able to confirm that the world is too curved, which was corrected by doubling the radius. The previous radius gave a full circle between the poles, when really I needed it to go all the way around. That also made the planet look much smaller than it really was. Here is how the same sized map looks with the proper radius:
Now that you can actually rotate and zoom the sphere it is great! Now I just need to fix the clicking part.
I really appreciate the help you have been providing! I didnāt even consider any of this as a remote possibility, and then bam! it all works.
Early on in development I was toying with creating the globe by physically aligning all the tiles in space, but even after I worked out the rough position and rotation of a few tiles they didnāt mesh well at the edges so I gave up on that. Wished I had saved the work because I think it would be pretty useful now for the volumes.
I donāt think I ever worked out the math to tile the whole sphere into a globe though.
I am going to have to toy with tying the Radius to the scroll wheel. I think that could basically accomplish what you are talking about. I donāt think it will be necessary on the larger maps, but the smaller maps will probably benefit quite a bit.
I recreated the sphere material in blueprint using the volume vector locations as the absolute world position, but that isnāt quite working. Getting some weird spoon shaped formation.
Apart from the opacity mask, the math is set up exactly the same way(unless I read some of the material stuff incorrectly). Basically everything that feeds into World Position Offset.
So, if the math offsets an individual pixel into a sphere shape, then it should also do the same for an actor. Except it isnāt.
I attached a sample of the material converted into blueprint. I will keep working on it.
I am thinking instead of collision volumes, I could create a collision sphere with a radius matching the projection and locating it at the offset point. Then, when I click on a tile, it hits the sphere underneath, gets the hit location vector, reverses all the projection math on it to put it on the flat map, clamps it to the nearest tileās vector, gets the index, and then I can take it from there. That sounds at least marginally more manageable than moving thousands of collision volumes on the fly while also keeping them tethered & rotated to the instanced tiles underneath.
Thanks, but if you are talking about the projection to the sphere, that is all . I am still trying to wrap my head around the math to even copy it a tiny bit for collision.
Thatās what I would have done. I donāt use collision volumes in my system anyway, just a single collision plane which I use to get hit locations and calculate the array index in much the same way you describe it. I see no reason why it shouldnāt also work with a sphere and reversing the projection math, and I think it would be lot cleaner than using lots of collision volumes. Iāve got everything you describe working except the sphere projection, so just ask if youāre stuck on any of the other points.
Yeah collision volumes are an old piece of my system. They get the job done, plus they are what I use for the color overlays. Dynamically moving thousands of volumes for the projection is going to be a pain. It could be done, but yeah a collision sphere should be better. Both systems have the same problem though, which is the need to reverse the projection from the Hit Location back to the flat map. Unfortunately, the projection uses some pretty complicated math that I donāt fully understand, so I donāt know where to make changes. I am pretty sure instead of adding the offset to the world position I need to subtract the offset from the Hit Location, but beyond that I donāt know what else needs to be touched.