- Home /
How To Export Blender Mesh w/ Shaders to Unity
I am a beginner following CG Geek's How to Create a Low Poly Tree in 1 Minute and I want to export this tree, shaders and all, to Unity so I can add it to my game. How would someone go about exporting a (Cycles Rendered) mesh To Unity? Thank You In advance!
I know It takes a few steps to do this, so since I'm a beginner (and i have no idea what I'm supposed to do) , could you be so kind as to include a step-by-step guide kind of like a for dummies book. THANKS
(BTW, I know there are a lot of people that already asked this but I tried them and they don't work. Also (I think), my circumstance is kind of specific)
Answer by tuinal · Jul 25, 2020 at 12:47 AM
The mesh is easy. Export as FBX. Click 'FBX ALL' with scale, and 'Experimental: Apply Transform' unless you have a lot of nested objects. If this FBX is in your assets folder you can just drop it into the scene.
Materials/shaders are a bit more complicated. You can't strictly speaking export a Blender shader to Unity. You can export material properties, though.
It's probably worth explaining what these things are (admittedly in a quick, slightly abstract way!).
The shader is the code sent to the GPU that says how to position the vertices and render the pixels of it's triangles. Cycles & Unity both provide visual editors that let you tweak inputs and compile the tweaking into the shader, but the heavy lifting is still done by an engine-specific 'master' node (e.g. Principled BSDF in Blender or Standard/Lit in Unity). These 'plug-in' to the pipeline and are not interchangeable between editors.
A material is data, that defines which shader to use, and the inputs (textures, floats etc.) for this shader. You can thus have a lot of materials using the same shader, but inputting different textures. Advanced shaders typically take multiple maps; a basecolor for what color something is, then normal, and metallic and smoothness maps that describe how light interacts with it. This is what lets textures give the illusion of height, wetness, etc. in modern games. If you just want the top of the tree to be green, you just need a base map. If you want it to look like photorealistic leaves, you need to worry more about these additional maps.
A Renderer (meshrenderer etc.) in unity needs a material, which in turn points to a shader compatible with the Unity pipeline. You can't stick Blender's principled BSDF into Unity. But you can use the fact both basically do the same thing, by giving them the same inputs.
The easiest way to do this is: 1) Identify the textures (at a minimum base color, more advanced metallic/smoothness, normal map etc. you're using them in Cycles they'll be input nodes. Export them to /assets as png. 2) Create a new Unity material. Assign these same textures to the material. 3) Drag & drop the material onto the object in Scene view. If you're lucky it will be fine. If not, you will need to edit the textures to conform to the expected material inputs. The common problem is inverted values, e.g. blender might think a black pixel in a metallic/smoothness is maximum smoothness whilst Unity thinks a red pixel is (this is example not fact!). I recommend using texturing software (e.g. Substance) if you're serious about texturing, since it deals with a lot of this for you.
Thank you so much man! I really appreciate you taking the time to write all this (: