Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support post process #2129

Open
wants to merge 30 commits into
base: dev/1.3
Choose a base branch
from
Open

Conversation

zhuxudong
Copy link
Member

@zhuxudong zhuxudong commented Jun 20, 2024

RFC: https://yuque.antfin-inc.com/shensi.zxd/ftoum6/gheugo4e7e1c1oil

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Summary by CodeRabbit

  • New Features

    • Introduced a new bloom effect for post-processing, enhancing the visual quality with adjustable parameters like size, threshold, scatter, and intensity.
  • Improvements

    • Enhanced the cascaded shadow casting with improved texture filtering and wrapping methods, resulting in better shadow quality and performance optimizations.

@zhuxudong zhuxudong added rendering Rendering related functions post processing Post processing labels Jun 20, 2024
@zhuxudong zhuxudong added this to the 1.3 milestone Jun 20, 2024
@zhuxudong zhuxudong self-assigned this Jun 20, 2024
@zhuxudong zhuxudong linked an issue Jun 20, 2024 that may be closed by this pull request
Copy link

coderabbitai bot commented Jun 28, 2024

Walkthrough

The recent changes introduce a new BloomEffect class for enhanced bloom rendering in post-processing, which includes stages like downsampling, blurring, and upsampling. Also, updates were made to the shadow casting logic in CascadedShadowCasterPass.ts, improving texture creation parameters and fixing minor issues.

Changes

File Path Change Summary
packages/core/src/postProcess/effects/BloomEffect.ts Added a BloomEffect class with properties and methods for bloom rendering, shader code for multiple bloom stages, and a new BloomDownScaleMode enum.
packages/core/src/shadow/CascadedShadowCasterPass.ts Updated texture creation parameters for depth and color textures, fixed an engine reference issue, and improved the shadow texture depth comparison logic.

Sequence Diagram(s)

Bloom Effect Control Flow

sequenceDiagram
    participant Scene
    participant BloomEffect
    participant Shader
    participant Renderer

    Scene->>+BloomEffect: Enable BloomEffect
    BloomEffect->>Shader: Load bloom shaders
    BloomEffect->>Renderer: Prepare to render with bloom
    Renderer->>Shader: Apply prefilter
    Renderer->>Shader: Apply horizontal blur
    Renderer->>Shader: Apply vertical blur
    Renderer->>Shader: Apply upsample
    Renderer->>Shader: Apply final composition
    Shader->>+Scene: Rendered scene with bloom effect
Loading

Poem

In code's bright dawn, a bloom takes flight,
With shaders that dance in radiant light.
Shadows adjust, textures refined,
Now clearer, sharper, perfectly aligned.
On pixels' edge, brilliance we see,
A coder's dream, now wild and free. 🌟

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zhuxudong zhuxudong marked this pull request as ready for review July 3, 2024 11:52
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

Outside diff range and nitpick comments (16)
packages/math/src/MathUtil.ts (1)

Line range hint 4-70: Consider refactoring the MathUtil class.

The class contains only static members. Prefer using simple functions instead of classes with only static members.

/**
 * Common utility methods for math operations.
 */
const MathUtil = {
  zeroTolerance: 1e-6,
  radToDegreeFactor: 180 / Math.PI,
  degreeToRadFactor: Math.PI / 180,

  clamp(v: number, min: number, max: number): number {
    return Math.max(min, Math.min(max, v));
  },

  equals(a: number, b: number): boolean {
    return Math.abs(a - b) <= MathUtil.zeroTolerance;
  },

  isPowerOf2(v: number): boolean {
    return (v & (v - 1)) === 0;
  },

  radianToDegree(r: number): number {
    return r * MathUtil.radToDegreeFactor;
  },

  degreeToRadian(d: number): number {
    return d * MathUtil.degreeToRadFactor;
  },

  lerp(start: number, end: number, t: number): number {
    return start + (end - start) * t;
  }
};

export default MathUtil;
Tools
Biome

[error] 4-71: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

e2e/case/postProcess-bloom-tonemap.ts (1)

1-4: Ensure the file header comments are accurate and complete.

The file header comments are clear and provide useful information about the file's purpose and category.

Consider adding more details if necessary.

packages/core/src/RenderPipeline/PipelineUtils.ts (1)

Line range hint 15-220: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

tests/src/core/Camera.test.ts (1)

97-97: Add a description for the new test.

To maintain consistency and clarity, add a brief description of what is being tested for camera.independentCanvasEnabled.

+    // Test independentCanvasEnabled
    expect(camera.independentCanvasEnabled).to.eq(false);
packages/core/src/shadow/CascadedShadowCasterPass.ts (2)

122-124: Consider adding comments for new parameters.

Adding comments for TextureWrapMode.Clamp and TextureFilterMode.Bilinear will improve code readability and maintainability.

        1,
        TextureWrapMode.Clamp,  // Clamp texture wrapping
        TextureFilterMode.Bilinear  // Bilinear texture filtering

137-139: Consider adding comments for new parameters.

Adding comments for TextureWrapMode.Clamp and TextureFilterMode.Bilinear will improve code readability and maintainability.

        1,
        TextureWrapMode.Clamp,  // Clamp texture wrapping
        TextureFilterMode.Bilinear  // Bilinear texture filtering
