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

Fix background render error when render to RT #2414

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/RenderPipeline/BasicRenderPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
if (background.mode === BackgroundMode.Sky) {
background.sky._render(context);
} else if (background.mode === BackgroundMode.Texture && background.texture) {
this._drawBackgroundTexture(engine, background);
this._drawBackgroundTexture(camera, background);

Check warning on line 178 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L178

Added line #L178 was not covered by tests
}
}

Expand Down Expand Up @@ -300,7 +300,8 @@
}
}

private _drawBackgroundTexture(engine: Engine, background: Background) {
private _drawBackgroundTexture(camera: Camera, background: Background) {
const engine = camera.engine;

Check warning on line 304 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L304

Added line #L304 was not covered by tests
const rhi = engine._hardwareRenderer;
const { canvas } = engine;
const { _material: material, _mesh: mesh } = background;
Expand All @@ -317,6 +318,7 @@
const program = pass._getShaderProgram(engine, Shader._compileMacros);
program.bind();
program.uploadAll(program.materialUniformBlock, material.shaderData);
program.uploadAll(program.cameraUniformBlock, camera.shaderData);

Check warning on line 321 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L321

Added line #L321 was not covered by tests
program.uploadUnGroupTextures();

(pass._renderState || material.renderState)._applyStates(
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/shaderlib/extra/background-texture.vs.glsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
attribute vec3 POSITION;
attribute vec2 TEXCOORD_0;

varying vec2 v_uv;
uniform vec4 camera_ProjectionParams;

void main() {
gl_Position = vec4(POSITION, 1.0);
gl_Position.y *= camera_ProjectionParams.x;

v_uv = TEXCOORD_0;
}
Loading