### Install Panda3D ComplexPBR from Local Wheel Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Install the panda3d-complexpbr module after building it locally, using the generated .whl file. ```bash pip install 'path/to/panda3d-complexpbr.whl' ``` -------------------------------- ### Install Panda3D ComplexPBR using PyPI Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Install the panda3d-complexpbr module directly from the Python Package Index using pip. ```bash pip install panda3d-complexpbr ``` -------------------------------- ### Initialize complexpbr in Panda3D Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Basic setup to apply complexpbr shaders to the render node in a Panda3D application. ```python from direct.showbase.ShowBase import ShowBase from panda3d.core import * import complexpbr class main(ShowBase): def __init__(self): super().__init__() complexpbr.apply_shader(self.render) # complexpbr.screenspace_init() # optional, starts the screenspace effects app = main() app.run() ``` -------------------------------- ### Build Panda3D ComplexPBR Module Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Build the panda3d-complexpbr module using the 'build' tool. This is typically done before local installation. ```bash python -m build ``` -------------------------------- ### Initialize Screenspace Post-Processing Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Use screenspace_init to enable effects like SSAO, SSR, and bloom. This must be called after apply_shader and allows customization via base.screen_quad. ```python from direct.showbase.ShowBase import ShowBase import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() complexpbr.apply_shader(self.render) complexpbr.screenspace_init() # Access screen_quad for customization screen_quad = base.screen_quad # Configure bloom effect screen_quad.set_shader_input("bloom_intensity", 0.25) screen_quad.set_shader_input("bloom_threshold", 0.3) screen_quad.set_shader_input("bloom_blur_width", 20) screen_quad.set_shader_input("bloom_samples", 4) # Configure Screen Space Reflections screen_quad.set_shader_input("ssr_intensity", 2.0) screen_quad.set_shader_input("reflection_threshold", 1.6) screen_quad.set_shader_input("ssr_step", 5.75) screen_quad.set_shader_input("screen_ray_factor", 0.06) screen_quad.set_shader_input("ssr_samples", 1) screen_quad.set_shader_input("ssr_depth_cutoff", 0.52) screen_quad.set_shader_input("ssr_depth_min", 0.49) # Configure SSAO screen_quad.set_shader_input("ssao_samples", 32) # Default is 6 # Configure HSV color adjustment screen_quad.set_shader_input("hsv_g", 1.3) # Saturation factor (default 1.0) screen_quad.set_shader_input("final_brightness", 1.3) # Final brightness multiplier app = MyApp() app.run() ``` -------------------------------- ### Configure ComplexPBR and Screenspace Effects Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Initializes the PBR shader on the scene graph and enables screenspace effects like SSAO and SSR. ```python from direct.showbase.ShowBase import ShowBase import complexpbr class main(ShowBase): def __init__(self): super().__init__() # apply a scene shader with PBR IBL # node can be base.render or any model node, intensity is the desired AO # (ambient occlusion reflection) intensity (float, 0.0 to 1.0) # you may wish to define a specific position in your scene where the # cube map is rendered from, to IE have multiple skyboxes preloaded # somewhere on the scene graph and have their reflections map to your # models -- to achieve this, set env_cam_pos=Vec3(your_pos) # you may set base.env_cam_pos after this, and it will update in realtime # env_res is the cube map resolution, can only be set once upon first call complexpbr.apply_shader(self.render) # complexpbr.screenspace_init() # optional, starts the screenspace effects # apply_shader() with optional inputs # complexpbr.apply_shader(self.render, intensity=0.9, env_cam_pos=None, env_res=256, lut_fill=[1.0,0.0,0.0], custom_dir='shaders/') # initialize complexpbr's screenspace effects (SSAO, SSR, AA, HSV color correction) # this replaces CommonFilters functionality complexpbr.screenspace_init() ``` -------------------------------- ### Configure Global Illumination and Custom Directories Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Adjusts shadow brightness and specifies custom shader file locations. ```python # example of how to turn on Global Illumination (GI) self.main_bridge_tunnel.set_shader_input('shadow_boost', 0.3) # increases intrinsic brightness of a tunnel model # example of how to specify a custom shader directory (you must have created the folder first) complexpbr.apply_shader(self.render, custom_dir='shaders/') ``` -------------------------------- ### Implement Hardware Skinning Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Enables hardware skinning for Actor models to improve performance. ```python # example of how to apply hardware skinning fp_character = actor_data.player_character # this is an Actor() model fp_character.reparent_to(self.render) fp_character.set_scale(1) # set hardware skinning for the Actor() complexpbr.skin(fp_character) ``` -------------------------------- ### screenspace_init Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Initializes ComplexPBR's screenspace post-processing effects including SSAO, SSR, bloom, antialiasing, and HSV color correction. This function replaces CommonFilters functionality and must be called after `apply_shader()`. Once called, it provides access to `base.screen_quad` for customizing all screenspace parameters. ```APIDOC ## screenspace_init ### Description Initializes ComplexPBR's screenspace post-processing effects including SSAO, SSR, bloom, antialiasing, and HSV color correction. This function replaces CommonFilters functionality and must be called after `apply_shader()`. Once called, it provides access to `base.screen_quad` for customizing all screenspace parameters. ### Method SCREENSPACE_INIT ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import complexpbr complexpbr.apply_shader(base.render) complexpbr.screenspace_init() # Access screen_quad for customization screen_quad = base.screen_quad # Configure bloom effect screen_quad.set_shader_input("bloom_intensity", 0.25) screen_quad.set_shader_input("bloom_threshold", 0.3) screen_quad.set_shader_input("bloom_blur_width", 20) screen_quad.set_shader_input("bloom_samples", 4) # Configure Screen Space Reflections screen_quad.set_shader_input("ssr_intensity", 2.0) screen_quad.set_shader_input("reflection_threshold", 1.6) screen_quad.set_shader_input("ssr_step", 5.75) screen_quad.set_shader_input("screen_ray_factor", 0.06) screen_quad.set_shader_input("ssr_samples", 1) screen_quad.set_shader_input("ssr_depth_cutoff", 0.52) screen_quad.set_shader_input("ssr_depth_min", 0.49) # Configure SSAO screen_quad.set_shader_input("ssao_samples", 32) # Configure HSV color adjustment screen_quad.set_shader_input("hsv_g", 1.3) screen_quad.set_shader_input("final_brightness", 1.3) ``` ### Response #### Success Response (200) None (initializes screenspace effects and provides access to `base.screen_quad`) #### Response Example None ``` -------------------------------- ### Configure Material Shader Inputs in ComplexPBR Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Use set_shader_input to adjust specular_factor and shadow_boost on nodes to customize material appearance and global illumination. ```python from direct.showbase.ShowBase import ShowBase import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() complexpbr.apply_shader(self.render) # Load models shiny_object = loader.load_model('models/metal_sphere.gltf') shiny_object.reparent_to(self.render) tunnel = loader.load_model('models/tunnel.gltf') tunnel.reparent_to(self.render) # Modify specular contribution (default is 1.0) self.render.set_shader_input("specular_factor", 10.0) # Per-model specular shiny_object.set_shader_input("specular_factor", 15.0) # Enable Global Illumination approximation for self-illumination in shadows tunnel.set_shader_input('shadow_boost', 0.3) # Increases intrinsic brightness app = MyApp() app.run() ``` -------------------------------- ### Control Dynamic Environment Camera Position Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Manage reflection cube map positioning by setting env_cam_pos or enabling Z-tracking for automatic camera-relative updates. ```python from direct.showbase.ShowBase import ShowBase from panda3d.core import Vec3 import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() # Set fixed cube map position at initialization complexpbr.apply_shader(self.render, env_cam_pos=Vec3(0, 0, 10)) # Update environment camera position at runtime base.env_cam_pos = Vec3(5, 5, 10) # Enable automatic Z-tracking relative to camera base.complexpbr_z_tracking = True # Manual Z offset adjustment base.complexpbr_map_z = 2.5 app = MyApp() app.run() ``` -------------------------------- ### Customize Bloom and SSR Parameters Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Fine-tunes bloom and Screen Space Reflection (SSR) settings via the screen quad shader inputs. ```python # example of how to set up bloom -- complexpbr.screenspace_init() must have been called first screen_quad = base.screen_quad screen_quad.set_shader_input("bloom_intensity", 0.25) screen_quad.set_shader_input("bloom_threshold", 0.3) screen_quad.set_shader_input("bloom_blur_width", 20) screen_quad.set_shader_input("bloom_samples", 4) # example of how to customize SSR screen_quad.set_shader_input('ssr_intensity', 2.0) screen_quad.set_shader_input('reflection_threshold', 1.6) # subtracts from intensity screen_quad.set_shader_input('ssr_step', 5.75) # helps determine reflect height screen_quad.set_shader_input('screen_ray_factor', 0.06) # detail factor screen_quad.set_shader_input('ssr_samples', 1) # determines total steps screen_quad.set_shader_input('ssr_depth_cutoff', 0.52) screen_quad.set_shader_input('ssr_depth_min', 0.49) ``` -------------------------------- ### Generate and Configure BRDF LUT Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Use the BRDF LUT calculator script to generate custom textures or provide a fallback color using the lut_fill parameter in apply_shader. ```python # brdf_lut_calculator.py usage # Place 'input_texture.png' in the working directory before running # The script will: # 1. Load input_texture.png as a base # 2. Apply BRDF calculations using OpenGL shaders # 3. Save the result as 'output_brdf_lut.png' # To run: # python brdf_lut_calculator.py # The generated output_brdf_lut.png can then be placed in your # project directory for ComplexPBR to use automatically. # If no output_brdf_lut.png exists, use lut_fill parameter: import complexpbr complexpbr.apply_shader(base.render, lut_fill=[1.0, 0.0, 0.0]) # RGB fill values ``` -------------------------------- ### Manage Cubemap Rendering Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Controls the activity state and tracking behavior of the environment cubemap. ```python # make the cubemap rendering static (performance boost) complexpbr.set_cubebuff_inactive() # make the cubemap rendering dynamic (this is the default state) complexpbr.set_cubebuff_active() # adjustment factors for the cubemap rendering height (as of version 0.5.5) base.complexpbr_map_z = 2.1 # manual additive/subtractive factor on the rendering height # automatically adjust the environment reflections such that they # update relative to the base.cam position during movement base.complexpbr_z_tracking = True # defaults to False ``` -------------------------------- ### Enable hardware skinning for Actor models Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Applies GPU-accelerated vertex skinning to animated characters to improve performance. ```python from direct.showbase.ShowBase import ShowBase from direct.actor.Actor import Actor import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() complexpbr.apply_shader(self.render) # Load an animated character model character = Actor('models/character.gltf', {'walk': 'models/character-walk.gltf'}) character.reparent_to(self.render) character.set_scale(1) # Enable hardware skinning for the Actor complexpbr.skin(character) # Start an animation character.loop('walk') app = MyApp() app.run() ``` -------------------------------- ### Apply PBR IBL Shading Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Use apply_shader to enable PBR shading on scene nodes. It supports both global scene application and individual model node targeting. ```python from direct.showbase.ShowBase import ShowBase from panda3d.core import Vec3 import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() # Basic usage - apply IBL shader to entire scene complexpbr.apply_shader(self.render) # Full parameter usage with all options complexpbr.apply_shader( self.render, # Node to apply shader to intensity=0.9, # Ambient occlusion reflection intensity (0.0 to 1.0) env_cam_pos=Vec3(0, 0, 5), # Fixed position for cube map rendering (None for dynamic) env_res=512, # Cube map resolution (set once on first call) lut_fill=[1.0, 0.0, 0.0], # RGB fill for BRDF LUT if no file provided custom_dir='shaders/', # Custom directory for generated shader files default_lighting=True, # Enable default lighting setup shadow_boost=0.3 # Global illumination approximation factor ) # Apply to specific model nodes my_model = loader.load_model('models/mymodel.gltf') my_model.reparent_to(self.render) complexpbr.apply_shader(my_model, intensity=0.8) app = MyApp() app.run() ``` -------------------------------- ### Manage cube map rendering buffer Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Toggles the cube map buffer to optimize performance and configures Z-tracking for reflections. ```python from direct.showbase.ShowBase import ShowBase import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() complexpbr.apply_shader(self.render) # Make cube map rendering static for performance complexpbr.set_cubebuff_inactive() # Re-enable dynamic cube map rendering when needed # complexpbr.set_cubebuff_active() # Z-tracking configuration for environment reflections base.complexpbr_map_z = 2.1 # Manual height offset for rendering base.complexpbr_z_tracking = True # Auto-adjust relative to camera position app = MyApp() app.run() ``` -------------------------------- ### Append custom shader logic Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Injects custom fragment and vertex shader code into the existing ComplexPBR pipeline. ```python from direct.showbase.ShowBase import ShowBase import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() # Load and setup a test model test_sphere = loader.load_model('models/sphere.gltf') test_sphere.reparent_to(self.render) # First apply the base shader complexpbr.apply_shader(test_sphere) # Define custom shader modifications # Fragment shader body modification (add custom functions) custom_frag_body = ''' float custom_noise(vec2 n) { float n2 = fract(sin(dot(n.xy, vec2(11.78, 77.443))) * 44372.7263); return n2; } ''' # Fragment shader main loop modification custom_frag_main = 'o_color += custom_noise(vec2(2.3, 3.3)) * 0.05;' # Vertex shader body modification custom_vert_body = ''' float vert_noise(vec2 n) { return n[0]; } ''' # Vertex shader main loop modification custom_vert_main = 'float offset = vert_noise(vec2(2.3, 3.3));' # Apply custom shader composition complexpbr.append_shader( test_sphere, custom_frag_body, # frag_body_mod custom_frag_main, # frag_main_mod custom_vert_body, # vert_body_mod custom_vert_main # vert_main_mod ) app = MyApp() app.run() ``` -------------------------------- ### apply_shader Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Applies PBR IBL shading to a node in the Panda3D scene graph. This function sets up cube map rendering for environment reflections, configures the BRDF lookup texture, and initializes the shader pipeline. It can be applied to `base.render` for scene-wide shading or to individual model nodes. ```APIDOC ## apply_shader ### Description Applies PBR IBL shading to a node in the Panda3D scene graph. This function sets up cube map rendering for environment reflections, configures the BRDF lookup texture, and initializes the shader pipeline. It can be applied to `base.render` for scene-wide shading or to individual model nodes. ### Method APPLY_SHADER ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import complexpbr from panda3d.core import Vec3 # Basic usage complexpbr.apply_shader(base.render) # Full parameter usage complexpbr.apply_shader( base.render, intensity=0.9, env_cam_pos=Vec3(0, 0, 5), env_res=512, lut_fill=[1.0, 0.0, 0.0], custom_dir='shaders/', default_lighting=True, shadow_boost=0.3 ) # Apply to specific model nodes my_model = loader.load_model('models/mymodel.gltf') my_model.reparent_to(base.render) complexpbr.apply_shader(my_model, intensity=0.8) ``` ### Response #### Success Response (200) None (modifies scene graph) #### Response Example None ``` -------------------------------- ### Compose Custom Shaders Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Appends custom GLSL code to existing shader files for specific models. ```python # example of how to use the shader composition functionality complexpbr.apply_shader(test_sphere) # example sphere model # call the append_shader() function, you may modify just 1 or all of the 4 shader files custom_body_mod = 'float default_noise(vec2 n)\n{\nfloat n2 = fract(sin(dot(n.xy,vec2(11.78,77.443)))*44372.7263);\nreturn n2;\n}' custom_main_mod = 'o_color += default_noise(vec2(2.3,3.3));' custom_vert_body_mod = 'float default_noise(vec2 n)\n{\nreturn n[0];\n}' custom_vert_main_mod = 'float whatever = default_noise(vec2(2.3,3.3));' complexpbr.append_shader(test_sphere, custom_body_mod, custom_main_mod, custom_vert_body_mod, custom_vert_main_mod) ``` -------------------------------- ### Apply Custom BRDF LUT with Panda3D ComplexPBR Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Directly fill the BRDF LUT texture instead of providing an external file. The 'lut_fill' parameter accepts RGB values. ```python complexpbr.apply_shader(base.render, 1.0, env_res=1024, lut_fill=[1.0,0.0,0.0]) ``` -------------------------------- ### Adjust HSV and Brightness in Panda3D ComplexPBR Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Modify the final image's hue, saturation, and brightness using shader inputs. 'hsv_g' controls saturation, defaulting to 1.0, and 'final_brightness' adjusts multiplicative brightness in screenspace. ```python screen_quad.set_shader_input("hsv_g", 1.3) ``` ```python screen_quad.set_shader_input("final_brightness", 1.3) ``` -------------------------------- ### Integrate CommonFilters with Panda3D ComplexPBR Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md If complexpbr.screenspace_init() has not been called, CommonFilters can be used for post-processing effects like bloom, exposure, gamma, and blur/sharpen. ```python # scene_filters = CommonFilters(base.win, base.cam) # scene_filters.set_bloom(size='medium') # scene_filters.set_exposure_adjust(1.1) # scene_filters.set_gamma_adjust(1.1) # scene_filters.set_blur_sharpen(0.9) ``` -------------------------------- ### Customize SSAO with Panda3D ComplexPBR Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Adjust the Screen Space Ambient Occlusion (SSAO) sample count using the 'ssao_samples' shader input. The default value is 6. ```python screen_quad.set_shader_input("ssao_samples", 32) ``` -------------------------------- ### Apply Vertex Displacement Mapping Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Applies a displacement map texture to a model to modify its geometry. ```python # example of how to use the vertex displacement mapping wood_sphere_3 = loader.load_model('assets/models/wood_sphere_3.gltf') wood_sphere_3.reparent_to(base.render) wood_sphere_3.set_pos(0,0,1) dis_tex = Texture() dis_tex.read('assets/textures/WoodFloor057_2K-PNG/WoodFloor057_2K_Displacement.png') wood_sphere_3.set_shader_input('displacement_map', dis_tex) wood_sphere_3.set_shader_input('displacement_scale', 0.1) ``` -------------------------------- ### Clean Up Generated Shader Files Source: https://context7.com/rayanalysis/panda3d-complexpbr/llms.txt Use remove_shader_files to delete generated shader files from the working directory. This is intended for development and not recommended for production builds. ```python from direct.showbase.ShowBase import ShowBase import complexpbr class MyApp(ShowBase): def __init__(self): super().__init__() complexpbr.apply_shader(self.render) complexpbr.screenspace_init() # At cleanup time (not recommended for production) # complexpbr.remove_shader_files() app = MyApp() app.run() ``` -------------------------------- ### Modify Specular Contribution in Panda3D ComplexPBR Source: https://github.com/rayanalysis/panda3d-complexpbr/blob/main/README.md Control the specular contribution of lighting by setting the 'specular_factor' shader input. The default value is 1.0. ```python self.render.set_shader_input("specular_factor", 10.0) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.