Skip to content

Commit

Permalink
Merge branch 'dev' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy committed Sep 7, 2022
2 parents c4b1322 + c1db3d8 commit 7d9aed6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
24 changes: 21 additions & 3 deletions packages/core/src/shader/utils/generateUniformsSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,27 @@ const GLSL_TO_SINGLE_SETTERS_CACHED: Dict<string> = {
mat3: 'gl.uniformMatrix3fv(location, false, v)',
mat4: 'gl.uniformMatrix4fv(location, false, v)',

sampler2D: 'gl.uniform1i(location, v)',
samplerCube: 'gl.uniform1i(location, v)',
sampler2DArray: 'gl.uniform1i(location, v)',
sampler2D: `
if (cv !== v)
{
cu.value = v;
gl.uniform1i(location, v);
}`,
samplerCube: `
if (cv !== v)
{
cu.value = v;
gl.uniform1i(location, v);
}`,
sampler2DArray: `
if (cv !== v)
{
cu.value = v;
gl.uniform1i(location, v);
}`,
};

const GLSL_TO_ARRAY_SETTERS: Dict<string> = {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/shader/utils/uniformParsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const uniformParsers: IUniformParser[] = [
},
// handling samplers
{
test: (data: any): boolean =>
// eslint-disable-next-line max-len
(data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray,
test: (data: any, uniform: any): boolean =>
// eslint-disable-next-line max-len,no-eq-null,eqeqeq
(data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray && (uniform == null || uniform.castToBaseTexture !== undefined),
code: (name: string): string => `t = syncData.textureCount++;
renderer.texture.bind(uv["${name}"], t);
Expand Down

0 comments on commit 7d9aed6

Please sign in to comment.