Josh Posted September 1 Share Posted September 1 @klepto2 @SpiderPig I am adding rendering hooks into the engine that will be called in the rendering thread. The two hooks I have planned are: HOOKID_COMPUTE - called once per render before drawing begins HOOKID_DRAWCAMERA - called once per pass for each camera or shadow render Hooks can be added to an object with this mechanism: void Object::AddHook(const HookID id, void (*hook)(std::shared_ptr<Object> source, std::shared_ptr<Object> extra), std::shared_ptr<Object> extra = NULL); They will pass an OpenGLRenderer object as the source argument of the function callback. void CustomRenderHook(shared_ptr<Object> o, shared_ptr<Object> extra) { auto renderer = o->As<OpenGLRenderer>(); // Start drawing! } The structure contains this information. Is there anything else missing that you need? struct OpenGLRenderer : public Object { HGLRC context; GLuint framebuffer; iVec4 viewport; std::array<GLuint, MAX_STORAGE_BUFFERS> storagebuffers; uint32_t cameraid; Mat4 cameramatrix; std::array<Mat4, 6> projectioncameramatrix; OpenGLRenderPass pass; }; I am trying to stick with the raw OpenGL data and avoid use of the internal API classes as much as possible. The pass value can be any of the following: RENDERPASS_DEPTH RENDERPASS_SOLID RENDERPASS_SHADOW RENDERPASS_TRANSPARENCY RENDERPASS_REFRACTION If the depth prepass is disabled, then the solid pass will indicate RENDERPASS_SOLID | RENDERPASS_DEPTH. Quote 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 More sharing options...
Josh Posted September 2 Author Share Posted September 2 This is available now in 0.9.8 beta. Quote 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 More sharing options...
klepto2 Posted September 2 Share Posted September 2 Very nice, thank you. Will take a closer look into this soon I have 2 more requests: Maybe we need a HOOKID_COMPUTE_AT_START and a HOOKID_COMPUTE_AT_END This is because some computations may rely on data produced after the whole rendering is done. It would be nice to have also access to camera frustumn (if possible) Some geometric code might need this (like my quadtree implemntation) Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
klepto2 Posted September 2 Share Posted September 2 also it would be nice (if possible at all) to have a cancel option. This way it could be possible to have something like this: void DepthOnlyRenderHook(shared_ptr<Object> o, shared_ptr<Object> extra) { auto renderer = o->As<OpenGLRenderer>(); auto camera = extra->As<Camera>(); //what is the cameraid actual? if(camera->GetId() == renderer->cameraid && (pass & RENDERPASS_DEPTH) == 0) { // disable all other passes and just draw the depth pass // might be much cheaper for much scenarios where later computations are just dependend on the depth. renderer.cancel = true; } } Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted September 2 Author Share Posted September 2 7 hours ago, klepto2 said: Maybe we need a HOOKID_COMPUTE_AT_START and a HOOKID_COMPUTE_AT_END This is because some computations may rely on data produced after the whole rendering is done. It would be nice to have also access to camera frustumn (if possible) Some geometric code might need this (like my quadtree implemntation) Ah, okay, so like per-camera compute. Quote 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 More sharing options...
Josh Posted September 2 Author Share Posted September 2 I will add this member in the next build: std::array<Plane, 6> camerafrustum; 1 Quote 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 More sharing options...
Recommended Posts
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.