Replies: 6 comments 5 replies
-
|
Thanks. The link doesn’t work, presumably because your repository is private? I gave this some thought and I believe lights should be implemented at the panel level rather than at the visual level. Currently, shaders have two main sets of parameters: shared per-panel parameters related to the viewport and transforms (model, view, projection matrices — though the model matrix might ultimately make more sense at the visual level), and "private" per-visual parameters (including visual-specific data, but also light position and parameters). I think light parameters would fit better in the shared per-panel parameters. The implementation would be simpler if we define a maximum number of lights per panel (say, 4 or 8). We’d also need to agree on a common C-like structure (shared with GLSL) to store light parameters. Something like: struct DvzLight {
vec4 light_pos; // x, y, z coordinates; use vec4 and not vec3 to avoid alignment/padding issues
vec4 light_params; // diffuse, ambient, specular, exponent?
vec4 light_color; // r, g, b
int light_type; // enum, e.g. DVZ_LIGHT_TYPE_POINT, DVZ_LIGHT_TYPE_DIRECTIONAL...
};What do you think? Is there anything else we’d need? This assumes a basic lighting model. More advanced models can achieve more realistic rendering, but that’s probably not a priority for Datoviz right now. In terms of API, the user would be able to add new lights and update their position and parameters dynamically using, for example: dvz_light_type(DvzPanel* panel, uint32_t light_idx, DvzLightType light_type);
dvz_light_pos(DvzPanel* panel, uint32_t light_idx, vec3 light_pos);
dvz_light_params(DvzPanel* panel, uint32_t light_idx, vec4 light_params);
dvz_light_color(DvzPanel* panel, uint32_t light_idx, DvzColor light_color);I was planning to release Datoviz v0.3 in the next couple of weeks if possible, and this would have been a good opportunity to get this right beforehand (it shouldn’t take too long to implement). But that might be too ambitious. |
Beta Was this translation helpful? Give feedback.
-
|
I changed it to public. This link should work better. Yes, I think I came to the same conclusion that they should be at the panel, or a child of the panel. In the example it's done with an add_light method on the scene class. (Which would be the panel in Datoviz.) Also in the example they are separate instances. But would be more efficient as a groups. The same for the cubes. I left it at seperate instances in this case to explore how the problem can be generalized. Adding light objects requires sharing the light data to the panel where it can then propagate down to the objects in the panel being lit by the lights. And in the objects, the shaders would need to access routines specific to the type of light. I left the example in a form that shows the dependencies and attempts to keep things somewhat modular. I'm sure it can be much improved, but the point of it is to have a reference for conversation. |
Beta Was this translation helpful? Give feedback.
-
Yes, Should light_params be a material property on the objects? But possibly it depends on when it's updated. I did something like that in the example with the proj, view, and model matrix's. The panel (canvas class) initiates all of them, but they get updated as objects that affect them get added. Adding a camera, updates the view. And each objects gets a copy, and then updates the model matrix. |
Beta Was this translation helpful? Give feedback.
-
|
Looks good! Yes, there should be a global per-panel structure for light parameters, and a per-mesh-visual structure for material properties. The former would be stored by each panel in a uniform buffer and then bound to the mesh visuals in that panel, while the latter would be an additional uniform binding in the mesh visual shader. Actually, I'm thinking we could go a bit further (without necessarily jumping into full PBR just yet). Here's an LLM-generated proposal, for example, suggesting the implementation of Blinn-Phong and optionally Oren-Nayar, Cook-Torrance, and Rim lighting (not yet tested). Proposed shader code: I’m leaning toward doing this properly, so maybe we should plan it for v0.4 instead. That version will also upgrade the Datoviz Rendering Protocol with more granularity and flexibility in how uniform values are bound to visuals, which would simplify the implementation of this system. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, v0.4 would likely be a better target. I think you are at the stage of adding how different objects (and data structures) interdepend on each other. A good design here will make things down the road much easier. It's worth taking a bit of extra time to get it right. Some things to consider: It would be good to be able to load prebuilt 3D models from public repositories. These file types will have a well defined data structure, and that may help to determine what features Datoviz may need in order to support the more common ones. I'm starting to look into that, there are some python modules for loading 3D models that may help. I'm learning as I go, so this may not be quick. You could consider a chart as a predefined model, and then use generated textures for the content. This could potentially simplify the visual code. And include saving a chart in a model file format along with the textures. A nice thing about this approach is textures scale to the objects they are on. So a chart would consist of generating a set of matching scaled textures for the labels and data areas. These are 2D, and then placed on a 3D model in 3D space. Or viewed as a 2D orthographic display, if that is the active camera used. What lights are added and used will be up to the user. For real time data, updating a set of textures on a prebuilt chart model should be very fast. |
Beta Was this translation helpful? Give feedback.
-
|
I think this can be closed now that your PR has been merged? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a continuation of issue #81.
The conversation led to differences in directional light and point lights. Currently Datoviz had only directional lights, but an update to the arcball used a moveable point light.
In both cases, the lights are hardcoded in the fragment shaders used. We should be able to implement a more generalized lights as visuals or objects that get added to the panel. I wrote a Vispy example showing the use of multiple point lights, with movement of both the lights and objects.
And a link to the file:
vispy_examples/animated_lights_and_cubes.py
I implemented this as a single file, but it would be more likely to be split up into separate importable/loadable objects or visuals.
I will be attempting to implement this with Datoviz, but maybe there already exists some features I should be using?
Beta Was this translation helpful? Give feedback.
All reactions