3

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?

4
  • 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. Commented Dec 13, 2018 at 14:03
  • 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). Commented Dec 13, 2018 at 14:51
  • 1
    How are the models formatted? Have you considered converting the models to a more standard format for which there are already loaders like GLTF? Commented Dec 18, 2018 at 5:22
  • @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 Commented Dec 18, 2018 at 8:24

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hey Nika, thanks for your quick answer! I already knew that the Standard Shader in Unity didn't accept those Physical parameters (accept for the Height Map, thanks!). I was hoping that someone somewhere had the same idea of implementing the ThreeJS materials in Unity and the code would have been available on GitHub. I'm afraid that I have to write those shaders myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.