helmut.bressler Posted May 27, 2014 Posted May 27, 2014 Hello Unigine community, I would like to create a cubemap containing at least a terrain and the sky once per frame. I know that this implies that every thing has to be rendered 6 times additionally. Therefore I tried to mask out other nodes I don't need by using a viewport mask. However when I apply the viewport maks to the Player provided by engine.game.setPlayer() it doesn't seem to affect the following engine.render.renderImageCube() call. How can I use viewport masks together with engine.render.renderImageCube()? thanks, Helmut
helmut.bressler Posted May 28, 2014 Author Posted May 28, 2014 Okay I have played around with the mesh_reflection_cube material which supports the viewport mask and even one face per frame generation. The performance impact is still too big, so I have to find another solution anyway.
unclebob Posted May 28, 2014 Posted May 28, 2014 Hi Helmut, Could you give me your test scene? This will give us ability to suggest a solution for you.
helmut.bressler Posted May 30, 2014 Author Posted May 30, 2014 Thank you, let me first provide you with a more detailed description of my problem: I have a scene with a large terrain and a group of mirrors and reflective metal objects in the center. All of them should reflect the skydome and the terrain. The skydome changes drastically during the day as there is a accurate day and night cycle. The number of nodes is big, but the number of different materials is not (it will be probably around 20 in the final project). To my knowledge I have the following options in unigine: 1.: Inheriting from the mesh_reflection_cube material: Intuitively that would be the best solution, as it is able to react on changes in the skydome with the dynamic cubemap update feature. Even with only a single face generation per frame and efficient usage of the viewport mask there is still a huge drop in the framerate when I turn on the dynamic cubemap generation (I have a root node which has about 10000 child nodes attached, all sharing the same material, so the cubemap is definitely shared, when I'm not using the root node the application becomes unusable). 2.: Generting a single cubemap via engine.render.renderImageCube() per frame and assign it to all mesh_reflection_cube materials as static cubemap: Here it seems to me that the viewport mask is ignored, as described in my first posting, and the performace is worse than in 1). But even when I get the viewport mask working I doubt that it will be faster than 1) because it renders all 6 cubemap faces per frame. 3.: Using environment coefficients: This is not an option, at least the mirrors have to be able to reflect high frequency detail (i.e. the sun). 4.: Precalculating the cubemaps for each day in a year and interpolating between two cubemaps: For each day I generate a several cubemaps, a higher number around sunrise/sunset where the skydome is changing much faster than during the daytime. During the day I pick the two closest cubemaps for a given time and somehow interpolate between them, either by modifying shaders or via the c++ api. I know that there might be glitches when the sun is visible and the number of cubemaps is too low. At the moment I'm investigating solution 4), it is certainly the fastest solution in terms of performance. Without interpolation it works already. cheers, Helmut
helmut.bressler Posted July 17, 2014 Author Posted July 17, 2014 Hi Cryunreal,at the moment, I have implemented it in C++ for direct3d 11. It runs to 100% on the GPU but it is not a general solution as it executes graphics api low level code (in that case it uses the existing direct3d device context) and could potentially mess around with the GPU/graphics API state, without the knowledge of the unigine renderer.(For this project that is less of an issue, as we will use our own App implementation anyway which gives us more controll over GPU/graphics API).All in all it works quite well, thanks to the fact that access to low level graphics api features is very easy in Unigine even without the source sdk.I hope you can keep up this tradition, given that there are so many new graphics apis around the corner.cheersHelmut
Recommended Posts