fix(shader): Use custom_background callback to render blurred texture
- Add _render_custom_background method as hello_imgui callback - Render blurred FBO texture as ImGui background - Use ctypes.cast to convert OpenGL texture ID to ImTextureRef
This commit is contained in:
@@ -82,9 +82,10 @@ This file tracks all major tracks for the project. Each track has its own detail
|
|||||||
11. [ ] **Track: Advanced Text Viewer with Syntax Highlighting**
|
11. [ ] **Track: Advanced Text Viewer with Syntax Highlighting**
|
||||||
*Link: [./tracks/text_viewer_rich_rendering_20260313/](./tracks/text_viewer_rich_rendering_20260313/)*
|
*Link: [./tracks/text_viewer_rich_rendering_20260313/](./tracks/text_viewer_rich_rendering_20260313/)*
|
||||||
|
|
||||||
12. [ ] **Track: Frosted Glass Background Effect**
|
12. [ ] ~~**Track: Frosted Glass Background Effect**~~ THIS IS A LOST CAUSE DON'T BOTHER.
|
||||||
*Link: [./tracks/frosted_glass_20260313/](./tracks/frosted_glass_20260313/)*
|
*Link: [./tracks/frosted_glass_20260313/](./tracks/frosted_glass_20260313/)*
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Additional Language Support
|
### Additional Language Support
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Response = true
|
|||||||
Theme = true
|
Theme = true
|
||||||
"Log Management" = true
|
"Log Management" = true
|
||||||
Diagnostics = false
|
Diagnostics = false
|
||||||
"External Tools" = true
|
"External Tools" = false
|
||||||
"Shader Editor" = true
|
"Shader Editor" = true
|
||||||
|
|
||||||
[theme]
|
[theme]
|
||||||
@@ -64,8 +64,8 @@ palette = "Nord Dark"
|
|||||||
font_path = "C:/projects/manual_slop/assets/fonts/MapleMono-Regular.ttf"
|
font_path = "C:/projects/manual_slop/assets/fonts/MapleMono-Regular.ttf"
|
||||||
font_size = 18.0
|
font_size = 18.0
|
||||||
scale = 1.0
|
scale = 1.0
|
||||||
transparency = 0.5400000214576721
|
transparency = 0.4399999976158142
|
||||||
child_transparency = 1.0
|
child_transparency = 0.5099999904632568
|
||||||
|
|
||||||
[mma]
|
[mma]
|
||||||
max_workers = 4
|
max_workers = 4
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ Collapsed=0
|
|||||||
DockId=0xAFC85805,2
|
DockId=0xAFC85805,2
|
||||||
|
|
||||||
[Window][Theme]
|
[Window][Theme]
|
||||||
Pos=0,1020
|
Pos=0,543
|
||||||
Size=680,737
|
Size=387,737
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,2
|
DockId=0x00000002,2
|
||||||
|
|
||||||
@@ -91,8 +91,8 @@ Collapsed=0
|
|||||||
DockId=0x00000010,2
|
DockId=0x00000010,2
|
||||||
|
|
||||||
[Window][Context Hub]
|
[Window][Context Hub]
|
||||||
Pos=0,1020
|
Pos=0,543
|
||||||
Size=680,737
|
Size=387,737
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000002,1
|
||||||
|
|
||||||
@@ -103,26 +103,26 @@ Collapsed=0
|
|||||||
DockId=0x0000000D,0
|
DockId=0x0000000D,0
|
||||||
|
|
||||||
[Window][Discussion Hub]
|
[Window][Discussion Hub]
|
||||||
Pos=1462,26
|
Pos=1169,26
|
||||||
Size=950,1731
|
Size=950,1254
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000013,0
|
DockId=0x00000013,0
|
||||||
|
|
||||||
[Window][Operations Hub]
|
[Window][Operations Hub]
|
||||||
Pos=682,26
|
Pos=389,26
|
||||||
Size=778,1731
|
Size=778,1254
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][Files & Media]
|
[Window][Files & Media]
|
||||||
Pos=0,1020
|
Pos=0,543
|
||||||
Size=680,737
|
Size=387,737
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
[Window][AI Settings]
|
[Window][AI Settings]
|
||||||
Pos=0,26
|
Pos=0,26
|
||||||
Size=680,992
|
Size=387,515
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
@@ -132,14 +132,14 @@ Size=416,325
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][MMA Dashboard]
|
[Window][MMA Dashboard]
|
||||||
Pos=2414,26
|
Pos=2121,26
|
||||||
Size=653,1731
|
Size=653,1254
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000010,0
|
DockId=0x00000010,0
|
||||||
|
|
||||||
[Window][Log Management]
|
[Window][Log Management]
|
||||||
Pos=2414,26
|
Pos=2121,26
|
||||||
Size=653,1731
|
Size=653,1254
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000010,1
|
DockId=0x00000010,1
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ Size=967,499
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Usage Analytics]
|
[Window][Usage Analytics]
|
||||||
Pos=1439,259
|
Pos=1627,680
|
||||||
Size=480,343
|
Size=480,343
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ Size=900,700
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Shader Editor]
|
[Window][Shader Editor]
|
||||||
Pos=923,623
|
Pos=998,497
|
||||||
Size=493,369
|
Size=493,369
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ Column 1 Weight=1.0000
|
|||||||
DockNode ID=0x00000008 Pos=3125,170 Size=593,1157 Split=Y
|
DockNode ID=0x00000008 Pos=3125,170 Size=593,1157 Split=Y
|
||||||
DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1029,147 Selected=0x0469CA7A
|
DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1029,147 Selected=0x0469CA7A
|
||||||
DockNode ID=0x0000000A Parent=0x00000008 SizeRef=1029,145 Selected=0xDF822E02
|
DockNode ID=0x0000000A Parent=0x00000008 SizeRef=1029,145 Selected=0xDF822E02
|
||||||
DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,26 Size=3067,1731 Split=X
|
DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,26 Size=2774,1254 Split=X
|
||||||
DockNode ID=0x00000003 Parent=0xAFC85805 SizeRef=1980,1183 Split=X
|
DockNode ID=0x00000003 Parent=0xAFC85805 SizeRef=1980,1183 Split=X
|
||||||
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2
|
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2
|
||||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=680,858 Split=Y Selected=0x8CA2375C
|
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=680,858 Split=Y Selected=0x8CA2375C
|
||||||
@@ -510,7 +510,7 @@ DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,26 Size=3067,1731 Spli
|
|||||||
DockNode ID=0x00000013 Parent=0x0000000E SizeRef=950,402 Selected=0x6F2B5B04
|
DockNode ID=0x00000013 Parent=0x0000000E SizeRef=950,402 Selected=0x6F2B5B04
|
||||||
DockNode ID=0x0000000D Parent=0x00000003 SizeRef=435,1186 Selected=0x363E93D6
|
DockNode ID=0x0000000D Parent=0x00000003 SizeRef=435,1186 Selected=0x363E93D6
|
||||||
DockNode ID=0x00000004 Parent=0xAFC85805 SizeRef=653,1183 Split=Y Selected=0x3AEC3498
|
DockNode ID=0x00000004 Parent=0xAFC85805 SizeRef=653,1183 Split=Y Selected=0x3AEC3498
|
||||||
DockNode ID=0x00000010 Parent=0x00000004 SizeRef=1199,1689 Selected=0x3AEC3498
|
DockNode ID=0x00000010 Parent=0x00000004 SizeRef=1199,1689 Selected=0x2C0206CE
|
||||||
DockNode ID=0x00000011 Parent=0x00000004 SizeRef=1199,420 Selected=0xDEB547B6
|
DockNode ID=0x00000011 Parent=0x00000004 SizeRef=1199,420 Selected=0xDEB547B6
|
||||||
|
|
||||||
;;;<<<Layout_655921752_Default>>>;;;
|
;;;<<<Layout_655921752_Default>>>;;;
|
||||||
|
|||||||
26
src/gui_2.py
26
src/gui_2.py
@@ -229,24 +229,27 @@ class App:
|
|||||||
t = time.time()
|
t = time.time()
|
||||||
self._blur_pipeline.prepare_global_blur(int(ws.x), int(ws.y), t, fb_scale)
|
self._blur_pipeline.prepare_global_blur(int(ws.x), int(ws.y), t, fb_scale)
|
||||||
|
|
||||||
def _render_frosted_background(self, window_pos: tuple, window_size: tuple):
|
def _render_custom_background(self):
|
||||||
if not self.ui_frosted_glass_enabled:
|
if not self.ui_frosted_glass_enabled:
|
||||||
return
|
return
|
||||||
if not self._blur_pipeline:
|
if not self._blur_pipeline:
|
||||||
return
|
return
|
||||||
|
ws = imgui.get_io().display_size
|
||||||
|
fb_scale = imgui.get_io().display_framebuffer_scale.x
|
||||||
|
if ws.x <= 0 or ws.y <= 0:
|
||||||
|
return
|
||||||
|
if fb_scale <= 0:
|
||||||
|
fb_scale = 1.0
|
||||||
|
import time
|
||||||
|
t = time.time()
|
||||||
|
self._blur_pipeline.prepare_global_blur(int(ws.x), int(ws.y), t, fb_scale)
|
||||||
blur_tex = self._blur_pipeline.get_blur_texture()
|
blur_tex = self._blur_pipeline.get_blur_texture()
|
||||||
if not blur_tex:
|
if not blur_tex:
|
||||||
return
|
return
|
||||||
ws = imgui.get_io().display_size
|
dl = imgui.get_background_draw_list()
|
||||||
fb_scale = imgui.get_io().display_framebuffer_scale.x
|
# Create texture reference from OpenGL texture ID
|
||||||
screen_w = ws.x * fb_scale
|
tex_ref = ctypes.cast(blur_tex, ctypes.c_void_p).value
|
||||||
screen_h = ws.y * fb_scale
|
dl.add_image(tex_ref, (0, 0), (ws.x, ws.y))
|
||||||
uv_x = window_pos[0] / screen_w
|
|
||||||
uv_y = 1.0 - (window_pos[1] / screen_h)
|
|
||||||
uv_w = window_size[0] / screen_w
|
|
||||||
uv_h = window_size[1] / screen_h
|
|
||||||
dl = imgui.get_window_draw_list()
|
|
||||||
self._draw_blurred_rect(dl, (window_pos[0], window_pos[1]), (window_pos[0] + window_size[0], window_pos[1] + window_size[1]), blur_tex, (uv_x, uv_y), (uv_x + uv_w, uv_y - uv_h))
|
|
||||||
|
|
||||||
def _draw_blurred_rect(self, dl, p_min, p_max, tex_id, uv_min, uv_max):
|
def _draw_blurred_rect(self, dl, p_min, p_max, tex_id, uv_min, uv_max):
|
||||||
import OpenGL.GL as gl
|
import OpenGL.GL as gl
|
||||||
@@ -4126,6 +4129,7 @@ def hello():
|
|||||||
self.runner_params.callbacks.setup_imgui_style = theme.apply_current
|
self.runner_params.callbacks.setup_imgui_style = theme.apply_current
|
||||||
self.runner_params.callbacks.post_init = self._post_init
|
self.runner_params.callbacks.post_init = self._post_init
|
||||||
self.runner_params.callbacks.pre_new_frame = self._pre_new_frame
|
self.runner_params.callbacks.pre_new_frame = self._pre_new_frame
|
||||||
|
self.runner_params.callbacks.custom_background = self._render_custom_background
|
||||||
self._fetch_models(self.current_provider)
|
self._fetch_models(self.current_provider)
|
||||||
md_options = markdown_helper.get_renderer().options
|
md_options = markdown_helper.get_renderer().options
|
||||||
immapp.run(self.runner_params, add_ons_params=immapp.AddOnsParams(with_markdown_options=md_options))
|
immapp.run(self.runner_params, add_ons_params=immapp.AddOnsParams(with_markdown_options=md_options))
|
||||||
|
|||||||
Reference in New Issue
Block a user