I am aware that Cycle materials do not work in real time engines like game engines but why is that? Is it because of the coding language of the shader being different from the one supported by the game engine? Or is there even an advanced problem than just the coding language?
1 Answers
Only game engine purposed materials work in their specific game engines, just like only specific render engine materials work in their specific Render Engine of origin. (Blender Internal Materials only work in Blender Internal Render, not Cycles, and vice versa).
Every rendering environment (realtime, game engine or otherwise) uses it's own specific material definitions specially designed for their particular task and non other.
A few exceptions are probably generic material definition standards like OSL (Open Shading Language) or GLSL (OpenGL Shading Language) or RenderMan Shading Language among others.
As far as I know there is nothing stopping a render engine from using Cycles materials, I am sure they could hypothetically be be easily ported, actually more the other way around, a game engine could perfectly be designed around rendering Cycles shaders.
In fact one already exists, in the upcomming Blender 2.8 the new viewport realtime OpenGL render engine EEVEE can and uses mostly cycles material definitions and display them in real time. Cycles object viewport previews will also be generated by EEVEE.
Bottom line is, to the best of my knowledge the problem doesn't lie in the materials themsleves, the shaders, the languages or anything else, the problem lies in optimization and purose.
Game engines need speed and responsiveness above all, they can't spend the endless time needed to render a Cycles scene, as such corners are cut. You can't have all the nice things an offline render provides like raytraced reflections, indirect lighting, mesh lights, refractions etc, as such that eye candy has to be faked with various complex and intricate techniques.
Real time materials are therefore optimized for these tasks, make abundant use of pre-calculated effects, baked maps, lots of textures, screen space ambient occlusions, deferred rendering, etc., whereas a Cycles material aims for realism and flexibility of use at the expense of render time.
Making render engines compatible with third party material definitions is also a huge complex task, error and bug prone, can cause artifacts and unexpected results, may introduce negative implications like worse performance and feature limitations.
See for example Cycles support for OSL shaders, you can have them but while using them you can't get GPU acceleration for example.
It is also often pointless to do so, there are no real gains in say Unreal or Unity supporting something as niche as Cycles shaders in their pipeline. Business strategies and market competition also probably restrict sharing proprietary shaders between rival companies.
- 59,425
- 39
- 130
- 187
-
You say that the materials should work fine in Unity and Unreal but they dont. None of the engines recognize the materials. – HelpPlz Sep 21 '17 at 01:18
-
I didn't say that – Duarte Farrajota Ramos Sep 21 '17 at 01:20
-
Ah you added hypothetically – HelpPlz Sep 21 '17 at 02:39
-
Yes I did. Just thought I'd make it more clear. – Duarte Farrajota Ramos Sep 21 '17 at 02:47
-
I think I am going to learn more on how EEVEE uses cycles shaders for rendering. – HelpPlz Sep 21 '17 at 02:54
-
Have in mind that it is currently under heavy development and broken in many fundamental ways. Stuff will change, things will break, features are not implemented yet, and lots of bugs are expected. Don't bother the developers with bug reports at this point, and questions about it here are mostly off topic for now. – Duarte Farrajota Ramos Sep 21 '17 at 02:59
-
1If you're going to use some other game engine... don't bother with EEVEE. It won't work. What you need to work with is the material system of the game engine (or program the material yourself with glsl). What you can do with Cycles materials is to bake them and then use the baked textures in the materials parameters of the game engine, since most of them have the same inputs for diffuse color, specular color, roughness, etc. – Secrop Sep 21 '17 at 07:42
-
1the most important difference between a realtime render engine (like EEVEE) and Cycles is that Cycles is a Raytracer. Raytracing takes a lot longer to render but can achieve much more realistic results because it simulates real light. Game Engines use an other method to render much quicker but less realistic by itself. For realism the light is often baked into the textures. – HenrikD Sep 21 '17 at 08:58
-
But @Secrop arent the materials made in EEVEE written in GLSL? – Casanova Sep 21 '17 at 20:12
-
@Casanova, It's possible to export the materials code (it has to be compiled in each machine). But the code for that must be written, and I doubt someone in the near future will work on that, not until EEVEE is mature enough. But even so, we must take into consideration that illumination is also a part of EEVEE (and more), and we are not dealing with exporting materials, but exporting EEVEE. – Secrop Sep 21 '17 at 20:39