Skip to content

Commit

Permalink
Fix default precision declaration in ShaderLab (#2286)
Browse files Browse the repository at this point in the history
* fix: default precision setting in shaderlab
  • Loading branch information
Sway007 authored Aug 5, 2024
1 parent 27da33c commit e79ed2d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/shader-lab/src/codeGen/GLESVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import { ICodeSegment } from "./types";
import { Logger } from "@galacean/engine";
import { VisitorContext } from "./VisitorContext";

const defaultPrecision = `precision mediump float;`;
const defaultPrecision = `
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif
`;

export abstract class GLESVisitor extends CodeGenVisitor {
protected _versionText: string = "";
Expand Down Expand Up @@ -82,7 +90,7 @@ export abstract class GLESVisitor extends CodeGenVisitor {

VisitorContext.context.reset();

return `${this._versionText}\n${defaultPrecision}\n${globalCode}\n\nvoid main() ${statements}`;
return `${this._versionText}\n${globalCode}\n\nvoid main() ${statements}`;
}

private _fragmentMain(entry: string, data: ShaderData): string {
Expand Down

0 comments on commit e79ed2d

Please sign in to comment.