### Start N8AO Development Server Source: https://github.com/n8python/n8ao/blob/master/README.md Instructions to start the development server for N8AO using npm. ```bash npm run dev ``` -------------------------------- ### Stencil Buffer Setup with pmndrs/postprocessing Source: https://github.com/n8python/n8ao/blob/master/README.md Provides an example of how to set up stencil buffers when using N8AOPostPass with the `pmndrs/postprocessing` library. This involves configuring the `EffectComposer` and `RenderPass`. ```js const composer = new EffectComposer(renderer, { stencilBuffer: true, // stencil depthBuffer: true, frameBufferType: THREE.HalfFloatType }); const renderPass = new RenderPass(scene, camera); renderPass.clearPass.setClearFlags(true, true, true); // Ensures that the render pass clears the stencil buffer composer.addPass(renderPass); const n8aopass = new N8AOPostPass( scene, camera, clientWidth, clientHeight ); composer.addPass(n8aopass); ``` -------------------------------- ### Basic Integration with Three.js Source: https://github.com/n8python/n8ao/blob/master/README.md Demonstrates the fundamental setup of N8AOPass within a Three.js scene using EffectComposer. This pass replaces the standard RenderPass. ```javascript import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'; import { N8AOPass } from 'n8ao'; const composer = new EffectComposer(renderer); const n8aopass = new N8AOPass( scene, camera, width, height ); composer.addPass(n8aopass); ``` -------------------------------- ### Manually Adjusting N8AOPass Quality Settings Source: https://github.com/n8python/n8ao/blob/master/README.md Provides examples of manually configuring N8AOPass quality parameters like `aoSamples`, `denoiseSamples`, and `denoiseRadius`. Changes to these settings trigger shader recompilation and should ideally be set once at application startup. ```js n8aopass.configuration.aoSamples = 16; n8aopass.configuration.denoiseSamples = 8; n8aopass.configuration.denoiseRadius = 12; ``` -------------------------------- ### Clone N8AO Repository Source: https://github.com/n8python/n8ao/blob/master/README.md Provides the command to clone the N8AO project repository from GitHub. ```bash git clone https://github.com/N8python/n8ao.git ``` -------------------------------- ### Three.js Module Imports Source: https://github.com/n8python/n8ao/blob/master/example_postprocessing/index.html Defines the import paths for various Three.js modules and the postprocessing library, essential for 3D rendering and effects. ```javascript { "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.176.0/build/three.module.js", "three/examples/": "https://cdn.jsdelivr.net/npm/three@0.176.0/examples/", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.176.0/examples/jsm/", "postprocessing": "https://cdn.jsdelivr.net/npm/postprocessing@6.37.3/build/index.js" } } ``` -------------------------------- ### Three.js Module Imports Source: https://github.com/n8python/n8ao/blob/master/example/index.html Defines the import paths for various Three.js modules and the postprocessing library, essential for 3D rendering and effects. ```javascript { "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.176.0/build/three.module.js", "three/examples/": "https://cdn.jsdelivr.net/npm/three@0.176.0/examples/", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.176.0/examples/jsm/", "postprocessing": "https://cdn.jsdelivr.net/npm/postprocessing@6.37.3/build/index.js" } } ``` -------------------------------- ### SSAO Styling Source: https://github.com/n8python/n8ao/blob/master/example_postprocessing/index.html Basic CSS rules for the SSAO (Screen Space Ambient Occlusion) effect, setting margin to 0 and disabling overflow. ```css SSAO body { margin: 0; overflow: hidden; } ``` -------------------------------- ### SSAO Styling Source: https://github.com/n8python/n8ao/blob/master/example/index.html Basic CSS rules for the SSAO (Screen Space Ambient Occlusion) effect, setting margin to 0 and disabling overflow. ```css SSAO body { margin: 0; overflow: hidden; } ``` -------------------------------- ### N8AOPass Display Modes Source: https://github.com/n8python/n8ao/blob/master/README.md Demonstrates how to switch between different display modes for visualizing the Ambient Occlusion effect. Available modes include Combined, AO, No AO, Split, and Split AO. ```js n8aopass.setDisplayMode("AO"); // Or any other display mode ``` -------------------------------- ### Integration with pmndrs/postprocessing Source: https://github.com/n8python/n8ao/blob/master/README.md Shows how to use N8AOPostPass with the pmndrs/postprocessing library. This version requires a preceding RenderPass and handles gamma correction automatically based on its pipeline position. ```javascript import { EffectComposer, RenderPass, EffectPass } from 'postprocessing'; import { N8AOPostPass } from 'n8ao'; import { SMAAEffect, SMAAPreset } from 'smaa'; const composer = new EffectComposer(renderer); composer.addPass(new RenderPass(scene, camera)); const n8aopass = new N8AOPostPass( scene, camera, width, height ); composer.addPass(n8aopass); /* SMAA Recommended */ composer.addPass(new EffectPass(camera, new SMAAEffect({ preset: SMAAPreset.ULTRA }))); ``` -------------------------------- ### Manual Transparency Configuration Source: https://github.com/n8python/n8ao/blob/master/README.md Explains how to manually enable or disable transparency awareness in N8AOPass. Setting `transparencyAware` to `true` disables automatic detection. ```js n8aopass.configuration.transparencyAware = true; ``` -------------------------------- ### Using Custom Render Targets with N8AOPass Source: https://github.com/n8python/n8ao/blob/master/README.md Demonstrates how to assign a pre-existing render target with a depth buffer to N8AOPass. This allows N8AOPass to utilize your custom render target instead of generating a new one. It also covers how to disable auto-rendering and the requirement for a depth buffer. ```js const renderTarget = new THREE.WebGLRenderTarget(width, height); // If you just want a depth buffer renderTarget.depthTexture = new THREE.DepthTexture(width, height, THREE.UnsignedIntType); renderTarget.depthTexture.format = THREE.DepthFormat; // If you want a depth buffer and a stencil buffer renderTarget.depthTexture = new THREE.DepthTexture(width, height, THREE.UnsignedInt248Type); renderTarget.depthTexture.format = THREE.DepthStencilFormat; ``` -------------------------------- ### N8AOPass Configuration Parameters Source: https://github.com/n8python/n8ao/blob/master/README.md Demonstrates how to set the core ambient occlusion configuration parameters for N8AOPass. These include aoRadius, distanceFalloff, intensity, and color, which control the visual appearance and behavior of the AO effect. ```javascript n8aopass.configuration.aoRadius = 5.0; n8aopass.configuration.distanceFalloff = 1.0; n8aopass.configuration.intensity = 5.0; n8aopass.configuration.color = new THREE.Color(0, 0, 0); ``` -------------------------------- ### Enabling Frame Accumulation Source: https://github.com/n8python/n8ao/blob/master/README.md Demonstrates how to enable the accumulation of samples across frames to reduce noise and improve AO quality when the camera is stationary. For best results, `denoiseRadius` should be 0 and `denoiseSamples` should be 1. ```js n8aopass.configuration.accumulate = true; ``` -------------------------------- ### Enabling Half-Resolution Mode for Performance Source: https://github.com/n8python/n8ao/blob/master/README.md Explains how to enable N8AOPass's half-resolution mode to improve performance in demanding applications. This mode calculates AO at half the screen resolution and upscales it, offering a significant performance boost at the cost of some detail. ```js n8aopass.configuration.halfRes = true; ``` -------------------------------- ### Stencil Buffer Support Configuration Source: https://github.com/n8python/n8ao/blob/master/README.md Explains how to enable stencil buffer support within N8AOPass. This is a configuration option specific to N8AOPass. ```js n8aopass.configuration.stencil = true; ``` -------------------------------- ### N8AOPass Compatibility and Usage Source: https://github.com/n8python/n8ao/blob/master/README.md Details the browser compatibility of N8AOPass, recommending three.js version r161 or later. It also explains that the pass is self-contained and how to access the scene texture. ```javascript const sceneTexture = n8aopass.beautyRenderTarget; ``` -------------------------------- ### Setting N8AOPass Quality Modes Source: https://github.com/n8python/n8ao/blob/master/README.md Shows how to switch between different quality presets for N8AOPass, such as 'Performance', 'Low', 'Medium', 'High', and 'Ultra'. These presets adjust AO samples, denoise samples, and denoise radius for various performance and visual quality trade-offs. ```js n8ao.setQualityMode("Low"); // Or any other quality mode ``` -------------------------------- ### N8AOPass Screen Space Radius Configuration Source: https://github.com/n8python/n8ao/blob/master/README.md Shows how to enable and configure the screen space radius feature in N8AOPass. This allows the AO effect's radius to be calculated based on screen pixels, with specific parameters for aoRadius and distanceFalloff in this mode. ```javascript n8aopass.configuration.screenSpaceRadius = true; // aoRadius should be set between 16 and 64 pixels // distanceFalloff should be set to 0.2 for most cases ``` -------------------------------- ### Disabling Gamma Correction Source: https://github.com/n8python/n8ao/blob/master/README.md Illustrates how to manually disable gamma correction for the N8AOPass if it conflicts with other passes in the post-processing pipeline. ```javascript n8aopass.configuration.gammaCorrection = false; ``` -------------------------------- ### Enabling and Disabling N8AOPass Debug Mode Source: https://github.com/n8python/n8ao/blob/master/README.md Explains how to enable and disable debug mode for N8AOPass to measure the render pass's execution time. Debug mode relies on WebGL2 features and may not be available in all browsers. ```js n8aopass.enableDebugMode(); // Disable with n8aopass.disableDebugMode(); ``` -------------------------------- ### Treating Objects as Opaque Source: https://github.com/n8python/n8ao/blob/master/README.md Shows how to configure individual meshes to be treated as opaque, preventing them from affecting the AO calculation for transparent objects. This is done by setting `treatAsOpaque` in the mesh's `userData`. ```js mesh.userData.treatAsOpaque = true; ``` -------------------------------- ### AO Tones Configuration Source: https://github.com/n8python/n8ao/blob/master/README.md Explains the `aoTones` property, which controls the number of quantization tones for the AO effect. A value of 0 means the effect is continuous. Values greater than 0 quantize the effect into the specified number of tones. ```js n8aopass.configuration.aoTones = 5; ``` -------------------------------- ### Disabling AO Reception for Objects Source: https://github.com/n8python/n8ao/blob/master/README.md Illustrates how to prevent an object from receiving any AO effect by setting `cannotReceiveAO` to `true` in its `userData`. This requires rendering the object twice and is not recommended for performance-critical applications. ```js mesh.userData.cannotReceiveAO = false; ``` -------------------------------- ### Bias Adjustment Properties Source: https://github.com/n8python/n8ao/blob/master/README.md Details the properties `biasOffset` and `biasMultiplier` used to adjust the bias calculation in N8AO, which can help correct artifacts. The in-shader calculation is `bias = biasOffset + biasMultiplier * bias`. ```js n8aopass.configuration.biasOffset = 0.1; n8aopass.configuration.biasMultiplier = 1.0; ``` -------------------------------- ### Disabling Depth-Aware Upsampling Source: https://github.com/n8python/n8ao/blob/master/README.md Details how to disable depth-aware upsampling in half-resolution mode if extreme performance is required. Disabling this feature can lead to a degraded visual appearance of the AO effect. ```js n8aopass.configuration.depthAwareUpsampling = false; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.