You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the way ambientColor is applied in phongFrag is simply adding up the calculated color values.
This is a layer application method called addition in illustration.
In illustration, however, there are many ways to apply color other than additive.
The four most commonly used are addition, multiplication, screen, and overlay. Otherwise, soft light and hard light may be used.
So I wanted to be able to apply it. This issue suggests it.
In the current situation where the only way to apply ambientColor is simply adding up, for example if the directionalLight is pure white, it will always be pure white if the ambientLight is pure white.
However, for example, if the application method is an overlay, the light and dark will be sharp when it is pure white.
Overlay is useful because the effect of approximating the applied color is easier to understand than additive.
The following image shows ambientColor applied to a gray torus using ADD and OVERLAY methods, respectively, using a feature to be implemented.
condition:
The more options you have, the more expressions you can express, so I thought it would be meaningful to implement it.
Most appropriate sub-area of p5.js?
Accessibility
Color
Core/Environment/Rendering
Data
DOM
Events
Image
IO
Math
Typography
Utilities
WebGL
Build Process
Unit Testing
Internalization
Friendly Errors
Other (specify if possible)
Feature request details
I will explain how to implement it.
First, let Renderer.GL have an integer property called ambientMode. This is used as a flag in phong.frag.
this.ambientMode=0;// default is 0 : ADD
The correspondence with blendMode is 0: ADD, 1: SCREEN, 2: MULTIPLY, 3: OVERLAY, 4: SOFT_LIGHT, 5: HARD_LIGHT.
Then have a function called ambientMode() (kind of like textureMode()). Change the value of ambientMode by substituting the above blending constant into the argument of this. For example, if you want the application method to be OVERLAY, use ambientMode(OVERLAY).
In this function, we convert the blending constant to an integer case by case. Here is an overview of the functions:
p5.prototype.ambientMode=function(mode){this._assert3d('ambientMode');p5._validateParameters('ambientMode',arguments);if(mode===ADD){this._renderer.ambientMode=0;}elseif(mode===SCREEN){this._renderer.ambientMode=1;}elseif(mode===MULTIPLY){this._renderer.ambientMode=2;}elseif(mode===OVERLAY){this._renderer.ambientMode=3;}elseif(mode===SOFT_LIGHT){this._renderer.ambientMode=4;}elseif(mode===HARD_LIGHT){this._renderer.ambientMode=5;}else{console.warn('There are only 6 blendModes that can be used to apply ambientColor: ADD, SCREEN, MULTIPLY, OVERLAY, SOFT_LIGHT, HARD_LIGHT.');}returnthis;};
Then pass this value to uAmbientColor in _setFillUniforms().
Let me explain another motivation. Watch the video below. noise&rotate
2023-05-01.04-06-02.mp4
As you can see, the result of applying lights() is much lighter in 1.6.0 than in 1.4.2. This is due to a change in how lighting is applied in 1.5.0.
This is not 128, 128 like lights(), but 255, 255 are set to MAX, and the result of applying with OVERLAY is shown here.
2023-05-01.04-12-56.mp4
In this way, the light and dark became clear and different appearance.
Appearance is a matter of individual subjectivity, so there is no correct answer. So this specification change does not change the default at all. AmbientMode defaults to ADD, so if you don't do anything, it will remain the same and backward compatibility will be maintained. What I want to do is increase the options in drawing.
I would like to add a simple benchmark test etc. later.
Increasing Access
Currently, the way ambientColor is applied in phongFrag is simply adding up the calculated color values.
This is a layer application method called addition in illustration.
In illustration, however, there are many ways to apply color other than additive.
The four most commonly used are addition, multiplication, screen, and overlay. Otherwise, soft light and hard light may be used.
So I wanted to be able to apply it. This issue suggests it.
In the current situation where the only way to apply ambientColor is simply adding up, for example if the directionalLight is pure white, it will always be pure white if the ambientLight is pure white.
However, for example, if the application method is an overlay, the light and dark will be sharp when it is pure white.
Overlay is useful because the effect of approximating the applied color is easier to understand than additive.
The following image shows ambientColor applied to a gray torus using ADD and OVERLAY methods, respectively, using a feature to be implemented.
condition:
The more options you have, the more expressions you can express, so I thought it would be meaningful to implement it.
Most appropriate sub-area of p5.js?
Feature request details
I will explain how to implement it.
First, let Renderer.GL have an integer property called ambientMode. This is used as a flag in phong.frag.
The correspondence with blendMode is 0: ADD, 1: SCREEN, 2: MULTIPLY, 3: OVERLAY, 4: SOFT_LIGHT, 5: HARD_LIGHT.
Then have a function called ambientMode() (kind of like textureMode()). Change the value of ambientMode by substituting the above blending constant into the argument of this. For example, if you want the application method to be OVERLAY, use ambientMode(OVERLAY).
In this function, we convert the blending constant to an integer case by case. Here is an overview of the functions:
Then pass this value to uAmbientColor in _setFillUniforms().
Receive this in phong.frag and use it in the ambientColor application part. Rewrite it like this:
before:
after:
overlay and softLight are calculated by creating separate functions.
That's all there is to the implementation.
Let me explain another motivation. Watch the video below.
noise&rotate
2023-05-01.04-06-02.mp4
As you can see, the result of applying lights() is much lighter in 1.6.0 than in 1.4.2. This is due to a change in how lighting is applied in 1.5.0.
This is not 128, 128 like lights(), but 255, 255 are set to MAX, and the result of applying with OVERLAY is shown here.
2023-05-01.04-12-56.mp4
In this way, the light and dark became clear and different appearance.
Appearance is a matter of individual subjectivity, so there is no correct answer. So this specification change does not change the default at all. AmbientMode defaults to ADD, so if you don't do anything, it will remain the same and backward compatibility will be maintained. What I want to do is increase the options in drawing.
I would like to add a simple benchmark test etc. later.