Mesh Replacement Test

Show off your mod creations or just a work in progress.
Post Reply
User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Mesh Replacement Test

Post by TheLacus »

tyhender wrote:Damn,this would look so good in game!
But trees seem a little bit too bright,don't you think so?
As i said in my original post, that was only a random picture i found on the internet, it was only to test the code. If you want to see some real trees look here ;)

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Mesh Replacement Test

Post by Nystul »

Hi TheLacus!
I would like to optimizing my ReflectionsMod (besides trying to build it on the new mod system I would also like to make it compatible with your texture replacement facilities).

Would it be possible to extend your mesh/texture replacement solution and support MetallicGloss-maps in the future?

one thing I am not sure about is how to handle textures that have global metallic and smooth values for the whole texture (the metallic and smoothness sliders in the editor when not using a metallicglossmap texture).
Of course there is the possibility to create textures with all pixels set to the same value, but it is kind of an overkill.
While I was writing this lines I realized that one could use a 1x1 pixel texture although it still has a bit of a performance penalty for sampling a texture, where setting the metallic and smooth values would suffice. But I could live with 1x1 textures very well ;)

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Mesh Replacement Test

Post by TheLacus »

Nystul wrote:Hi TheLacus!
I would like to optimizing my ReflectionsMod (besides trying to build it on the new mod system I would also like to make it compatible with your texture replacement facilities).
That's great, though it's not possible to implement the replacement system on the ground unless we switch to a differen terrain setup. This is an anticipation for future improvements on this or the ReflectionsMod also works on others textures?
Nystul wrote: Would it be possible to extend your mesh/texture replacement solution and support MetallicGloss-maps in the future?
It should be possible to do so for every texture available in the inspector, using Keywords. Normal maps didn't work as-is and required a workaround (luckily we are hardly the only ones importing textures at runtime with unity), but it's probably only a single exception. Tomorrow i will try it in game and i will be able to answer this question with certainty. :)

Nystul wrote: one thing I am not sure about is how to handle textures that have global metallic and smooth values for the whole texture (the metallic and smoothness sliders in the editor when not using a metallicglossmap texture).
Of course there is the possibility to create textures with all pixels set to the same value, but it is kind of an overkill.
While I was writing this lines I realized that one could use a 1x1 pixel texture although it still has a bit of a performance penalty for sampling a texture, where setting the metallic and smooth values would suffice. But I could live with 1x1 textures very well ;)
It's possible to edit this values from script so we can just read them from an Xml file. My only doubt about this is that we end up making X number of accesses to disk for every texture, but i'm all for providing access to new features and let the users decide what their system can run.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Mesh Replacement Test

Post by Nystul »

TheLacus wrote:
Nystul wrote:Hi TheLacus!
I would like to optimizing my ReflectionsMod (besides trying to build it on the new mod system I would also like to make it compatible with your texture replacement facilities).
That's great, though it's not possible to implement the replacement system on the ground unless we switch to a differen terrain setup. This is an anticipation for future improvements on this or the ReflectionsMod also works on others textures?
for indoor floor textures it already should work well I think, but you are right about outdoor ground textures

TheLacus wrote:
Nystul wrote: one thing I am not sure about is how to handle textures that have global metallic and smooth values for the whole texture (the metallic and smoothness sliders in the editor when not using a metallicglossmap texture).
Of course there is the possibility to create textures with all pixels set to the same value, but it is kind of an overkill.
While I was writing this lines I realized that one could use a 1x1 pixel texture although it still has a bit of a performance penalty for sampling a texture, where setting the metallic and smooth values would suffice. But I could live with 1x1 textures very well ;)
It's possible to edit this values from script so we can just read them from an Xml file. My only doubt about this is that we end up making X number of accesses to disk for every texture, but i'm all for providing access to new features and let the users decide what their system can run.
not sure about the disk accesses. I thought textures are only loaded once on initial loading. I remember a texture cache implementation inside the dfunity core classes somewhere, but I am not sure if your mesh replacement facilities also use it ;)

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Mesh Replacement Test

Post by TheLacus »

Nystul wrote: for indoor floor textures it already should work well I think, but you are right about outdoor ground textures
You're right, i didn't think about that.
Nystul wrote: not sure about the disk accesses. I thought textures are only loaded once on initial loading. I remember a texture cache implementation inside the dfunity core classes somewhere, but I am not sure if your mesh replacement facilities also use it ;)
Yes, i know about it. Talking about, vanilla textures don't use metallic maps so we also need to edit the cache to save them too.
Anyway, i can confirm map import works just fine.

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Mesh Replacement Test

Post by TheLacus »

I've just made a PR for this one.

Textures/archive_record-0_MetallicGloss.png for maps

and you can use an xml like this:

Textures/archive_record-0.xml

Code: Select all

<?xml version="1.0"?>
<properties>
<metallic>0.5</metallic>
<smoothness>0.5</smoothness>
</properties>
Let me know if there is anything else i can do :)

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Mesh Replacement Test

Post by Nystul »

Wow that was fast - thanks a lot!

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Mesh Replacement Test

Post by Nystul »

Interkarma wrote:
Interkarma wrote:Nice work! This shows some real promise.

As Nystul mentioned, the ground tile textures are built into a specialised atlas for the tilemap shader. You can read about how this works here. The atlas pre-transforms (rotates and flips) all the tiles ahead of time and generates extra data to simulate wrapping or clamping depending on the tile. This allows the shader to blast out any number of tiles very quickly to a single quad in one draw call.

So changing the terrain textures is definitely possible - but would need a lot of extra work to overhaul the terrain system. The current tilemap setup is also dependent on Daggerfall's small tile texture size for everything to fit into a single atlas per climate zone. Larger textures would quickly blow out the max atlas size. A whole new approach will probably be needed by this point.
I just wanted to update this and suggest that it should be possible to revamp the terrain tiling system to use texture arrays, a new feature in Unity 5.4. This might overcome some of the problems inherent to the atlas setup and allow for easier replacement of these tile textures at runtime.

It's definitely something to investigate in detail as this kind of modding gains traction.
I started to revamp the terrain tiling system by using texture arrays instead of the atlas. I just spend a few hours and it already starts to kind of work. Will be a lot of work to do, but first experiments are promising...

The texture arrays approach should eventually give these advantages:
  • support for texture replacement and higher terrain texture resolutions (currently terrain textures are 64x64 pixels)
  • slightly better performance
  • no mip map "bleeding" into different tiles of the atlas - see the screenshots below
  • possible support for reflections from the RealtimeReflections mod on replaced terrain textures tiles
For the screenshots I had to deactivate the terrain transition ring of the DistantTerrain mod because it needs also to be updated to the texture arrays and this would have caused graphical glitches right now...

bleeding issue with the old approach:
Image

no bleeding issue with the texture arrays:
Image

User avatar
LorrMaster42
Posts: 65
Joined: Thu Dec 24, 2015 12:09 am

Re: Mesh Replacement Test

Post by LorrMaster42 »

Nice. How is terrain handled in DFU anyways? Can it be changed to include cliffs and such?

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Mesh Replacement Test

Post by TheLacus »

Nystul this is awesome, thank you :D

Post Reply