Replies: 7 comments 5 replies
-
@robertosfield just committed code today that writes the viewport dimensions to ViewDependentState, and you can get at that via getState()->_commandBuffer->viewDependentState() in the RecordTraversal object. Otherwise you can write a custom View object which will have direct access to the camera. See https://github.com/timoore/vsgCs/blob/873b1311c67a33a05f88cd2a5ec478b82ad08875/src/vsgCs/CsView.cpp . Your application will have to use that View class. |
Beta Was this translation helpful? Give feedback.
-
Thanks Tim. I see that |
Beta Was this translation helpful? Give feedback.
-
Have a look at the LOD code as it uses a screen based calculation for selection the LOD child. |
Beta Was this translation helpful? Give feedback.
-
No I'm at my dev system I can more easily look up the specific code in RecordTraversal::apply(LOD&): https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/app/RecordTraversal.cpp#L148 The scheme is not entirely straight forward because I'm trying to lower the CPU overhead as much as possible and enable use of non-dimensional screen height ratios for the LOD cutoff, rather than more traditional distance cutoffs. The vsg::State object used internally by the RecordTraversal caches a pre-processed vec4 lodScale value that is updated each time the view frustum changes during traversal. The lodScale is computed from the model view and projection matrices and is used to distill the work required for the LOD calculations. Unfortunately I don't have a record of how I derived the maths, just the the final C++ code remains. Fingers cross I don't have to an further debugging on it :-) |
Beta Was this translation helpful? Give feedback.
-
As a general note, during the VSG development I've been using the "Minimal and Complete" principle to help decide what to implement and what not. Many features that we might find in the OSG also appear in the VSG, but many haven't been included - if a feature isn't essential and can be implemented with other means then I have often chosen not to implement it. What one might deem essential will vary from project to project, as the VSG's usage becomes more widespread that the diversity of the projects that use it will increase and with it the potential set of features we might now deem as essential. I'm fully expect this process to continue - boundaries will be pushed potentially to breaking point and when things break or become far too awkward to implement then refactoring or extending the existing API and implementation will be warranted. By not trying to over-think what users might need off in the future, and instead focusing on what existing uses or near-future uses require one keeps the implementation distilled and focused on actively used features which can be tested against, and avoids implementing features that don't have an immediate use case or a means for testing them - and avoids the extra complexity, that may never by needed. So if you root around for a solution but don't find one, and no one else can come up with a sensible solution just raise your hand and say "it looks like feature X is missing as I can't do Y without it." If you can also suggest a minimal change to address this feature X then even better :-) |
Beta Was this translation helpful? Give feedback.
-
Haha :) |
Beta Was this translation helpful? Give feedback.
-
@timoore mentioned about recent changes to the core VSG that extend ViewDependentState to include viewportData so that shaders can now use this. One example of where it can be used is when scaling point sprites relative to the window size, something that vsgPoints used have to do manually providing the viewport data as a uniform, but using the new feature have been able to simplify the code, the changes are: vsgPoints changes using the ViewDependetState::viewportData The brick.vert shader provide an example of how it's used: brick.vert shader from vsgPoints The code that scales he point size is simply:
|
Beta Was this translation helpful? Give feedback.
-
Is there a way to access the current camera, viewport, or window from the RecordTraversal? My goal is to do some screen-space-error culling, not too different than the OSG's "pixel size on screen" LOD mode. This requires access to the viewport information or a window matrix of some kind. Thanks for your help.
Beta Was this translation helpful? Give feedback.
All reactions