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 camera depth texture #1658

Merged
merged 32 commits into from
Aug 4, 2023
Merged

Conversation

GuoLei1990
Copy link
Member

@GuoLei1990 GuoLei1990 commented Jul 22, 2023

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)

Feat:

  • Camera support depthTextureMode
  • Camera support pixelViewport

Playground:galacean/galacean.github.io#764

@GuoLei1990 GuoLei1990 marked this pull request as draft July 22, 2023 12:42
@GuoLei1990 GuoLei1990 changed the base branch from main to dev/1.1 July 22, 2023 12:42
@GuoLei1990 GuoLei1990 added the enhancement New feature or request label Jul 23, 2023
@GuoLei1990 GuoLei1990 added this to the 1.1 milestone Jul 23, 2023
@GuoLei1990 GuoLei1990 self-assigned this Jul 23, 2023
@GuoLei1990 GuoLei1990 marked this pull request as ready for review July 26, 2023 11:06
@GuoLei1990 GuoLei1990 linked an issue Jul 26, 2023 that may be closed by this pull request
pipelineStage: PipelineStage.ShadowCaster
};
});
const basePasses = [depthOnlyPass, shadowCasterPass];
Copy link
Member

Choose a reason for hiding this comment

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

use [shadowCasterPass, depthOnlyPass] to be compatible with previous usage

Copy link
Member Author

Choose a reason for hiding this comment

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

done

#include <blendShape_vert>
#include <skinning_vert>

gl_Position = renderer_MVPMat * position;
Copy link
Member

Choose a reason for hiding this comment

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

why not use #include <position_vert>

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,3 @@
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
Copy link
Member

Choose a reason for hiding this comment

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

delete this line is better

Copy link
Member Author

Choose a reason for hiding this comment

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

done

* @internal
* Culling results.
*/
export class CullingResults {
Copy link
Member

Choose a reason for hiding this comment

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

why not called RendererQueueManager

Copy link
Member Author

Choose a reason for hiding this comment

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

The design is just save the cull info to save cull performance

*/
static recreateTextureIfNeeded(
engine: Engine,
currentTexture: Texture2D,
Copy link
Member

Choose a reason for hiding this comment

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

currentTexture: Texture2D | void

Copy link
Member Author

Choose a reason for hiding this comment

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

done with currentTexture: Texture2D | null

*/
static recreateRenderTargetIfNeeded(
engine: Engine,
currentRenderTarget: RenderTarget,
Copy link
Member

Choose a reason for hiding this comment

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

currentRenderTarget: RenderTarget | void

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,21 @@
import { Engine } from "../Engine";
Copy link
Member

Choose a reason for hiding this comment

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

this file should migrate to core/src/RenderPipeline

Copy link
Member Author

Choose a reason for hiding this comment

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

done

export abstract class PipelinePass {
protected _engine: Engine;

constructor(engine: Engine) {
Copy link
Member

Choose a reason for hiding this comment

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

I think based on Camera is better, DepthOnlyPass and CascadedShadowCasterPass will be more suitable

Copy link
Member Author

Choose a reason for hiding this comment

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

Different camera use the same Pipeline pass instance, should not bind camera in constrouctor

* @param context - Rendering context
* @param cullingResults - Culling results
*/
abstract onRender(context: RenderContext, cullingResults: CullingResults): void;
Copy link
Member

Choose a reason for hiding this comment

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

if based on camera, context and cullingResults can be ignored from camera.engine._renderContext and camera.renderPipeline._cullingResults

@@ -32,9 +33,11 @@ class MathTemp {
@dependentComponents(Transform, DependentMode.CheckOnly)
export class Camera extends Component {
/** @internal */
static _cameraTextureProperty = ShaderProperty.getByName("camera_DepthTexture");
Copy link
Member

Choose a reason for hiding this comment

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

_cameraDepthTextureProperty

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -179,7 +173,8 @@ export class BasicRenderPipeline {
cubeFace?: TextureCubeFace,
mipLevel?: number
) {
pass.preRender(camera, this._opaqueQueue, this._alphaTestQueue, this._transparentQueue);
const cullingResults = this._cullingResults;
Copy link
Member

Choose a reason for hiding this comment

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

const {opaqueQueue, alphaTestQueue, transparentQueue} = cullingResults;

Copy link
Member Author

Choose a reason for hiding this comment

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

done

* dev/1.1: (48 commits)
  fix: skin mesh error (galacean#1675)
  fix: test error (galacean#1674)
  test: fix github test (galacean#1669)
  test: fix ci not work (galacean#1670)
  glTF support basisu (galacean#1662)
  fix: `EventDispatcher` static pool bug
  fix: eventdispatcher bug (galacean#1671)
  fix: animation event bug (galacean#1666)
  Shader pass support blend (galacean#1668)
  Fix model mesh advanced data write bug (galacean#1663)
  Cherry pick glTF conflict (galacean#1660)
  Fix worker status set error and can't throw error bug (galacean#1652)
  Fix parse glTF texture wrap & filterMode bug (galacean#1659)
  Add shader lab package and support shader framework (galacean#1610)
  Fix text wrap bug (galacean#1644)
  chore: use strict error msg and type (galacean#1647)
  Fix text error for set text to "" and set enableWrapping to true (galacean#1634)
  "v1.0.0-beta.17"
  Process GLTFBufferParser and GLTFTextureParser pipelines in parallel (galacean#1638)
  Fix animation clip loader, clip change promise to assetPromise, controller json parse (galacean#1506)
  ...
Copy link
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp left a comment

Choose a reason for hiding this comment

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

+1

@GuoLei1990 GuoLei1990 merged commit ce11f72 into galacean:dev/1.1 Aug 4, 2023
4 of 5 checks passed
GuoLei1990 added a commit to GuoLei1990/galacean-engine that referenced this pull request Aug 4, 2023
* dev/1.1:
  `SkinnedMeshRenderer` support immediate initialization of `rootBone` and `bones` (galacean#1672)
  Support camera depth texture (galacean#1658)
zhuxudong added a commit to zhuxudong/engine that referenced this pull request Aug 17, 2023
* dev/1.1: (66 commits)
  build: fix pnpm lock file
  build: fix pnpm-lock file
  build: fix pnpm-lock file
  build: fix build error
  `ResourceManager` support `findResourcesByType` (galacean#1700)
  fix: memory leak of Transform (galacean#1701)
  fix: file name error
  "v1.1.0-alpha.1"
  test(RenderTarget): fix `getColorTexture` error
  Fix ktx2 loader can't throw error (galacean#1699)
  Enhance type for `LoadItem` & `Entity.getComponent` (galacean#1696)
  types: opt getComponent return type
  types: fix lint
  Fix ci test (galacean#1677)
  Shader Lab support `RenderState` (galacean#1664)
  feat: enhance type for `LoadItem` & `Entity.getComponent`
  fix: variable error (galacean#1693)
  `SkinnedMeshRenderer` support immediate initialization of `rootBone` and `bones` (galacean#1672)
  Support camera depth texture (galacean#1658)
  "v1.0.0-beta.18"
  ...

# Conflicts:
#	packages/loader/src/gltf/parser/GLTFSceneParser.ts
#	packages/loader/src/gltf/parser/GLTFSkinParser.ts
#	tests/src/loader/GLTFLoader.test.ts
@GuoLei1990 GuoLei1990 deleted the PR/deth-texture branch September 18, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pipeline support Depth Texture
3 participants