adrian.licuriceanu Posted September 11, 2017 Posted September 11, 2017 Hi, Some background: we are having our own rendering code embedded into Unigine. We've just upgraded from 2.2 to 2.5 version. In the previous version when we had to render water planar reflection we just took the current engine projection matrix (which was the oblique projection with the clipping plane matching the reflection plane) and render with it (so the geometry above water was clipped). Starting with this new version the oblique projection is no longer computed. It seems that you've switched to some sort of discard in the shaders based on the clipping plane. My question is: what is the reason for this new method? Are there any advantages? I am asking this since I still debate if I am to just compute the oblique projection myself and render as before or to just modify our shaders and use the new method (more time consuming to make but maybe there are benefits from it). Regards, Adrian Licu VStep
silent Posted September 11, 2017 Posted September 11, 2017 Hi Adrian, We moved away from oblique projection in ObjectWaterGlobal because of complex math that basically won't allow us to: Reflect complex shading object (like clouds with extensive compute shaders usage) Calculate Velocity buffer (for TAA and other Post-processing effects) Store water depth like we need (to save performance) We are discarding right now in shader and it solves all of our issues. As far as I know you still can calculate your own matrix, but you can quickly run at some graphics artifacts. You can use in your code following methods to discard as well: // return 1 or 0 float isObliqueFrustumDiscard(float3 position) float isObliqueFrustumDiscard(float4 position) // only fragment shader void obliqueFrustumDiscard(float3 position) void obliqueFrustumDiscard(float4 position) Examples of usage you can find in mesh_base shaders, it's pretty straightforward. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
adrian.licuriceanu Posted September 11, 2017 Author Posted September 11, 2017 Many thanks, I will have a look.
adrian.licuriceanu Posted September 14, 2017 Author Posted September 14, 2017 Ok, I've managed to implement the reflection clipping but now I have another issue. Everything renders fine except our terrain which in reflection is always black (as per attached screenshot). What is strange is that using render_show_textures 1 shows all the reflection gbuffer textures as correct (similar with main render target but reflected) but the final rendering (lighting) in the reflection (using gbuffers) produces black results for the terrain (only terrain, objects look ok). Any idea what may produce this? I've also looked into the backface culling (seems that now it is reversed in the reflection) but this seems to not be the case. Many thanks, Adrian
silent Posted September 15, 2017 Posted September 15, 2017 Hi Adrian, Could you please provide some small test example with this behavior? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
adrian.licuriceanu Posted September 15, 2017 Author Posted September 15, 2017 Hi, I will see what I can do but it would be hard since we have a lot of customizations and an entire pipeline to pack. I will check to see what I can share. But any idea what is different in reflection compared with normal rendering? Culling seems reversed, but anything else that may affect this? Regards, Adrian
silent Posted September 15, 2017 Posted September 15, 2017 Hi Adrian, It's really hard to tell without some debugging, sorry. I've asked devs and they currently have no ideas, actually. Btw, is that old ObjectTerrain not ObjectTerrainGlobal on your screenshot? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
adrian.licuriceanu Posted September 15, 2017 Author Posted September 15, 2017 On that screenshot everything is our own external objects (our terrain and objects rendering) integrated into Unigine. If there is nothing different in Unigine between normal rendering and reflection rendering (same rendering states, only different matrices) , then it must be something in our states. Strange is that all gbuffers produced by our code for reflection look correct, only that the final Unigine lighting pass produces black pixels for terrain only. Regards, Adrian
Recommended Posts