packages/core/src/Scene.ts (3)

14-14: Add a comment for the new import.

Adding a comment for the PostProcessManager import will improve code readability and maintainability.

import { PostProcessManager } from "./postProcess";  // Post processing manager

67-68: Add a comment for the new property.

Adding a comment for the _postProcessManager property will improve code readability and maintainability.

  /** @internal */
  _postProcessManager = new PostProcessManager(this);  // Manages post-processing effects

269-274: Add a description for the new getter method.

To maintain consistency and clarity, add a brief description of what the postProcessManager getter method does.

  /**
   * Post Process manager.
   * @returns The post-process manager for the scene.
   */
  get postProcessManager(): PostProcessManager {
    return this._postProcessManager;
  }
packages/core/src/postProcess/effects/BloomEffect.ts (4)

1-10: Ensure consistent import order.

For better readability and maintainability, consider grouping and ordering imports consistently, e.g., by module and then alphabetically.


15-24: Consider adding descriptions to enum values.

Adding descriptions to each enum value can improve code readability and maintainability.

/**
 * This controls the size of the bloom texture.
 */
export enum BloomDownScaleMode {
  /**
   *  Use this to select half size as the starting resolution.
   */
  Half,
  /**
   *  Use this to select quarter size as the starting resolution.
   */
  Quarter
}

26-30: Consider adding comments for private static properties.

Adding comments for private static properties can improve code readability and maintainability.

export class BloomEffect extends PostProcessEffect {
  static readonly SHADER_NAME = "postProcessEffect-bloom";

