shchoe Posted December 3, 2021 Share Posted December 3, 2021 Hi, I want to know how to approach the planar reflection with c++ after approaching, i want to control enable/disable Regards, seheonChoe Link to comment
silent Posted December 3, 2021 Share Posted December 3, 2021 shchoe There is an example in documentation that shows how to use Material API to change the planar reflection state (works for 2.11): https://developer.unigine.com/en/docs/2.11/api/library/rendering/class.material?rlang=cpp#example2 Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
fox Posted December 3, 2021 Share Posted December 3, 2021 Hi @shchoe, Starting from 2.14 planar reflections are implemented via a separate node called Planar Reflection Probe. The probe grabs the reflection, and requires a surface to project the reflection onto. There is a set of parameters enabling you to tweak the look of your reflections and optimize rendering load (by limiting visibility distance, for example) . The complete list of settings and parameters is available in the Planar Reflection Probe article. Here is a simple snippet of how you can make it work via C++: // necessary headers #include <UniginePrimitives.h> #include <UnigineObjects.h> #include <UnigineLights.h> /*...*/ //creating a reflecting plane, onto which the reflection is to be projected by the probe plane = Primitives::createPlane(20, 20, 1); // Creating a planar reflection probe of the same size LightPlanarProbePtr planar_probe = LightPlanarProbe::create(); planar_probe->setProjectionSize(Math::vec3(20, 20, 1)); plane->rotate(-90.0f, 0.0f, 0.0f); plane->translate(0.0f, 5.0f, -5.0f); // putting the planar probe so that it covers the reflecting surface // to project the reflection onto planar_probe->setTransform(plane->getTransform()); // inheriting a new material from the one assigned // to the reflecting surface by default in order to tweak it // and set metalness and roughness values (metallic and polished) MaterialPtr plane_mat = plane->getMaterialInherit(0); plane_mat->setParameterFloat("metalness", 1.0f); plane_mat->setParameterFloat("roughness", 0.0f); // set the distance from the camera, up to which // the planar reflection will be visible planar_probe->setVisibleDistance(5.0f); You can also change other parameters of the probe via API: for the list of available methods please refer to the LightPlanarProbe class article. I'll add a Usage Example to the article in the nearest future. Thanks! 1 Link to comment
Recommended Posts