Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColorAdjustmentNode: Fix hue code #27197

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions examples/jsm/nodes/display/ColorAdjustmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import TempNode from '../core/TempNode.js';
import { dot, mix } from '../math/MathNode.js';
import { add } from '../math/OperatorNode.js';
import { addNodeClass } from '../core/Node.js';
import { addNodeElement, tslFn, nodeProxy, float, vec3, mat3 } from '../shadernode/ShaderNode.js';
import { addNodeElement, tslFn, nodeProxy, float, vec3 } from '../shadernode/ShaderNode.js';

const saturationNode = tslFn( ( { color, adjustment } ) => {

Expand All @@ -23,15 +23,11 @@ const vibranceNode = tslFn( ( { color, adjustment } ) => {

const hueNode = tslFn( ( { color, adjustment } ) => {

const RGBtoYIQ = mat3( 0.299, 0.587, 0.114, 0.595716, - 0.274453, - 0.321263, 0.211456, - 0.522591, 0.311135 );
const YIQtoRGB = mat3( 1.0, 0.9563, 0.6210, 1.0, - 0.2721, - 0.6474, 1.0, - 1.107, 1.7046 );
const k = vec3( 0.57735, 0.57735, 0.57735 );

const yiq = RGBtoYIQ.mul( color );
const cosAngle = adjustment.cos();

const hue = yiq.z.atan2( yiq.y ).add( adjustment );
const chroma = yiq.yz.length();

return YIQtoRGB.mul( vec3( yiq.x, chroma.mul( hue.cos() ), chroma.mul( hue.sin() ) ) );
return vec3( color.rgb.mul( cosAngle ).add( k.cross( color.rgb ).mul( adjustment.sin() ).add( k.mul( dot( k, color.rgb ).mul( cosAngle.oneMinus() ) ) ) ) );

} );

Expand Down
12 changes: 4 additions & 8 deletions examples/jsm/nodes/lighting/EnvironmentNode.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import LightingNode from './LightingNode.js';
import { cache } from '../core/CacheNode.js';
import { context } from '../core/ContextNode.js';
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
import { equirectUV } from '../utils/EquirectUVNode.js';
import { specularMIPLevel } from '../utils/SpecularMIPLevelNode.js';
import { cameraViewMatrix } from '../accessors/CameraNode.js';
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/NormalNode.js';
import { positionViewDirection } from '../accessors/PositionNode.js';
import { addNodeClass } from '../core/Node.js';
import { float, vec2 } from '../shadernode/ShaderNode.js';
import { vec2 } from '../shadernode/ShaderNode.js';
import { cubeTexture } from '../accessors/CubeTextureNode.js';
import { reference } from '../accessors/ReferenceNode.js';

Expand Down Expand Up @@ -166,14 +167,9 @@ const createIrradianceContext = ( normalWorldNode ) => {
return node;

},
getTextureLevel: () => {

return float( 1 );

},
getTextureLevelAlgorithm: ( textureNode, levelNode ) => {
getTextureLevel: ( textureNode ) => {

return specularMIPLevel( textureNode, levelNode );
return maxMipLevel( textureNode );

}
};
Expand Down