Skip to content

Commit 98d8394

Browse files
authored
Merge pull request #7288 from davepagurek/rename-shader-hooks
Rename default shader methods to have a base* prefix
2 parents 8f46337 + 5b1b1a7 commit 98d8394

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

src/webgl/material.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ p5.prototype.shader = function (s) {
887887
* Get the default shader used with lights, materials,
888888
* and textures.
889889
*
890-
* You can call <a href="#/p5.Shader/modify">`materialShader().modify()`</a>
890+
* You can call <a href="#/p5.Shader/modify">`baseMaterialShader().modify()`</a>
891891
* and change any of the following hooks:
892892
*
893893
* <table>
@@ -1032,10 +1032,10 @@ p5.prototype.shader = function (s) {
10321032
* Most of the time, you will need to write your hooks in GLSL ES version 300. If you
10331033
* are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.
10341034
*
1035-
* Call `materialShader().inspectHooks()` to see all the possible hooks and
1035+
* Call `baseMaterialShader().inspectHooks()` to see all the possible hooks and
10361036
* their default implementations.
10371037
*
1038-
* @method materialShader
1038+
* @method baseMaterialShader
10391039
* @beta
10401040
* @returns {p5.Shader} The material shader
10411041
*
@@ -1046,7 +1046,7 @@ p5.prototype.shader = function (s) {
10461046
*
10471047
* function setup() {
10481048
* createCanvas(200, 200, WEBGL);
1049-
* myShader = materialShader().modify({
1049+
* myShader = baseMaterialShader().modify({
10501050
* uniforms: {
10511051
* 'float time': () => millis()
10521052
* },
@@ -1075,7 +1075,7 @@ p5.prototype.shader = function (s) {
10751075
*
10761076
* function setup() {
10771077
* createCanvas(200, 200, WEBGL);
1078-
* myShader = materialShader().modify({
1078+
* myShader = baseMaterialShader().modify({
10791079
* declarations: 'vec3 myNormal;',
10801080
* 'Inputs getPixelInputs': `(Inputs inputs) {
10811081
* myNormal = inputs.normal;
@@ -1115,7 +1115,7 @@ p5.prototype.shader = function (s) {
11151115
*
11161116
* function setup() {
11171117
* createCanvas(200, 200, WEBGL);
1118-
* myShader = materialShader().modify({
1118+
* myShader = baseMaterialShader().modify({
11191119
* 'Inputs getPixelInputs': `(Inputs inputs) {
11201120
* float factor =
11211121
* sin(
@@ -1150,7 +1150,7 @@ p5.prototype.shader = function (s) {
11501150
*
11511151
* function setup() {
11521152
* createCanvas(200, 200, WEBGL);
1153-
* myShader = materialShader().modify({
1153+
* myShader = baseMaterialShader().modify({
11541154
* 'Inputs getPixelInputs': `(Inputs inputs) {
11551155
* vec3 newNormal = inputs.normal;
11561156
* // Simple bump mapping: adjust the normal based on position
@@ -1189,15 +1189,15 @@ p5.prototype.shader = function (s) {
11891189
* </code>
11901190
* </div>
11911191
*/
1192-
p5.prototype.materialShader = function() {
1193-
this._assert3d('materialShader');
1194-
return this._renderer.materialShader();
1192+
p5.prototype.baseMaterialShader = function() {
1193+
this._assert3d('baseMaterialShader');
1194+
return this._renderer.baseMaterialShader();
11951195
};
11961196

11971197
/**
11981198
* Get the shader used by <a href="#/p5/normalMaterial">`normalMaterial()`</a>.
11991199
*
1200-
* You can call <a href="#/p5.Shader/modify">`normalShader().modify()`</a>
1200+
* You can call <a href="#/p5.Shader/modify">`baseNormalShader().modify()`</a>
12011201
* and change any of the following hooks:
12021202
*
12031203
* Hook | Description
@@ -1217,10 +1217,10 @@ p5.prototype.materialShader = function() {
12171217
* Most of the time, you will need to write your hooks in GLSL ES version 300. If you
12181218
* are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.
12191219
*
1220-
* Call `normalShader().inspectHooks()` to see all the possible hooks and
1220+
* Call `baseNormalShader().inspectHooks()` to see all the possible hooks and
12211221
* their default implementations.
12221222
*
1223-
* @method normalShader
1223+
* @method baseNormalShader
12241224
* @beta
12251225
* @returns {p5.Shader} The `normalMaterial` shader
12261226
*
@@ -1231,7 +1231,7 @@ p5.prototype.materialShader = function() {
12311231
*
12321232
* function setup() {
12331233
* createCanvas(200, 200, WEBGL);
1234-
* myShader = normalShader().modify({
1234+
* myShader = baseNormalShader().modify({
12351235
* uniforms: {
12361236
* 'float time': () => millis()
12371237
* },
@@ -1258,7 +1258,7 @@ p5.prototype.materialShader = function() {
12581258
*
12591259
* function setup() {
12601260
* createCanvas(200, 200, WEBGL);
1261-
* myShader = normalShader().modify({
1261+
* myShader = baseNormalShader().modify({
12621262
* 'vec3 getWorldNormal': '(vec3 normal) { return abs(normal); }',
12631263
* 'vec4 getFinalColor': `(vec4 color) {
12641264
* // Map the r, g, and b values of the old normal to new colors
@@ -1284,15 +1284,15 @@ p5.prototype.materialShader = function() {
12841284
* </code>
12851285
* </div>
12861286
*/
1287-
p5.prototype.normalShader = function() {
1288-
this._assert3d('materialShader');
1289-
return this._renderer.normalShader();
1287+
p5.prototype.baseNormalShader = function() {
1288+
this._assert3d('baseNormalShader');
1289+
return this._renderer.baseNormalShader();
12901290
};
12911291

12921292
/**
12931293
* Get the shader used when no lights or materials are applied.
12941294
*
1295-
* You can call <a href="#/p5.Shader/modify">`colorShader().modify()`</a>
1295+
* You can call <a href="#/p5.Shader/modify">`baseColorShader().modify()`</a>
12961296
* and change any of the following hooks:
12971297
*
12981298
* Hook | Description
@@ -1312,10 +1312,10 @@ p5.prototype.normalShader = function() {
13121312
* Most of the time, you will need to write your hooks in GLSL ES version 300. If you
13131313
* are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.
13141314
*
1315-
* Call `colorShader().inspectHooks()` to see all the possible hooks and
1315+
* Call `baseColorShader().inspectHooks()` to see all the possible hooks and
13161316
* their default implementations.
13171317
*
1318-
* @method colorShader
1318+
* @method baseColorShader
13191319
* @beta
13201320
* @returns {p5.Shader} The color shader
13211321
*
@@ -1326,7 +1326,7 @@ p5.prototype.normalShader = function() {
13261326
*
13271327
* function setup() {
13281328
* createCanvas(200, 200, WEBGL);
1329-
* myShader = colorShader().modify({
1329+
* myShader = baseColorShader().modify({
13301330
* uniforms: {
13311331
* 'float time': () => millis()
13321332
* },
@@ -1347,15 +1347,15 @@ p5.prototype.normalShader = function() {
13471347
* </code>
13481348
* </div>
13491349
*/
1350-
p5.prototype.colorShader = function() {
1351-
this._assert3d('colorShader');
1352-
return this._renderer.colorShader();
1350+
p5.prototype.baseColorShader = function() {
1351+
this._assert3d('baseColorShader');
1352+
return this._renderer.baseColorShader();
13531353
};
13541354

13551355
/**
13561356
* Get the shader used when drawing the strokes of shapes.
13571357
*
1358-
* You can call <a href="#/p5.Shader/modify">`strokeShader().modify()`</a>
1358+
* You can call <a href="#/p5.Shader/modify">`baseStrokeShader().modify()`</a>
13591359
* and change any of the following hooks:
13601360
*
13611361
* <table>
@@ -1487,10 +1487,10 @@ p5.prototype.colorShader = function() {
14871487
* Most of the time, you will need to write your hooks in GLSL ES version 300. If you
14881488
* are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.
14891489
*
1490-
* Call `strokeShader().inspectHooks()` to see all the possible hooks and
1490+
* Call `baseStrokeShader().inspectHooks()` to see all the possible hooks and
14911491
* their default implementations.
14921492
*
1493-
* @method strokeShader
1493+
* @method baseStrokeShader
14941494
* @beta
14951495
* @returns {p5.Shader} The stroke shader
14961496
*
@@ -1501,7 +1501,7 @@ p5.prototype.colorShader = function() {
15011501
*
15021502
* function setup() {
15031503
* createCanvas(200, 200, WEBGL);
1504-
* myShader = strokeShader().modify({
1504+
* myShader = baseStrokeShader().modify({
15051505
* 'Inputs getPixelInputs': `(Inputs inputs) {
15061506
* float opacity = 1.0 - smoothstep(
15071507
* 0.0,
@@ -1535,7 +1535,7 @@ p5.prototype.colorShader = function() {
15351535
*
15361536
* function setup() {
15371537
* createCanvas(200, 200, WEBGL);
1538-
* myShader = strokeShader().modify({
1538+
* myShader = baseStrokeShader().modify({
15391539
* uniforms: {
15401540
* 'float time': () => millis()
15411541
* },
@@ -1581,7 +1581,7 @@ p5.prototype.colorShader = function() {
15811581
*
15821582
* function setup() {
15831583
* createCanvas(200, 200, WEBGL);
1584-
* myShader = strokeShader().modify({
1584+
* myShader = baseStrokeShader().modify({
15851585
* 'float random': `(vec2 p) {
15861586
* vec3 p3 = fract(vec3(p.xyx) * .1031);
15871587
* p3 += dot(p3, p3.yzx + 33.33);
@@ -1620,9 +1620,9 @@ p5.prototype.colorShader = function() {
16201620
* </code>
16211621
* </div>
16221622
*/
1623-
p5.prototype.strokeShader = function() {
1624-
this._assert3d('strokeShader');
1625-
return this._renderer.strokeShader();
1623+
p5.prototype.baseStrokeShader = function() {
1624+
this._assert3d('baseStrokeShader');
1625+
return this._renderer.baseStrokeShader();
16261626
};
16271627

16281628
/**

src/webgl/p5.RendererGL.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
17981798
return this._getImmediateLineShader();
17991799
}
18001800

1801-
materialShader() {
1801+
baseMaterialShader() {
18021802
if (!this._pInst._glAttributes.perPixelLighting) {
18031803
throw new Error(
18041804
'The material shader does not support hooks without perPixelLighting. Try turning it back on.'
@@ -1872,7 +1872,7 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
18721872
return this._defaultImmediateModeShader;
18731873
}
18741874

1875-
normalShader() {
1875+
baseNormalShader() {
18761876
return this._getNormalShader();
18771877
}
18781878

@@ -1907,7 +1907,7 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
19071907
return this._defaultNormalShader;
19081908
}
19091909

1910-
colorShader() {
1910+
baseColorShader() {
19111911
return this._getColorShader();
19121912
}
19131913

@@ -1998,7 +1998,7 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
19981998
return this._defaultPointShader;
19991999
}
20002000

2001-
strokeShader() {
2001+
baseStrokeShader() {
20022002
return this._getLineShader();
20032003
}
20042004

@@ -2206,15 +2206,15 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
22062206
return new p5.Framebuffer(this, options);
22072207
}
22082208

2209-
_setStrokeUniforms(strokeShader) {
2210-
strokeShader.bindShader();
2209+
_setStrokeUniforms(baseStrokeShader) {
2210+
baseStrokeShader.bindShader();
22112211

22122212
// set the uniform values
2213-
strokeShader.setUniform('uUseLineColor', this._useLineColor);
2214-
strokeShader.setUniform('uMaterialColor', this.curStrokeColor);
2215-
strokeShader.setUniform('uStrokeWeight', this.curStrokeWeight);
2216-
strokeShader.setUniform('uStrokeCap', STROKE_CAP_ENUM[this.curStrokeCap]);
2217-
strokeShader.setUniform('uStrokeJoin', STROKE_JOIN_ENUM[this.curStrokeJoin]);
2213+
baseStrokeShader.setUniform('uUseLineColor', this._useLineColor);
2214+
baseStrokeShader.setUniform('uMaterialColor', this.curStrokeColor);
2215+
baseStrokeShader.setUniform('uStrokeWeight', this.curStrokeWeight);
2216+
baseStrokeShader.setUniform('uStrokeCap', STROKE_CAP_ENUM[this.curStrokeCap]);
2217+
baseStrokeShader.setUniform('uStrokeJoin', STROKE_JOIN_ENUM[this.curStrokeJoin]);
22182218
}
22192219

22202220
_setFillUniforms(fillShader) {

src/webgl/p5.Shader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ p5.Shader = class {
269269
* For example, this shader will produce the following output:
270270
*
271271
* ```js
272-
* myShader = materialShader().modify({
272+
* myShader = baseMaterialShader().modify({
273273
* declarations: 'uniform float time;',
274274
* 'vec3 getWorldPosition': `(vec3 pos) {
275275
* pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
@@ -381,7 +381,7 @@ p5.Shader = class {
381381
*
382382
* function setup() {
383383
* createCanvas(200, 200, WEBGL);
384-
* myShader = materialShader().modify({
384+
* myShader = baseMaterialShader().modify({
385385
* uniforms: {
386386
* 'float time': () => millis()
387387
* },
@@ -410,7 +410,7 @@ p5.Shader = class {
410410
*
411411
* function setup() {
412412
* createCanvas(200, 200, WEBGL);
413-
* myShader = materialShader().modify({
413+
* myShader = baseMaterialShader().modify({
414414
* // Manually specifying a uniform
415415
* declarations: 'uniform float time;',
416416
* 'vec3 getWorldPosition': `(vec3 pos) {

0 commit comments

Comments
 (0)