I have a really nice looking crystal material using cycles applied to my object; it's pretty fast and very simple - Just one glass node. Is there any way to convert this into an HLSL shader for use wihthin Unity? My understanding is that cycles materials are left out when Blender files are used in Unity.
I don't think that is possible, at least the results will look different. Cycles uses a completely different rendering system than what realtime graphics applications like Unity use.
The Cycles Renderer is a ray tracer and has full knowledge of the whole scene all the time. It can model shadows, reflections, refractions and indirect lighting pretty easily, but they cost a lot of computation power.
Unity on the other hand uses OpenGL and Direct3D for rendering. Both APIs are optimized for realtime graphics, but during rendering only single objects are known. Reflections and shadows have to be faked by rendering the scene multiple times from different angles. To get performant global illumination it is precalculated and refractions are usually faked by distorting the final image.
So even if you export all the settings from Cycles to Unity, the rendering engine in Unity can not use them correctly.
You could approach this in a way that I have found relatively decent although it doesn't necessarily achieve the complete result of a cycles material. What you could do is:
Bake your material to your model without lighting or just have the scene 100 percent lit. There is a good explanation of this on this page of the forum:
What this will accomplish is a model with a diffuse material, but a baked "texture" (UV mapped) version of your material.
If you have a complex or semi translucent material then this becomes a bit problematic. As others have mentioned, the raytracing render method that blender uses is far different from the realtime materials used in unity. You have to fake things like reflections and translucency when you bake textures in blender and then transfer them to unity.
But if you want a basic texture based off your material, you can accomplish that with the method above.
- Then you would export the fbx model along with your baked texture from blender and apply a unity supported realtime shader in unity.
What he is saying is this... What baking does is it turns those settings you have in the node editor, or whatever you are using, and it turns them into a new texture. So all you have to do is apply the texture, and it looks rough, or metallic, or whatever you had. The link he posted was to a forum explaining how to do this.
Now if I remember correctly, it also makes the lighting stick, so the object will have that constant weird glare from wherever your light was pointing when you baked it.
They said to make sure you have either no light, or pure light, so i'm assuming that's why, but i'm not sure.
Take this with a grain of salt, I've only been doing this for about 3 weeks
Also, thank you sooo much, I've been looking everywhere for how to do something like this XD