Jump to content

Request: Indicator if a camera is realtime in shader


klepto2
 Share

Recommended Posts

While testing the new Effect feature in the Editor i encountered a small problem with my posteffect shaders.

Some of my effects use a technique called reprojection, actually this is a very basic implementation but improves the perfromance a lot. What it does, is that it uses a 4*4 Bayer filter to determine which pixel needs to be calculated based on the fragment coordinate and the current frame. If a pixel is not meant to be calculated it reads the result from the previous frame (reprojecting the current uv to the previous uv). This means over a period of 16 frames the whole buffer is calculated.

Unfortunatly this is not working in the editor. I believe it might be due to the fact (correct me @Josh if i am wrong), that the editor doesn't use async rendering and the camera is not rendered in realtime. so if we can get a flag which indicates if a shader is invoked from the editor, we could disable some features (reprojection in this case) and use the pfx correctly in the editor.

I will write a very basic shader which will simulate the error and attach it later here.

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

For this reason, I was considering making 3D viewports render twice in the editor each time, if SSR is enabled.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

ok, that makes sense, but in that case a dynmic calculation how many frames needs to be generated maybe needed. While 2 frames for ssr are enough (previous + currentframe) it would't be enough if you use the full power of reprojection and regenerate the whole view over multiple frames. In my case the editor would need to render 16 frames to update the viewport. 

Maybe something like the premulitplyalpha option in a posteffect file would be needed. Wven if its for the editor alone. Maybe somehting like:

EditorRedrawFrames: 16 or so. Then the editor could use the maximum of the that value based on the posteffects attached.

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Hmmm, that is a lot! I think your idea to disable reprojection based on a camera setting is probably better.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 2 weeks later...

Just an idea: Now as normally the glsl is compiled at runtime, we could use that fact to introduce global defines which are added to the preprocessed shaders. 

this could also be extended to add functionality or inject custom macros, but that might be a small overkill for now. I could imagine a system like this:

//Before loading any shader a function needs to be called to register global definitions. 
//As it will be a advanced feature i would place it like this: 
Render::GraphicsEngine::instance->AddShaderDefine("Editor");
Render::GraphicsEngine::instance->AddSahderDefine("saturate(x) clamp(x,0,1)");

the generated code in glsl  would look like this:

#version 460
...

#define Editor
#define saturate(x) clamp(x,0,1)


void main()
{
#ifdef Editor
	....
#endif
}

just an idea.

  • Like 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...