Skip to content

Commit 331dec6

Browse files
committed
fix: no worker: change "u_sampler2D0" to "u_sampler2D"
test: pass all no worker unit tests
1 parent 7f34aed commit 331dec6

13 files changed

Lines changed: 35 additions & 35 deletions

File tree

src/renderer/shader/chunk/ShaderChunk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const frontLight_fragment:GLSLChunk = {top: "",define: "",varDeclare: "",
1919
export const frontLight_setWorldPosition_vertex:GLSLChunk = {top: "",define: "",varDeclare: "",funcDeclare: "",funcDefine: "",body: "v_worldPosition = vec3(mMatrix * vec4(a_position, 1.0));\n"};
2020
export const frontLight_vertex:GLSLChunk = {top: "",define: "",varDeclare: "",funcDeclare: "",funcDefine: "",body: "gl_Position = u_pMatrix * u_vMatrix * vec4(v_worldPosition, 1.0);\n"};
2121
export const webgl1_normalMatrix_noInstance_vertex:GLSLChunk = {top: "",define: "",varDeclare: "",funcDeclare: "",funcDefine: "",body: "mat3 normalMatrix = u_normalMatrix;\n"};
22-
export const webgl1_basic_map_fragment:GLSLChunk = {top: "",define: "",varDeclare: "varying vec2 v_mapCoord0;\n",funcDeclare: "",funcDefine: "",body: "totalColor *= texture2D(u_sampler2D0, v_mapCoord0);\n"};
22+
export const webgl1_basic_map_fragment:GLSLChunk = {top: "",define: "",varDeclare: "varying vec2 v_mapCoord0;\n",funcDeclare: "",funcDefine: "",body: "totalColor *= texture2D(u_sampler2D, v_mapCoord0);\n"};
2323
export const webgl1_basic_map_vertex:GLSLChunk = {top: "",define: "",varDeclare: "varying vec2 v_mapCoord0;\n",funcDeclare: "",funcDefine: "",body: "// vec2 sourceTexCoord0 = a_texCoord * u_map0SourceRegion.zw + u_map0SourceRegion.xy;\n//\n// v_mapCoord0 = sourceTexCoord0 * u_map0RepeatRegion.zw + u_map0RepeatRegion.xy;\n\n v_mapCoord0 = a_texCoord;\n"};
2424
export const webgl1_diffuseMap_fragment:GLSLChunk = {top: "",define: "",varDeclare: "varying vec2 v_diffuseMapTexCoord;\n",funcDeclare: "",funcDefine: "vec3 getMaterialDiffuse() {\n return texture2D(u_diffuseMapSampler, v_diffuseMapTexCoord).rgb;\n }\n",body: ""};
2525
export const webgl1_diffuseMap_vertex:GLSLChunk = {top: "",define: "",varDeclare: "varying vec2 v_diffuseMapTexCoord;\n",funcDeclare: "",funcDefine: "",body: "//todo optimize(combine, reduce compute numbers)\n //todo BasicTexture extract textureMatrix\n// vec2 sourceTexCoord = a_texCoord * u_diffuseMapSourceRegion.zw + u_diffuseMapSourceRegion.xy;\n// v_diffuseMapTexCoord = sourceTexCoord * u_diffuseMapRepeatRegion.zw + u_diffuseMapRepeatRegion.xy;\n\n v_diffuseMapTexCoord = a_texCoord;\n"};
@@ -44,7 +44,7 @@ export const webgl2_common_fragment:GLSLChunk = {top: "",define: "",varDeclare:
4444
export const webgl2_common_function:GLSLChunk = {top: "",define: "",varDeclare: "",funcDeclare: "",funcDefine: "",body: ""};
4545
export const webgl2_common_vertex:GLSLChunk = {top: "",define: "",varDeclare: "",funcDeclare: "",funcDefine: "",body: ""};
4646
export const ubo_light:GLSLChunk = {top: "",define: "",varDeclare: "layout(std140) uniform LightUbo {\n/*! vec4(lightModel, 0.0, 0.0, 0.0) */\n vec4 lightModel;\n} lightUbo;\n",funcDeclare: "",funcDefine: "",body: ""};
47-
export const webgl2_basic_map_fragment:GLSLChunk = {top: "",define: "",varDeclare: "in vec2 v_mapCoord0;\n",funcDeclare: "",funcDefine: "",body: "totalColor *= texture(u_sampler2D0, v_mapCoord0);\n"};
47+
export const webgl2_basic_map_fragment:GLSLChunk = {top: "",define: "",varDeclare: "in vec2 v_mapCoord0;\n",funcDeclare: "",funcDefine: "",body: "totalColor *= texture(u_sampler2D, v_mapCoord0);\n"};
4848
export const webgl2_basic_map_vertex:GLSLChunk = {top: "",define: "",varDeclare: "out vec2 v_mapCoord0;\n",funcDeclare: "",funcDefine: "",body: "// vec2 sourceTexCoord0 = a_texCoord * u_map0SourceRegion.zw + u_map0SourceRegion.xy;\n//\n// v_mapCoord0 = sourceTexCoord0 * u_map0RepeatRegion.zw + u_map0RepeatRegion.xy;\n\n v_mapCoord0 = a_texCoord;\n"};
4949
export const gbuffer_common_fragment:GLSLChunk = {top: "",define: "",varDeclare: "in vec3 v_worldPosition;\n",funcDeclare: "",funcDefine: "",body: ""};
5050
export const gbuffer_common_vertex:GLSLChunk = {top: "",define: "",varDeclare: "out vec3 v_worldPosition;\n",funcDeclare: "",funcDefine: "",body: ""};

src/renderer/webgl1/shader/chunk/glsl/basic/map/webgl1_basic_map_fragment.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ varying vec2 v_mapCoord0;
33
@end
44

55
@body
6-
totalColor *= texture2D(u_sampler2D0, v_mapCoord0);
6+
totalColor *= texture2D(u_sampler2D, v_mapCoord0);
77
@end
88

src/renderer/webgl2/shader/chunk/glsl/basic/map/webgl2_basic_map_fragment.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ in vec2 v_mapCoord0;
33
@end
44

55
@body
6-
totalColor *= texture(u_sampler2D0, v_mapCoord0);
6+
totalColor *= texture(u_sampler2D, v_mapCoord0);
77
@end
88

src/renderer/worker/webgl1/both_file/data/shaderLib_generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export const webgl1_shaderLib_generator = {
183183
],
184184
"uniformDefine": [
185185
{
186-
"name": "u_sampler2D0",
186+
"name": "u_sampler2D",
187187
"type": "sampler2D"
188188
}
189189
]

src/renderer/worker/webgl2/both_file/data/shaderLib_generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export const webgl2_shaderLib_generator = {
505505
],
506506
"uniformDefine": [
507507
{
508-
"name": "u_sampler2D0",
508+
"name": "u_sampler2D",
509509
"type": "sampler2D"
510510
}
511511
]

test/karma.conf.webgl1.noWorker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
// 'test/unit/**/BufferWriter.js',
3535

3636
// 'test/unit/no_worker/**',
37-
'test/unit/no_worker/**/hotLoad*',
38-
'test/unit/no_worker/**/AssetDatabase*',
37+
// 'test/unit/no_worker/**/hotLoad*',
38+
// 'test/unit/no_worker/**/AssetDatabase*',
3939
// 'test/unit/no_worker/**/device*',
4040
// 'test/unit/no_worker/**/Material*',
4141
// 'test/unit/no_worker/**/vao*',
@@ -44,7 +44,7 @@
4444
// 'test/unit/no_worker/**/Scene*',
4545
// 'test/unit/no_worker/**/*MapManager*',
4646
// 'test/unit/no_worker/**/*Geometry*',
47-
// 'test/unit/no_worker/**/TextureSpec*',
47+
'test/unit/no_worker/**/TextureSpec*',
4848
// 'test/unit/no_worker/**/ColorSpec*',
4949
// 'test/unit/no_worker/**/shader*Spec*',
5050
// 'test/unit/no_worker/**/Shader*Spec*',

test/unit/no_worker/component/webgl1/geometry/GeometrySpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe("Geometry", function () {
125125
var texture = textureSystemTool.create();
126126
textureSystemTool.setSource(texture, {})
127127

128-
basicMaterialTool.addMap(mat1, texture);
128+
basicMaterialTool.setMap(mat1, texture);
129129

130130

131131
var data2 = sceneSystemTool.prepareGameObjectAndAddToScene(true, geo2);

test/unit/no_worker/renderer/texture/MapManagerSpec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ describe("MapManager", function() {
3333
sandbox.restore();
3434
});
3535

36-
// describe("addMap", function() {
36+
// describe("setMap", function() {
3737
// beforeEach(function(){
3838
//
3939
// });
4040
//
4141
// it("test add first map", function(){
42-
// basicMaterialTool.addMap(material, texture);
42+
// basicMaterialTool.setMap(material, texture);
4343
//
4444
// expect(MapManagerData.textureIndices[material.index]).toEqual(texture.index);
4545
// });
4646
// it("test add second map", function () {
4747
// var texture2 = textureSystemTool.create();
4848
//
49-
// basicMaterialTool.addMap(material, texture);
50-
// basicMaterialTool.addMap(material, texture2);
49+
// basicMaterialTool.setMap(material, texture);
50+
// basicMaterialTool.setMap(material, texture2);
5151
//
5252
// expect(MapManagerData.textureIndices[material.index]).toEqual(texture.index);
5353
// expect(MapManagerData.textureIndices[material.index + 1]).toEqual(texture2.index);
@@ -58,13 +58,13 @@ describe("MapManager", function() {
5858
// for(var i = 0; i < 16; i++){
5959
// texture = textureSystemTool.create();
6060
//
61-
// basicMaterialTool.addMap(material, texture);
61+
// basicMaterialTool.setMap(material, texture);
6262
// }
6363
//
6464
// var texture2 = textureSystemTool.create();
6565
//
6666
// expect(function () {
67-
// basicMaterialTool.addMap(material, texture2);
67+
// basicMaterialTool.setMap(material, texture2);
6868
// }).toThrow("map count shouldn't exceed max count")
6969
// });
7070
// });

test/unit/no_worker/renderer/texture/TextureSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("Texture", function () {
3333

3434
texture = textureSystemTool.create();
3535

36-
basicMaterialTool.addMap(material, texture);
36+
basicMaterialTool.setMap(material, texture);
3737
});
3838
afterEach(function () {
3939
testTool.clear(sandbox);
@@ -339,7 +339,7 @@ describe("Texture", function () {
339339

340340
beforeEach(function(){
341341
texture2 = textureSystemTool.create();
342-
basicMaterialTool.addMap(material, texture2);
342+
basicMaterialTool.setMap(material, texture2);
343343
});
344344

345345
describe("test remove from map", function() {
@@ -415,7 +415,7 @@ describe("Texture", function () {
415415
testTool.closeContractCheck();
416416

417417
texture2 = textureSystemTool.create();
418-
basicMaterialTool.addMap(material, texture2);
418+
basicMaterialTool.setMap(material, texture2);
419419

420420
glTexture1 = {t:1};
421421
glTexture2 = {t:2};

test/unit/no_worker/renderer/webgl1/render/basic/basicRenderSpec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe("basic render", function () {
178178
var texture = textureSystemTool.create();
179179
textureSystemTool.setSource(texture, {});
180180

181-
basicMaterialTool.addMap(material, texture);
181+
basicMaterialTool.setMap(material, texture);
182182
});
183183

184184
describe("send a_texCoord", function () {
@@ -221,9 +221,9 @@ describe("basic render", function () {
221221
});
222222
})
223223

224-
it("send u_sampler2D0", function () {
224+
it("send u_sampler2D", function () {
225225
var pos = 0;
226-
gl.getUniformLocation.withArgs(sinon.match.any, "u_sampler2D0").returns(pos);
226+
gl.getUniformLocation.withArgs(sinon.match.any, "u_sampler2D").returns(pos);
227227

228228
directorTool.init(state);
229229
directorTool.loopBody(state);
@@ -247,8 +247,8 @@ describe("basic render", function () {
247247
var fs = getFsSource(gl);
248248

249249
expect(glslTool.contain(fs, "varying vec2 v_mapCoord0;\n")).toBeTruthy();
250-
expect(glslTool.contain(fs, "uniform sampler2D u_sampler2D0;\n")).toBeTruthy();
251-
expect(glslTool.contain(fs, "totalColor *= texture2D(u_sampler2D0, v_mapCoord0);\n")).toBeTruthy();
250+
expect(glslTool.contain(fs, "uniform sampler2D u_sampler2D;\n")).toBeTruthy();
251+
expect(glslTool.contain(fs, "totalColor *= texture2D(u_sampler2D, v_mapCoord0);\n")).toBeTruthy();
252252
});
253253
});
254254
});

0 commit comments

Comments
 (0)