You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to color an OpenGLSurface based on coordinates and I noticed multiple issues with the differents methods :
the color_by_code() function can't do anything. Looking at the implementation, it seems that it's editing the shader_wrapper.program_code attribute to change the surface shader but the shader_wrapper attached to the mobject is re-initialised by the get_shader_wrapper() method of OpengGLSurface each time the mobject is rendered. This means that the shaders in the program_code attribute are reloaded from the files each frame which make it impossible to edit them.
editing directly the finalize_color.glsl shader file can effectively modify the surface color but the coordinates passed in the function seem to be screen space coordinates. Maybe it would be more usefull to put the "///// INSERT COLOR FUNCTION HERE /////" comment which is replaced by the users code in a function that has access to world space coordinates.
the color_by_xyz_func() method is using the get_colormap_list() method that does not exists
Editing the finalize_color.glsl file is working but the coordinates are screen space coordinates :
Logs
Terminal output
Part of printed program_code after modifying the shader with color_by_code(), the comment should have been replaced :
vec4 finalize_color(vec4 color,
vec3 point,
vec3 unit_normal,
vec3 light_coords,
float gloss,
float shadow){
///// INSERT COLOR FUNCTION HERE /////
// The line above may be replaced by arbitrary code snippets, as per
// the method Mobject.set_color_by_code
return add_light(color, point, unit_normal, light_coords, gloss, shadow);
}
System specifications
System Details
OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Windows 10
I looked bit more at the code and it seems that the program_code attribute is not used in the rendering process. The only thing that could be modified in the shader_wrapper to change the color of the surface is the shader_folder attribute because the shaders attached to the surfaces are reloaded from a cache with the shader folder name each frame.
I also noticed that the get_shader_wrapper method has this commented code : if hasattr(self, "__shader_wrapper"): return self.__shader_wrapper
It would prevent the shader_wrapper from being reloaded each time the method is called but uncommenting it cause the surface to render incorrectly.
I ended up adding a reload_shader_wrapper method to reload the shader_wrapper of the surface after creating it which is working. I then modify the shader_folder attribute to redirect the renderer to a custom folder containing my shaders. It's a temporary solution but I don't know how else to do it.
Description of bug / unexpected behavior
I'm trying to color an OpenGLSurface based on coordinates and I noticed multiple issues with the differents methods :
the color_by_code() function can't do anything. Looking at the implementation, it seems that it's editing the shader_wrapper.program_code attribute to change the surface shader but the shader_wrapper attached to the mobject is re-initialised by the get_shader_wrapper() method of OpengGLSurface each time the mobject is rendered. This means that the shaders in the program_code attribute are reloaded from the files each frame which make it impossible to edit them.
editing directly the finalize_color.glsl shader file can effectively modify the surface color but the coordinates passed in the function seem to be screen space coordinates. Maybe it would be more usefull to put the "///// INSERT COLOR FUNCTION HERE /////" comment which is replaced by the users code in a function that has access to world space coordinates.
the color_by_xyz_func() method is using the get_colormap_list() method that does not exists
Expected behavior
How to reproduce the issue
Code for reproducing the problem
Additional media files
Images/GIFs
Editing the finalize_color.glsl file is working but the coordinates are screen space coordinates :

Logs
Terminal output
Part of printed program_code after modifying the shader with color_by_code(), the comment should have been replaced :
System specifications
System Details
python/py/python3 --version
): 3.9pip list
):LaTeX details
Additional comments
The text was updated successfully, but these errors were encountered: