Honey Hex Framework and iOS
Aug 3, 2015 10:33:17 GMT
Post by jarzac on Aug 3, 2015 10:33:17 GMT
Hello,
I've been testing the Honey Hex Framework on iOS recently, and thanks to the help of Khash I've been able to have it run consistantly on my iOS devices (and on the Unity Editor on my Mac, which helps a lot )
First of all the hardware
Mac book pro with Unity 4.6.6 f2 (I still need to test with Unity 5)
iPhone 4s, 5, 6P
iPad 3 and new iPad air
Then, the tests
The first thing to do when you want to use the framework on iOS is to tell the engine you don't want to use Directx 11 (so you want to use directx 9)
This is done in a couple of places :
- First in the Player settings, even if you are building for iOS, select the PC settings and uncheck DirectX11 (sometimes Unity does weird stuff with that checked)
- Then in the settings : the framework uses a file in the "Streaming Assets" folder named : HoneyFramework.MHGameSettings. In that file set the value of dx11Mode to false.
- If you really want to make sure directx11 won't be used, edit the file MHGameSettings.cs and make sure the member variable dx11mode is set to false.
This will tell the engine not to use the directx11 terrain and chunks (which are not compatible with iOS, Android and Mac).
The issues
Now, if I run the app on my iphone 6 plus, it works pretty good.
1) If I run it on my Mac, I'll see mostly water (first issue).
2) If I run it on my iPhone 5 I can see only land and no water and no trees : everythin is flat, except the borders (second issue)
3) If I run it on my iphone 4s, it crashes due to memory issues (the generation of the terrain is taking too much memory).
To solve the issue 3, edit the file MHGameSettings.cs and reduce the chunkTextureSize. For me it was 2048, and reducing it to 512 did the trick (I'm pretty sure 1024 would work).
Issue number 1 is a bit more tricky. The framework builds the terrain height out of several maps. You can find these maps in Resources/Terrain/Ground. There are several types of maps :
_d means diffuse
_h means height
_m means mixer
Roughly : the framework uses the mixer to mix diffuse and heights. So for example if you have some mountains near some dirt, the mixer will make sure that the diffuse of both hexagon are not roughly cut, but are mixed together. Same goes for height. That way you alyways have a map that looks coherent.
How is it done ? Very cleverly
The chunks are rendered in a sequence of shaders (I won't go into details here). So first goes the height map, then the rivers, then the shadows, then diffuse, and so on...
So the maps (_h, _m) are sent to the shaders for treatment. The shaders expect RGBA maps, but the maps we are using are only RGB. Not only that : the mixer should have a transparency layer.
To fix this, first select the _h maps and check "Alpha from greyscale". This will force the textures to be RGBA.
Now select the _m files and check "Alpha from greyscal" and Alpha from transparency.
This should solve the issue and you should be able to see correct landscape on your mac.
The Issue number 2 I had with an iphone 5 and iphone 4s. Turns out it's due to a shader that's a bit too heavy for these device, and thus ruin the entire render process.
Edit the file WorldOven.cs and comment all the calls to BlurTexture. This should solve the issue on older iphone devices.
Now you should have a consistent rendering between all your Apple devices.
Next steps : replace the blur function / shader with a fast blur provided by unity and then test with Unity 5.
I've been testing the Honey Hex Framework on iOS recently, and thanks to the help of Khash I've been able to have it run consistantly on my iOS devices (and on the Unity Editor on my Mac, which helps a lot )
First of all the hardware
Mac book pro with Unity 4.6.6 f2 (I still need to test with Unity 5)
iPhone 4s, 5, 6P
iPad 3 and new iPad air
Then, the tests
The first thing to do when you want to use the framework on iOS is to tell the engine you don't want to use Directx 11 (so you want to use directx 9)
This is done in a couple of places :
- First in the Player settings, even if you are building for iOS, select the PC settings and uncheck DirectX11 (sometimes Unity does weird stuff with that checked)
- Then in the settings : the framework uses a file in the "Streaming Assets" folder named : HoneyFramework.MHGameSettings. In that file set the value of dx11Mode to false.
- If you really want to make sure directx11 won't be used, edit the file MHGameSettings.cs and make sure the member variable dx11mode is set to false.
This will tell the engine not to use the directx11 terrain and chunks (which are not compatible with iOS, Android and Mac).
The issues
Now, if I run the app on my iphone 6 plus, it works pretty good.
1) If I run it on my Mac, I'll see mostly water (first issue).
2) If I run it on my iPhone 5 I can see only land and no water and no trees : everythin is flat, except the borders (second issue)
3) If I run it on my iphone 4s, it crashes due to memory issues (the generation of the terrain is taking too much memory).
To solve the issue 3, edit the file MHGameSettings.cs and reduce the chunkTextureSize. For me it was 2048, and reducing it to 512 did the trick (I'm pretty sure 1024 would work).
Issue number 1 is a bit more tricky. The framework builds the terrain height out of several maps. You can find these maps in Resources/Terrain/Ground. There are several types of maps :
_d means diffuse
_h means height
_m means mixer
Roughly : the framework uses the mixer to mix diffuse and heights. So for example if you have some mountains near some dirt, the mixer will make sure that the diffuse of both hexagon are not roughly cut, but are mixed together. Same goes for height. That way you alyways have a map that looks coherent.
How is it done ? Very cleverly
The chunks are rendered in a sequence of shaders (I won't go into details here). So first goes the height map, then the rivers, then the shadows, then diffuse, and so on...
So the maps (_h, _m) are sent to the shaders for treatment. The shaders expect RGBA maps, but the maps we are using are only RGB. Not only that : the mixer should have a transparency layer.
To fix this, first select the _h maps and check "Alpha from greyscale". This will force the textures to be RGBA.
Now select the _m files and check "Alpha from greyscal" and Alpha from transparency.
This should solve the issue and you should be able to see correct landscape on your mac.
The Issue number 2 I had with an iphone 5 and iphone 4s. Turns out it's due to a shader that's a bit too heavy for these device, and thus ruin the entire render process.
Edit the file WorldOven.cs and comment all the calls to BlurTexture. This should solve the issue on older iphone devices.
Now you should have a consistent rendering between all your Apple devices.
Next steps : replace the blur function / shader with a fast blur provided by unity and then test with Unity 5.