3
votes

I'm working on a project in Unity that uses AR to place products in the real world. These products (geometry & material) are downloaded from a http server and converted into a gameobject in Unity.

These products are originally created in ThreeJS (don't ask why) and have a different geometry/material structure in comparison to Unity geometry/materials.

I got the geometry working, but I'm having trouble with the materials. The 'Standard' shader in Unity doesn't contain all the parameters to create the material (like: alpha map, environment map, refraction, displacement map, roughness map, double side, etc..).

I've looked to different plugins/libraries in the Asset Store/GitHub (like LUX, Bit2Good, Shader Sandwich or Simple Physical Shader) but it seems that they are all missing some parameters too. I'm thinking of writing the Phong/Physical shader myself, but that definitely would take me several weeks to complete.

Do you guys have any suggestions?

1
Writing a basic Phong shader shouldn't take too long; there are plenty of examples on the web for the math related to the parameters you mentioned. I would also look at the FX Composer from NVIDIA. It may speed that process up as you can view the changes in your shader in real time, the only downside with it is that NVIDIA no longer provides support for it. - Taco タコス
The Blinn-Phong shader should indeed be easy to implement. I am more worried about the Physical shader. I was wondering if someone had the same idea of implementing ThreeJS materials in Unity and put the code GitHub (or in the AssetStore). - Tostifrosti
How are the models formatted? Have you considered converting the models to a more standard format for which there are already loaders like GLTF? - Garrett Johnson
@GarrettJohnson The models are converted in a homemade format. After parsing this format, the geometry part will be passed to a homemade loader (which will be replaced in the future by Draco if the repo is more stable). The material part will also be parsed by a homemade loader that uses the 'Standard' shader of unity. I want to replace this shader to use more parameters which I described in my question above. Also the GLTF loader you are refering to, seems to be still on the road of release1.0 - Tostifrosti

1 Answers

3
votes

There is no alpha map in Standard shader - the alpha channel of the main texture is used as alpha map.

There is no environment map either - use Cube Maps as Reflection probes.

There is no refraction in standard shader - it's a standard shader.

Displacement map in standard shader is called height map.

Roughness map - not in standard (the closest you can get is invert it and use as occlusion map).

Double sided - nope.

You'll need to write your own shader for all this.

Suggestion is:

Step 1. find a shader for each of those properties

Step 2. combine them by copy-pasting relevant code