Skip to content

Commit

Permalink
deprecate: v_texcoord in ScreenShader
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Aug 5, 2024
1 parent 004e96f commit d17b30f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Deprecated

- `ScreenShader` v_texcoord is deprecated, use v_uv. This is changed to match the materials shader API
- `actor.getGlobalPos()` - use `actor.globalPos` instead
- `actor.getGlobalRotation()` - use `actor.globalRotation` instead
- `actor.getGlobalScale()` - use `actor.globalScale` instead
Expand Down
17 changes: 14 additions & 3 deletions src/engine/Graphics/PostProcessor/ScreenShader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Logger } from '../../Util/Log';
import { Shader } from '../Context/shader';
import { VertexBuffer } from '../Context/vertex-buffer';
import { VertexLayout } from '../Context/vertex-layout';
Expand All @@ -13,17 +14,27 @@ export class ScreenShader {
private _buffer: VertexBuffer;
private _layout: VertexLayout;
constructor(gl: WebGL2RenderingContext, fragmentSource: string) {
if (process.env.NODE_ENV === 'development') {
if (fragmentSource.includes('v_texcoord')) {
Logger.getInstance().warn(
`ScreenShader: "v_texcoord" is deprecated in postprocessing fragment shaders will be removed in v1.0,` +
` use "v_uv" instead. Source [${fragmentSource}]`
);
}
}
this._shader = new Shader({
gl,
vertexSource: `#version 300 es
in vec2 a_position;
in vec2 a_texcoord;
in vec2 a_uv;
out vec2 v_texcoord;
out vec2 v_uv;
void main() {
gl_Position = vec4(a_position, 0.0, 1.0);
// Pass the texcoord to the fragment shader.
v_texcoord = a_texcoord;
v_texcoord = a_uv;
v_uv = a_uv;
}`,
fragmentSource: fragmentSource
});
Expand All @@ -45,7 +56,7 @@ export class ScreenShader {
vertexBuffer: this._buffer,
attributes: [
['a_position', 2],
['a_texcoord', 2]
['a_uv', 2]
]
});
this._buffer.upload();
Expand Down

0 comments on commit d17b30f

Please sign in to comment.