New video on 4way blends

Started by wallworm, December 29, 2016, 06:50:00 PM

Previous topic - Next topic

wallworm


wallworm


lauris47

#2
(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?

wallworm

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.

lauris47

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.

wallworm

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.

lauris47

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

wallworm

#7
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]

wallworm

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?

lauris47

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?

wallworm

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.


  • Vertex Alpha (-2) For 2Way Blends on displacements
  • Map Channel 10 for 4way Blends on displacements
  • Map Channel 1 for everything else

I will report this directly to Autodesk.

lauris47

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)

wallworm

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.

lauris47

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, 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.


wallworm

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.

SMF spam blocked by CleanTalk