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

Nodes: fix atan2 #24464

Merged
merged 1 commit into from
Aug 9, 2022
Merged

Nodes: fix atan2 #24464

merged 1 commit into from
Aug 9, 2022

Conversation

miko3k
Copy link
Contributor

@miko3k miko3k commented Aug 7, 2022

Description

I noticed that atan2 doesn't work in WebGL, I am getting following error:

FRAGMENT
ERROR: 0:1199: 'atan2' : no matching overloaded function found

Example:

import { AttributeNode, ShaderNode, nodeObject, atan2, MeshStandardNodeMaterial } from "three/examples/jsm/nodes/Nodes";

export const SomeShaderNode = new ShaderNode( ( {uv} ) => {
    return atan2(uv.x, uv.y)
} );

const material = new MeshStandardNodeMaterial();
material.colorNode = SomeShaderNode.call({uv: new AttributeNode('uv')})

This is an attempt to correct this error.

@sunag
Copy link
Collaborator

sunag commented Aug 7, 2022

I think we can follow a style similar to WebGPUNodeBuilder?

const glslMethods = {
	atan2: 'atan'
};

...

getMethod( method ) {

	return glslMethods[ method ] || method;

}

@miko3k
Copy link
Contributor Author

miko3k commented Aug 7, 2022

Thanks for feedback. I updated the PR.

@sunag sunag merged commit 38273fb into mrdoob:dev Aug 9, 2022
@sunag
Copy link
Collaborator

sunag commented Aug 9, 2022

Thanks for the contribution!

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants