Wall Worm Forums

Design Tools => Materials and Textures => Topic started by: wallworm on December 29, 2016, 06:50:00 PM

Title: New video on 4way blends
Post by: wallworm on December 29, 2016, 06:50:00 PM
New Documentation on Using 4Way Blends (http://dev.wallworm.com/document/221/using_4way_blends.html)

And video:

https://www.youtube.com/watch?v=mtUDJ12WfSs
Title: Re: New video on 4way blends
Post by: wallworm on March 13, 2017, 03:01:59 PM
Today I updated the docs for using 4way blends (http://dev.wallworm.com/document/221/using_4way_blends.html).
Title: Re: New video on 4way blends
Post by: lauris47 on July 23, 2018, 07:05:49 AM
(This question was updated multiple times)

I see that displacement map textures are working inside 3Ds Max.
How can I maintain such textures when I export to FBX? Is it possible at all?

Would it be possible to bake shader/material to a single texture, so that can be reassigned to a regular material that is supported in export of FBX?
Title: Re: New video on 4way blends
Post by: wallworm on July 23, 2018, 11:10:20 AM
This is likely a tricky issue. First, Wall Worm uses DirectX Shaders for blend and 4way. I do not know if there is a one-to-one translation.

I have written a function to convert the blends to OSL shaders in a Standard material. This requires using Max 2019+. I have not exposed these functions to the UI yet. Also, I do not know if Maya will use OSL shaders.

So the short answer is that it is theoretically possible but not tested.
Title: Re: New video on 4way blends
Post by: lauris47 on July 24, 2018, 04:41:08 AM
Ok, Thank you for an explanation. With current project I tried multiple versions of Maya and Max. I'll try 2019 Max to see how it works over-there.

However, I was thinking that baking the shader to a texture and later use it as a single texture would be a waist of resources. Considering that each surface actually uses same textures but blends them while baked textures would require to combine these few textures to huge maps for each surface (building, ground etc.) to maintain individuality. I think newest Doom game used 16k textures, so it is possible.
Title: Re: New video on 4way blends
Post by: wallworm on July 24, 2018, 10:06:18 AM
The only sane way is to use native shaders. In Max there is a DX shader (viewport) and an OSL shader (render) for this. Baking entire scenes would create too many large bitmaps if you wanted to keep any resolution.
Title: Re: New video on 4way blends
Post by: lauris47 on July 24, 2018, 11:08:26 AM
Hmm, but these shaders are not supported trough FBX export. I used Send to Maya from Max, which I believe uses FBX as well, and all textures disappeared. Only ones that remains are from the regular geometry/materials. I need to find a solution where at least the base texture is transferred. Maybe you have suggestion for that?

I attached pictures of both Maya and Max 2018. I think the blending on 2018 Max is shown correctly? I see different textures appearing on same faces.

Thanks
Title: Re: New video on 4way blends
Post by: wallworm on July 24, 2018, 11:14:27 AM
Yeah, this is an issue of FBX not supporting all Materials. And if it did, it would also depend on Maya supporting the materials/shaders. Those that are going through are Standard materials.

I will see about exposing the function to convert the DX shaders to Standard using OSL. Once I expose it, this will require using Max 2019. Again, the DX-to-OSL isn't yet exposed. I'll let you know when it is.

Once I add it and you have latest Wall Worm installed, you can Wall Worm > Wall Worm Importers > Batch Level Importer and choose FBX as the generated file to make it. Stay tuned.

[EDITED]
Title: Re: New video on 4way blends
Post by: wallworm on July 24, 2018, 04:24:28 PM
I have updated WW with exposure to the ConvertBlendToOSL methods. However, it won't do you any good. The OSLMap is not preserved in FBX. I'm also not sure that all the map channels are exported (4way blends use channel 10 and they seem to be missing.

Not being a Maya user I think this is the end of the road for my advice on this topic. At this point, why not just keep it all in Max?
Title: Re: New video on 4way blends
Post by: lauris47 on July 25, 2018, 03:17:32 AM
Thank you very much.
For me it is most important to export it to FBX, because FBX is supported across all mainstream game engines and 3d programs. I will load final maps in Unity not in Hammer.

Out of curiosity, does 4way blend remains when exporting map back as a Game Level from 3ds Max WW?
Title: Re: New video on 4way blends
Post by: wallworm on July 25, 2018, 09:54:28 AM
I see. Still, exporting to FBX to send to Maya to then send to FBX again for Unity seems like an extra hassle.

In any event, the FBX tests I did yesterday showed that the 4way blend channel was lost (UV Channel 10) when saving scene to FBX. So I need to amend my comment above.

WW Uses Channel 1 for almost all things. But there are a few exceptions.


I will report this directly to Autodesk.
Title: Re: New video on 4way blends
Post by: lauris47 on July 26, 2018, 03:24:17 AM
Ok thanks. For now I will have to use one texture instead of 4way blend style.
When I have some spare time I'll try to learn 3ds Max basics to bake 4Way blend materials to textures and see how result looks.
(I am Maya user, Max is so different and difficult for me)
Title: Re: New video on 4way blends
Post by: wallworm on July 26, 2018, 10:07:57 AM
Just a heads up. After more testing, I have discovered that the FBX does preserve the 4way blend channel. Unfortunately, it moves it from channel 10 to channel 2 (at least for a return trip to Max). So you can still render the blends in other DCC provided you have a shader for that in the DCC that will use the data as needed.

The DX shader used in Max is preserved in the FBX and comes back to Max fine.

The remaining question would be if Maya can use Max's FX files. If so, it may just be an issue of the path to the bitmaps not working in the FBX for how Maya expects them.

Finally, in terms of baking an entire level. Doing this would be catastrophic for almost any target application as mentioned in an earlier thread. The only sane solution is to replicate the 4way shader in the target DCC or game engine.
Title: Re: New video on 4way blends
Post by: lauris47 on July 27, 2018, 08:15:02 AM
Maya maintains the same dx11 shader reference, directly from Max, but it doesn't work. I tried loading same named shader from Maya, but it doens't work as well. I am not good with this.

Perhaps possible solution would be to manually add textures to a custom shader for example built in Unity on each model. On export these specific objects could use default material of Maya, just like I did now with a simple blin.

Then, material's shader inside Unity could be replaced with custom shader, or perhaps unity has something similar already, I need to do some digging.

If I understood correctly, how textures are blend together is kept in a separate texture, e.g. called "plaster_a_blend.tga", then according to strength of colour in that map, specific textures are exposed on the face of the mesh?
I did some shader coding inside Unity and I used such technique.

(I noticed that Unreal engine has 4Way blend technique as well https://docs.unrealengine.com/en-US/engine/ui/leveleditor/modes/meshpaintmode/vertexcolor/materialsetup/4way (https://docs.unrealengine.com/en-US/engine/ui/leveleditor/modes/meshpaintmode/vertexcolor/materialsetup/4way), maybe that one can be directly connected when model is exported from max to Unreal)
I will discard baking the textures as a possible solution.

Title: Re: New video on 4way blends
Post by: wallworm on July 27, 2018, 08:48:45 AM
If Maya is maintaining the DX shader, is it showing any texture at all? If so, it may be a result of the FBX bug mentioned above--that UV channel 10 is moved to UV channel 2. The 4way blend shader blends between the 4 textures based on the vertex colors (which are contained in channel 10).

So to explain the blending:

2way blends use Vertex alpha and an optional tiling blendmodulate texture to work with vertex alpha.

4way blends use map channel 10 (and no texture) for blending.
Title: Re: New video on 4way blends
Post by: lauris47 on July 30, 2018, 07:53:46 AM
Thanks. So of course it means that inside Unity, trough shader coding information from channel 10 (or if moved from channel 2) can be used for 4Way blending.

No, Maya does not maintain any textures from 3ds Max that uses that shader. Textures become just the default lambert color. I created replacement materials, just to have the base texture (the first found in .vmt). It doesn't look good but at least these models have some texture for now. Most likely 4Way blend will be required for my project, so better solution must be found.
Title: Re: New video on 4way blends
Post by: lauris47 on August 07, 2018, 03:58:18 AM
I was playing around with custom shader in Unity. You have mentioned that 4way blend channel is kept in channel 2 or 10 (depending). How do I use that information when coding?
If I look in uv editor UV channel where 4way blend information is kept, all I see is one dot - all uvs are in the same position, 0,0 in coordinates. UVs are 2D coordinates? Or is it 3D, 4D... but that is not shown since, UV editors don't need them?

Thank you.



Quote from: wallworm on July 26, 2018, 10:07:57 AM
Just a heads up. After more testing, I have discovered that the FBX does preserve the 4way blend channel. Unfortunately, it moves it from channel 10 to channel 2 (at least for a return trip to Max). So you can still render the blends in other DCC provided you have a shader for that in the DCC that will use the data as needed.

The DX shader used in Max is preserved in the FBX and comes back to Max fine.

The remaining question would be if Maya can use Max's FX files. If so, it may just be an issue of the path to the bitmaps not working in the FBX for how Maya expects them.

Finally, in terms of baking an entire level. Doing this would be catastrophic for almost any target application as mentioned in an earlier thread. The only sane solution is to replicate the 4way shader in the target DCC or game engine.
Title: Re: New video on 4way blends
Post by: lauris47 on August 13, 2018, 03:28:01 AM
I was able to replicate the shader at least partially. I got two textures blending, according how Valve team painted them in Unity. That information is stored in vertex paint (PVC paint vortex color) - didn't know that there is such thing.
I will work more to get more detailed result, bump maps and specular shine.
Title: Re: New video on 4way blends
Post by: wallworm on August 13, 2018, 08:32:08 AM
Sorry I just got back from vacation.

In terms of Vertex Colors. They are technically just map channels. The vertex color channel is map channel 0. The channels WW uses are explained above. The map information is included in the FBX. You just have to have your shader use the map/color information in the channel it's coming through in the FBX--which looks to be map channel 2 instead of the vertex color channel.