I am developing an interior-designing application.
The user opens a 3D scene (a house/flat) and applies material for meshes (walls, floors etc.).
I am planning to use any openGL/OpenCL/DirectX library to display the 3D scene in the View panel.
All my materials are defined as Cycles shaders and stored in xml files.
When the user applies a material to a mesh, I should be able to quickly show the mesh with the material applied. (A full baking can be done when the user wants but for the sake of user experience, I should be able to show the material applied quickly) .
How can I achieve this?
Do I need to convert the Cycles material to GLSL shader?
How blender does it?
You will need to find suitable settings to be able to generate a preview as quickly as you need. There might be things exposed when using Cycles to be able to ‘shortcut’ some aspects of rendering, but I don’t know the API well enough to tell you what they might be.
I’d be looking at what things you can skip in the rendering process, by for example, just evaluating a single sample assuming full illumination with the ‘background’ colour (or alternatively using some AO heuristic), then a handful of samples on various positions on the light source, plus maybe one for sharp reflections. This should render very quickly and will give you a good enough preview for most architectural materials, but won’t represent semi-glossy materials very well. Maybe you could add a progressive refinement on top of the initial preview like what Cycles does.
Curious to know how you do tackle this, please share as you make progress.
I recommend exporting to glTF and adopting their material model. In Blender you’d don’t have to create shader setups that are compatible with that and bake textures as needed. There are existing libraries and frameworks for reading and rendering glTF models.
Replicating the Cycles/Eevee shader nodes outside of Blender is possible in principle, but is a big project and will be hard to maintain as Blender keeps evolving.