  // High-quality filtering macro
  private static _hqMacro: ShaderMacro = ShaderMacro.getByName("BLOOM_HQ");
  // Dirt texture macro
  private static _dirtMacro: ShaderMacro = ShaderMacro.getByName("BLOOM_DIRT");

42-46: Consider initializing private properties in the constructor.

For better readability and maintainability, consider initializing private properties in the constructor.

private _material: Material;
private _threshold: number = 0.9;
private _scatter: number = 0.7;
private _highQualityFiltering = false;
packages/core/src/postProcess/effects/TonemappingEffect.ts (3)

1-8: Ensure consistent import order.

For better readability and maintainability, consider grouping and ordering imports consistently, e.g., by module and then alphabetically.


13-32: Consider adding descriptions to enum values.

Adding descriptions to each enum value can improve code readability and maintainability.

/**
 * Options to select a tonemapping algorithm to use.
 */
export enum TonemappingMode {
  /**
   * Use this option if you do not want to apply tonemapping
   */
  None,
  /**
   * Neutral tonemapper
   * @remarks Use this option if you only want range-remapping with minimal impact on color hue and saturation.
   */
  Neutral,
  /**
   * ACES Filmic reference tonemapper (custom approximation)
   * @remarks
   * Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
   * It is more contrasted than Neutral and has an effect on actual color hue and saturation.
   */
  ACES
}

37-38: Consider adding comments for private properties.

Adding comments for private properties can improve code readability and maintainability.

private _mode: TonemappingMode;
private _material: Material;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ab7113b and 7979b9b.

Files ignored due to path filters (1)
  • e2e/fixtures/originImage/PostProcess_postProcess-bloom-tonemap.jpg is excluded by !**/*.jpg
Files selected for processing (25)
  • e2e/case/postProcess-bloom-tonemap.ts (1 hunks)
  • e2e/config.ts (1 hunks)
  • packages/core/src/BasicResources.ts (2 hunks)
  • packages/core/src/Camera.ts (10 hunks)
  • packages/core/src/RenderPipeline/BasicRenderPipeline.ts (5 hunks)
  • packages/core/src/RenderPipeline/DepthOnlyPass.ts (2 hunks)
  • packages/core/src/RenderPipeline/OpaqueTexturePass.ts (2 hunks)
  • packages/core/src/RenderPipeline/PipelinePass.ts (1 hunks)
  • packages/core/src/RenderPipeline/PipelineUtils.ts (9 hunks)
  • packages/core/src/RenderPipeline/RenderContext.ts (2 hunks)
  • packages/core/src/RenderPipeline/enums/RenderBufferStoreAction.ts (1 hunks)
  • packages/core/src/RenderPipeline/index.ts (1 hunks)
  • packages/core/src/Scene.ts (3 hunks)
  • packages/core/src/index.ts (1 hunks)
  • packages/core/src/postProcess/PostProcessEffect.ts (1 hunks)
  • packages/core/src/postProcess/PostProcessManager.ts (1 hunks)
  • packages/core/src/postProcess/PostProcessPass.ts (1 hunks)
  • packages/core/src/postProcess/effects/BloomEffect.ts (1 hunks)
  • packages/core/src/postProcess/effects/TonemappingEffect.ts (1 hunks)
  • packages/core/src/postProcess/effects/index.ts (1 hunks)
  • packages/core/src/postProcess/index.ts (1 hunks)
  • packages/core/src/shaderlib/pbr/pbr_helper.glsl (1 hunks)
  • packages/core/src/shadow/CascadedShadowCasterPass.ts (4 hunks)
  • packages/math/src/MathUtil.ts (1 hunks)
  • tests/src/core/Camera.test.ts (1 hunks)
Files skipped from review due to trivial changes (4)
  • packages/core/src/RenderPipeline/PipelinePass.ts
  • packages/core/src/RenderPipeline/enums/RenderBufferStoreAction.ts
  • packages/core/src/postProcess/effects/index.ts
  • packages/core/src/postProcess/index.ts
Additional context used
Biome
packages/math/src/MathUtil.ts

[error] 4-71: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

packages/core/src/postProcess/PostProcessManager.ts

[error] 19-19: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 26-26: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 33-33: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 33-33: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 34-34: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 34-34: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 36-36: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 36-36: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 36-36: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 50-50: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 52-52: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 70-70: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 71-71: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 76-76: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

packages/core/src/RenderPipeline/PipelineUtils.ts

[error] 15-220: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

packages/core/src/shadow/CascadedShadowCasterPass.ts

[error] 85-85: Useless rename.

Safe fix: Remove the renaming.

(lint/complexity/noUselessRename)

Additional comments not posted (51)
packages/core/src/RenderPipeline/index.ts (1)

3-3: Export statement addition looks good.

The new export for RenderBufferStoreAction aligns with the project's structure.

packages/core/src/postProcess/PostProcessEffect.ts (2)

1-2: Import statements look good.

The necessary imports for RenderContext, RenderTarget, and Texture2D are correctly added.


4-21: Abstract class PostProcessEffect looks well-structured.

The class contains a private property _enabled, a constructor, and an abstract method onRender. This structure is appropriate for an abstract class meant to define post-processing effects.

However, ensure that all subclasses implement the onRender method correctly.

packages/core/src/RenderPipeline/OpaqueTexturePass.ts (2)

32-42: Method onConfig looks good.

The method correctly configures the render target based on the camera's opaque texture downsampling settings.


48-49: Method onRender looks good.

The method correctly blits the texture and sets the camera's shader data.

packages/core/src/RenderPipeline/DepthOnlyPass.ts (2)

Line range hint 28-42: Method onConfig looks good.

The method correctly configures the render target based on the camera's pixel viewport and depth texture settings.


49-53: Method onRender looks good.

The method correctly activates the render target, clears it, and renders the opaque and alpha test queues.

packages/math/src/MathUtil.ts (1)

61-70: Method lerp looks good.

The method correctly performs linear interpolation between two values.

packages/core/src/index.ts (1)

65-66: Ensure that the postProcess module is correctly implemented and tested.

The export statement looks good, but make sure the postProcess module is properly implemented and covered by tests.

e2e/case/postProcess-bloom-tonemap.ts (4)

5-20: Imports are well-organized and appropriate.

The imports cover all necessary modules and classes for the post-processing setup.


23-25: Verify the canvas element exists and is correctly referenced.

Ensure that the canvas element with the ID "canvas" exists in the HTML and is correctly referenced.


64-65: Ensure post-processing and HDR settings are correctly applied.

The settings for enabling post-processing and HDR look correct. Validate that they produce the expected visual effects.


67-75: Verify the proper initialization and order of post-processing effects.

The initialization and addition of post-processing effects seem correct. Ensure the order of effects is as intended.

packages/core/src/RenderPipeline/RenderContext.ts (2)

6-6: Ensure the RenderTarget import is necessary and used correctly.

The import statement for RenderTarget is appropriate. Verify its usage within the file.


37-37: Validate the addition of colorTarget property.

The colorTarget property is added correctly. Ensure it is used appropriately within the RenderContext class and other related classes.

e2e/config.ts (1)

184-189: Ensure the PostProcess configuration is consistent with other categories.

The addition of the PostProcess category with bloomAndTonemap looks consistent. Ensure it aligns with the project's configuration standards.

packages/core/src/postProcess/PostProcessPass.ts (11)

1-8: Imports are well-organized and appropriate.

The imports cover all necessary modules and classes for the PostProcessPass setup.


9-12: Initialization of private properties is correct.

The private properties _isActive and _effects are initialized correctly.


13-15: Ensure the name property is used consistently.

The name property is defined correctly. Ensure it is used consistently within the class and other related classes.


16-25: Getters and setters for isActive are correct.

The getters and setters for the isActive property are implemented correctly.


27-33: Getter for effects is correct.

The getter for the effects property is implemented correctly.


34-42: Constructor is implemented correctly.

The constructor initializes the PostProcessPass with the engine and optional name.


44-57: Ensure the onRender method handles post-processing effects correctly.

The onRender method appears to handle post-processing effects correctly. Ensure the logic is as intended and performs well.


59-73: Getter for getEffect is correct.

The getter for the getEffect method is implemented correctly.


75-91: Getter for getEffects is correct.

The getter for the getEffects method is implemented correctly.


93-130: Method addEffect is implemented correctly.

The addEffect method is implemented correctly. Ensure the logic handles edge cases appropriately.


132-142: Method removeEffect is implemented correctly.

The removeEffect method is implemented correctly. Ensure the logic handles edge cases appropriately.

packages/core/src/BasicResources.ts (3)

33-34: Verify the correctness of the vertex coordinates.

The vertex coordinates for the right-bottom and left-top vertices have been changed. Ensure these new coordinates are correct and expected for the intended rendering.


38-40: Verify the correctness of the flipY vertex coordinates.

The vertex coordinates for the right-bottom and left-top vertices in the flipYVertices array have been changed. Ensure these new coordinates are correct and expected for the intended rendering.


81-81: Confirm the change in mesh topology.

The mesh topology has been changed from TriangleStrip to Triangles. Ensure this change is intentional and does not affect the rendering pipeline adversely.

packages/core/src/postProcess/PostProcessManager.ts (5)

79-81: Ensure the _passes property is used correctly.

The _passes property is initialized as a SafeLoopArray. Verify that this property is used correctly in the rest of the class.


115-139: Ensure proper handling of indexOrPass parameter.

The addPass method handles adding a post-process pass at a specified index or appending it to the end. Verify that the method correctly handles both cases and ensures the pass belongs to the current engine.


156-189: Verify the _render method logic.

The _render method handles the rendering of post-processing passes. Ensure that the method correctly manages the rendering context and post-processing passes.


190-190: Ensure proper release of swap render targets.

The _render method releases the swap render targets if post-processing is not enabled. Verify that this logic is correct and does not introduce any resource leaks.


10-13: Avoid using this in a static context.

Using this in a static context can be confusing. Prefer using the class name instead.

-  private static _transformRT: RenderTarget[] = [];
-  private static _rtIdentifier = 0;
-  private static _srcRenderTarget: RenderTarget;
-  private static _destRenderTarget: RenderTarget;
+  private static PostProcessManager._transformRT: RenderTarget[] = [];
+  private static PostProcessManager._rtIdentifier = 0;
+  private static PostProcessManager._srcRenderTarget: RenderTarget;
+  private static PostProcessManager._destRenderTarget: RenderTarget;

Likely invalid or redundant comment.

packages/core/src/shaderlib/pbr/pbr_helper.glsl (1)

14-14: Ensure the clamping logic is correct.

The calculation in the getAARoughnessFactor function has been modified to clamp the value to a maximum of 1.0. Verify that this change is correct and does not affect the rendering quality adversely.

packages/core/src/RenderPipeline/PipelineUtils.ts (4)

18-22: Ensure the new properties are used correctly.

The properties _blitTexelSizeProperty and _texelSize have been added. Verify that these properties are used correctly in the methods of the class.


Line range hint 34-67: Verify the recreateTextureIfNeeded method logic.

The recreateTextureIfNeeded method has been updated to include textureWrapMode and textureFilterMode parameters. Ensure that the method correctly handles these parameters and recreates the texture if needed.


Line range hint 80-138: Verify the recreateRenderTargetIfNeeded method logic.

The recreateRenderTargetIfNeeded method has been updated to include textureWrapMode and textureFilterMode parameters. Ensure that the method correctly handles these parameters and recreates the render target if needed.


Line range hint 149-218: Verify the blitTexture method logic.

The blitTexture method has been updated to include material, passIndex, and renderBufferStoreAction parameters. Ensure that the method correctly handles these parameters and performs the blit operation as expected.

packages/core/src/RenderPipeline/BasicRenderPipeline.ts (5)

118-124: Verify the internal color target handling.

The internal color target is recreated if needed with the specified parameters. Ensure that this logic is correct and does not introduce any rendering issues.


153-157: Verify the color target and viewport handling.

The _drawRenderPass method handles the color target and viewport. Ensure that this logic is correct and does not introduce any rendering issues.


200-203: Verify the post-process rendering logic.

The post-process manager's _render method is called to handle post-processing effects. Ensure that this logic is correct and integrates well with the rest of the rendering pipeline.


208-216: Verify the final blit operation.

The final blit operation copies the internalColorTarget to camera.renderTarget. Ensure that this logic is correct and does not introduce any rendering issues.


210-216: Verify the background texture rendering logic.

The _drawBackgroundTexture method handles rendering the background texture. Ensure that this logic is correct and does not introduce any rendering issues.

packages/core/src/Scene.ts (1)

272-274: LGTM!

The postProcessManager getter method is correctly implemented.

packages/core/src/Camera.ts (5)

122-123: Verify the usage of new private properties _enableHDR and _enablePostProcess.

Ensure these properties are used correctly within the class and are properly initialized.

Verification successful

The new private properties _enableHDR and _enablePostProcess are used correctly within the Camera class.

  • _enableHDR is accessed via getter and setter methods and used in a conditional expression.
  • _enablePostProcess is accessed via getter and setter methods and used in a conditional expression.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of new private properties `_enableHDR` and `_enablePostProcess`.

# Test: Search for the usage of `_enableHDR` and `_enablePostProcess` within the `Camera` class.
rg --type-add 'ts:*.ts' --type ts '_enableHDR|_enablePostProcess' packages/core/src/Camera.ts

Length of output: 424


730-732: Verify the correctness of _getInternalColorTextureFormat method.

Ensure the method correctly returns the appropriate texture format based on the _enableHDR property.

Verification successful

To verify the correctness of the _getInternalColorTextureFormat method, we need to check the following:

  1. The definition and usage of the _enableHDR property within the Camera class.
  2. The import and definition of TextureFormat.

Let's proceed with generating the necessary shell scripts to gather this information.


The _getInternalColorTextureFormat method is correctly implemented.

  • The _enableHDR property is defined within the Camera class.
  • The TextureFormat is correctly imported and used.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of `_getInternalColorTextureFormat` method.

# Test: Ensure the method correctly returns the appropriate texture format based on the `_enableHDR` property.
rg --type-add 'ts:*.ts' --type ts '_getInternalColorTextureFormat' packages/core/src/Camera.ts

Length of output: 146



Script:

#!/bin/bash
# Verify the definition and usage of `_enableHDR` within Camera class.
ast-grep --lang typescript --pattern 'class Camera {
  $$$
  private _enableHDR: $_;
  $$$
}' packages/core/src/Camera.ts

# Verify the import of `TextureFormat`.
rg 'TextureFormat' packages/core/src/Camera.ts

Length of output: 496


369-385: Verify the correctness of enableHDR getter and setter.

Ensure the getter and setter methods correctly handle the _enableHDR property and include proper checks for hardware support.

Verification successful

The enableHDR getter and setter methods are correctly implemented.

  • The _enableHDR property is properly initialized.
  • The setter method includes the necessary hardware support check using GLCapabilityType.textureHalfFloat.
  • The Logger.warn method is used appropriately to log warnings.
  • The _checkMainCanvasAntialiasWaste method is invoked correctly in the setter.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of `enableHDR` getter and setter.

# Test: Ensure the getter and setter methods correctly handle the `_enableHDR` property and include proper checks for hardware support.
rg --type-add 'ts:*.ts' --type ts 'enableHDR' packages/core/src/Camera.ts

Length of output: 451



Script:

#!/bin/bash
# Verify the initialization of the _enableHDR property
rg --type-add 'ts:*.ts' --type ts '_enableHDR' packages/core/src/Camera.ts

# Verify the usage of GLCapabilityType.textureHalfFloat
rg --type-add 'ts:*.ts' --type ts 'GLCapabilityType.textureHalfFloat' packages/core/src/Camera.ts

# Verify the Logger.warn method
rg --type-add 'ts:*.ts' --type ts 'Logger.warn' packages/core/src/Camera.ts

# Verify the _checkMainCanvasAntialiasWaste method
rg --type-add 'ts:*.ts' --type ts '_checkMainCanvasAntialiasWaste' packages/core/src/Camera.ts

Length of output: 915


387-400: Verify the correctness of enablePostProcess getter and setter.

Ensure the getter and setter methods correctly handle the _enablePostProcess property.

Verification successful

The enablePostProcess getter and setter are correctly implemented.

The _checkMainCanvasAntialiasWaste method correctly handles the necessary conditions when enablePostProcess is set.

  • Implementation of _checkMainCanvasAntialiasWaste method is verified and correct.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of `enablePostProcess` getter and setter.

# Test: Ensure the getter and setter methods correctly handle the `_enablePostProcess` property.
rg --type-add 'ts:*.ts' --type ts 'enablePostProcess' packages/core/src/Camera.ts

Length of output: 488



Script:

#!/bin/bash
# Description: Verify the definition and implementation of the `_checkMainCanvasAntialiasWaste` method.

# Test: Ensure the `_checkMainCanvasAntialiasWaste` method is defined and correctly handles the changes when `enablePostProcess` is set.
rg --type-add 'ts:*.ts' --type ts '_checkMainCanvasAntialiasWaste' packages/core/src/Camera.ts

Length of output: 323



Script:

#!/bin/bash
# Description: Retrieve the implementation details of the `_checkMainCanvasAntialiasWaste` method.

# Test: Ensure the `_checkMainCanvasAntialiasWaste` method correctly handles the changes when `enablePostProcess` is set.
ast-grep --lang typescript --pattern $'class $_ {
  private _checkMainCanvasAntialiasWaste(): void {
    $$$
  }
}' packages/core/src/Camera.ts

Length of output: 144



Script:

#!/bin/bash
# Description: Retrieve the implementation details of the `_checkMainCanvasAntialiasWaste` method using rg.

# Test: Ensure the `_checkMainCanvasAntialiasWaste` method correctly handles the changes when `enablePostProcess` is set.
rg --type-add 'ts:*.ts' --type ts 'private _checkMainCanvasAntialiasWaste' -A 20 packages/core/src/Camera.ts

Length of output: 477


166-174: Verify the logic of independentCanvasEnabled getter.

Ensure the logic correctly handles the new _enableHDR and _enablePostProcess properties.

e2e/case/postProcess-bloom-tonemap.ts Show resolved Hide resolved
tests/src/core/Camera.test.ts Show resolved Hide resolved
packages/core/src/shadow/CascadedShadowCasterPass.ts Outdated Show resolved Hide resolved
packages/core/src/postProcess/effects/BloomEffect.ts Outdated Show resolved Hide resolved
packages/core/src/postProcess/effects/BloomEffect.ts Outdated Show resolved Hide resolved
packages/core/src/postProcess/effects/BloomEffect.ts Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7979b9b and d377549.

Files selected for processing (2)
  • packages/core/src/postProcess/effects/BloomEffect.ts (1 hunks)
  • packages/core/src/shadow/CascadedShadowCasterPass.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/shadow/CascadedShadowCasterPass.ts
Additional comments not posted (10)
packages/core/src/postProcess/effects/BloomEffect.ts (10)

1-25: LGTM!

The imports and enum declaration are correct.


27-41: LGTM!

The class definition and static properties are correctly implemented.


43-80: LGTM!

The threshold property and its getter and setter methods are correctly implemented with necessary validation.


82-98: LGTM!

The scatter property and its getter and setter methods are correctly implemented with necessary validation.


100-111: LGTM!

The intensity property and its getter and setter methods are correctly implemented with necessary validation.


113-125: LGTM!

The tint property and its getter and setter methods are correctly implemented with necessary color updates.


127-145: LGTM!

The highQualityFiltering property and its getter and setter methods are correctly implemented with necessary macro updates.


147-161: LGTM!

The dirtTexture property and its getter and setter methods are correctly implemented with necessary macro updates.


163-172: LGTM!

The dirtIntensity property and its getter and setter methods are correctly implemented with necessary shader data updates.


220-625: LGTM!

The remaining methods and shader fragments are correctly implemented with necessary shader logic.

Comment on lines +174 to +194
constructor(engine: Engine) {
super(engine);

const material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
const depthState = material.renderState.depthState;

depthState.enabled = false;
depthState.writeEnabled = false;

const shaderData = material.shaderData;
shaderData.setVector4(BloomEffect._bloomParams, new Vector4());
shaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
shaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
shaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));

this._material = material;
this.threshold = 0.9;
this.scatter = 0.7;
this.intensity = 1;
this.dirtIntensity = 1;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider initializing material properties in a separate method.

For better readability and maintainability, consider initializing material properties in a separate method.

constructor(engine: Engine) {
  super(engine);

  this._material = this._createMaterial(engine);
  this.threshold = 0.9;
  this.scatter = 0.7;
  this.intensity = 1;
  this.dirtIntensity = 1;
}

private _createMaterial(engine: Engine): Material {
  const material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
  const depthState = material.renderState.depthState;

  depthState.enabled = false;
  depthState.writeEnabled = false;

  const shaderData = material.shaderData;
  shaderData.setVector4(BloomEffect._bloomParams, new Vector4());
  shaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
  shaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
  shaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));

  return material;
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(engine: Engine) {
super(engine);
const material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
const depthState = material.renderState.depthState;
depthState.enabled = false;
depthState.writeEnabled = false;
const shaderData = material.shaderData;
shaderData.setVector4(BloomEffect._bloomParams, new Vector4());
shaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
shaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
shaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));
this._material = material;
this.threshold = 0.9;
this.scatter = 0.7;
this.intensity = 1;
this.dirtIntensity = 1;
}
constructor(engine: Engine) {
super(engine);
this._material = this._createMaterial(engine);
this.threshold = 0.9;
this.scatter = 0.7;
this.intensity = 1;
this.dirtIntensity = 1;
}
private _createMaterial(engine: Engine): Material {
const material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
const depthState = material.renderState.depthState;
depthState.enabled = false;
depthState.writeEnabled = false;
const shaderData = material.shaderData;
shaderData.setVector4(BloomEffect._bloomParams, new Vector4());
shaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
shaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
shaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));
return material;
}

Comment on lines +196 to +218
override onRender(context: RenderContext, srcTexture: Texture2D, destRenderTarget: RenderTarget): void {
const engine = this.engine;
const camera = context.camera;
const material = this._material;
const downRes = this.downScale === BloomDownScaleMode.Half ? 1 : 2;
const pixelViewport = camera.pixelViewport;
const tw = pixelViewport.width >> downRes;
const th = pixelViewport.height >> downRes;

// Determine the iteration count
const mipCount = this._calculateMipCount(tw, th);

// Prefilter
this._prefilter(camera, srcTexture, tw, th, mipCount);
// Down sample - gaussian pyramid
this._downsample(mipCount);
// Up sample (bilinear by default, HQ filtering does bicubic instead
this._upsample(mipCount);
// Setup bloom on uber
this._setupBloom(camera);

PipelineUtils.blitTexture(engine, srcTexture, destRenderTarget, undefined, undefined, material, 4);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider splitting the onRender method into smaller methods.

The onRender method is quite large and can be split into smaller methods for better readability and maintainability.

override onRender(context: RenderContext, srcTexture: Texture2D, destRenderTarget: RenderTarget): void {
  const engine = this.engine;
  const camera = context.camera;
  const material = this._material;
  const shaderData = material.shaderData;
  const downRes = this.downScale === BloomDownScaleMode.Half ? 1 : 2;
  const pixelViewport = camera.pixelViewport;
  const tw = pixelViewport.width >> downRes;
  const th = pixelViewport.height >> downRes;

  const mipCount = this._calculateMipCount(tw, th);
  this._prefilter(engine, camera, srcTexture, tw, th, mipCount);
  this._downsample(engine, material, mipCount);
  this._upsample(engine, camera, material, mipCount);
  this._setupBloom(shaderData, camera);

  PipelineUtils.blitTexture(engine, srcTexture, destRenderTarget, undefined, undefined, material, 4);
}

private _calculateMipCount(tw: number, th: number): number {
  const maxSize = Math.max(tw, th);
  const iterations = Math.floor(Math.log2(maxSize) - 1);
  return Math.min(Math.max(iterations, 1), this._maxIterations);
}

private _prefilter(engine: Engine, camera: Camera, srcTexture: Texture2D, tw: number, th: number, mipCount: number): void {
  let mipWidth = tw,
    mipHeight = th;
  for (let i = 0; i < mipCount; i++) {
    this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(
      engine,
      this._mipUpRT[i],
      mipWidth,
      mipHeight,
      camera._getInternalColorTextureFormat(),
      null,
      false,
      false,
      camera.msaaSamples,
      TextureWrapMode.Clamp,
      TextureFilterMode.Bilinear
    );
    this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(
      engine,
      this._mipDownRT[i],
      mipWidth,
      mipHeight,
      camera._getInternalColorTextureFormat(),
      null,
      false,
      false,
      camera.msaaSamples,
      TextureWrapMode.Clamp,
      TextureFilterMode.Bilinear
    );

    mipWidth = Math.max(1, Math.floor(mipWidth / 2));
    mipHeight = Math.max(1, Math.floor(mipHeight / 2));
  }

  PipelineUtils.blitTexture(
    engine,
    srcTexture,
    this._mipDownRT[0],
    undefined,
    undefined,
    this._material,
    0,
    RenderBufferStoreAction.BlitMSAA
  );
}

private _downsample(engine: Engine, material: Material, mipCount: number): void {
  var lastDown = this._mipDownRT[0];
  for (let i = 1; i < mipCount; i++) {
    PipelineUtils.blitTexture(
      engine,
      <Texture2D>lastDown.getColorTexture(0),
      this._mipUpRT[i],
      undefined,
      undefined,
      material,
      1,
      RenderBufferStoreAction.BlitMSAA
    );
    PipelineUtils.blitTexture(
      engine,
      <Texture2D>this._mipUpRT[i].getColorTexture(0),
      this._mipDownRT[i],
      undefined,
      undefined,
      material,
      2,
      RenderBufferStoreAction.BlitMSAA
    );

    lastDown = this._mipDownRT[i];
  }
}

private _upsample(engine: Engine, camera: Camera, material: Material, mipCount: number): void {
  for (let i = mipCount - 2; i >= 0; i--) {
    const lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
    const highMip = this._mipDownRT[i];
    const dst = this._mipUpRT[i];

    material.shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
    if (this.highQualityFiltering) {
      const texelSizeLow = material.shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
      texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
    }

    PipelineUtils.blitTexture(
      engine,
      <Texture2D>highMip.getColorTexture(0),
      dst,
      undefined,
      undefined,
      material,
      3,
      RenderBufferStoreAction.BlitMSAA
    );
  }
}

private _setupBloom(shaderData: ShaderData, camera: Camera): void {
  const dirtTexture = this.dirtTexture;
  if (dirtTexture) {
    const dirtTilingOffset = shaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
    const dirtRatio = dirtTexture.width / dirtTexture.height;
    const screenRatio = camera.aspectRatio;
    if (dirtRatio > screenRatio) {
      dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
    } else if (dirtRatio < screenRatio) {
      dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
    } else {
      dirtTilingOffset.set(1, 1, 0, 0);
    }
  }

  shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
override onRender(context: RenderContext, srcTexture: Texture2D, destRenderTarget: RenderTarget): void {
const engine = this.engine;
const camera = context.camera;
const material = this._material;
const downRes = this.downScale === BloomDownScaleMode.Half ? 1 : 2;
const pixelViewport = camera.pixelViewport;
const tw = pixelViewport.width >> downRes;
const th = pixelViewport.height >> downRes;
// Determine the iteration count
const mipCount = this._calculateMipCount(tw, th);
// Prefilter
this._prefilter(camera, srcTexture, tw, th, mipCount);
// Down sample - gaussian pyramid
this._downsample(mipCount);
// Up sample (bilinear by default, HQ filtering does bicubic instead
this._upsample(mipCount);
// Setup bloom on uber
this._setupBloom(camera);
PipelineUtils.blitTexture(engine, srcTexture, destRenderTarget, undefined, undefined, material, 4);
}
override onRender(context: RenderContext, srcTexture: Texture2D, destRenderTarget: RenderTarget): void {
const engine = this.engine;
const camera = context.camera;
const material = this._material;
const downRes = this.downScale === BloomDownScaleMode.Half ? 1 : 2;
const pixelViewport = camera.pixelViewport;
const tw = pixelViewport.width >> downRes;
const th = pixelViewport.height >> downRes;
// Determine the iteration count
const mipCount = this._calculateMipCount(tw, th);
// Prefilter
this._prefilter(camera, srcTexture, tw, th, mipCount);
// Down sample - gaussian pyramid
this._downsample(mipCount);
// Up sample (bilinear by default, HQ filtering does bicubic instead
this._upsample(mipCount);
// Setup bloom on uber
this._setupBloom(camera);
PipelineUtils.blitTexture(engine, srcTexture, destRenderTarget, undefined, undefined, material, 4);
}
private _calculateMipCount(tw: number, th: number): number {
const maxSize = Math.max(tw, th);
const iterations = Math.floor(Math.log2(maxSize) - 1);
return Math.min(Math.max(iterations, 1), this._maxIterations);
}
private _prefilter(engine: Engine, camera: Camera, srcTexture: Texture2D, tw: number, th: number, mipCount: number): void {
let mipWidth = tw,
mipHeight = th;
for (let i = 0; i < mipCount; i++) {
this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(
engine,
this._mipUpRT[i],
mipWidth,
mipHeight,
camera._getInternalColorTextureFormat(),
null,
false,
false,
camera.msaaSamples,
TextureWrapMode.Clamp,
TextureFilterMode.Bilinear
);
this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(
engine,
this._mipDownRT[i],
mipWidth,
mipHeight,
camera._getInternalColorTextureFormat(),
null,
false,
false,
camera.msaaSamples,
TextureWrapMode.Clamp,
TextureFilterMode.Bilinear
);
mipWidth = Math.max(1, Math.floor(mipWidth / 2));
mipHeight = Math.max(1, Math.floor(mipHeight / 2));
}
PipelineUtils.blitTexture(
engine,
srcTexture,
this._mipDownRT[0],
undefined,
undefined,
this._material,
0,
RenderBufferStoreAction.BlitMSAA
);
}
private _downsample(engine: Engine, material: Material, mipCount: number): void {
var lastDown = this._mipDownRT[0];
for (let i = 1; i < mipCount; i++) {
PipelineUtils.blitTexture(
engine,
<Texture2D>lastDown.getColorTexture(0),
this._mipUpRT[i],
undefined,
undefined,
material,
1,
RenderBufferStoreAction.BlitMSAA
);
PipelineUtils.blitTexture(
engine,
<Texture2D>this._mipUpRT[i].getColorTexture(0),
this._mipDownRT[i],
undefined,
undefined,
material,
2,
RenderBufferStoreAction.BlitMSAA
);
lastDown = this._mipDownRT[i];
}
}
private _upsample(engine: Engine, camera: Camera, material: Material, mipCount: number): void {
for (let i = mipCount - 2; i >= 0; i--) {
const lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
const highMip = this._mipDownRT[i];
const dst = this._mipUpRT[i];
material.shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
if (this.highQualityFiltering) {
const texelSizeLow = material.shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
}
PipelineUtils.blitTexture(
engine,
<Texture2D>highMip.getColorTexture(0),
dst,
undefined,
undefined,
material,
3,
RenderBufferStoreAction.BlitMSAA
);
}
}
private _setupBloom(shaderData: ShaderData, camera: Camera): void {
const dirtTexture = this.dirtTexture;
if (dirtTexture) {
const dirtTilingOffset = shaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
const dirtRatio = dirtTexture.width / dirtTexture.height;
const screenRatio = camera.aspectRatio;
if (dirtRatio > screenRatio) {
dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
} else if (dirtRatio < screenRatio) {
dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
} else {
dirtTilingOffset.set(1, 1, 0, 0);
}
}
shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
}

@zhuxudong
Copy link
Member Author

待讨论问题:

  • _forceUseInternalCanvas 是否要根据是否有激活的 Effect
  • manager.addpass 时是否需要判断 pass 是否在别的 manager 里面
  • Blit Traniagnle / quad
  • Blit后,应该还原 RT, viewport, context.flipProjection, mipLevel, cubeFace ?(暂时不用还原,有些操作如果还原了,下次又得重新设置,更加浪费性能)
  • RenderBufferStoreAction 的 Resolve 、Store 如何用 webgl 实现,或者先实现基本基本的是否 blit
  • 是否需要 Clear color/depth/stensil (暂时不需要)
  • RT.texture 应该设置 clamp, point ?
  • Gamma to linear
  • downres 可以增加 BloomDownscaleMode 枚举配置
  • 不支持 HDR 的时候,还可以使用 rgbm 作为替代方案, 或者B10G11R11_UFloatPack32
  • use shaderLab
  • 开启 enableHDR ,但是没有后处理,opaque 时,是否需要 internal
  • tintColor 是否需要跟 unity 一样保持亮度,intensity 决定最终亮度
  • 后处理shader 中的透明通道
  • 是否判断最后一个 Effect 机制,可以节省一个 Blit
  • onRender 需不需要强制写到 destRT 中,比如 tonemapping 模式为 none 时其实不需要 blit,但是不Blit 的话,对管线的统一 Swap 而言就不确定了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pipeline post processing Post processing rendering Rendering related functions
Projects
Development

Successfully merging this pull request may close these issues.

Support Post Process Pipeline
1 participant