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
Pass alphaTest as a uniform, rather than a macro. #15654
Comments
Interesting... In case of .alpha = new THREE.ThresholdNode( alphaMapNode, thresholdNode ); and |
// Mask
.alpha = new THREE.ThresholdNode( mapNode, floatNode );
// Blend
.alpha = mapNode;
// Both
.alpha = new THREE.ThresholdNode( mapNode, floatNode, mapNode );
// thrid map is blend |
do you have the source of |
I do not think I need to, I was kind of confused, it seems to have a displace map too. |
I see no problem implementing Perhaps we can change the default value of |
The screenshot is from the Shade for iOS app (https://twitter.com/_LucasRizzotto/status/1078140430036828160) which generates a JSON representation of the node graph and a Unity shader. I have both available if that's helpful. I was able to get a dissolve effect working in NodeMaterial, aside from this alphaTest question and adding a custom Noise3DNode, but haven't tried reproducing the smoke effect yet. I like the idea of defaulting to material.alpha = new NoiseNode( ... );
material.alphaTest = new Math1Node( new TimerNode(), Math1Node.SIN ); |
Hmm. Shade is quite impressive. About create new slots is not the way that I would follow only if there is no output more for it. For example three.js/examples/webgl_materials_nodes.html Lines 2144 to 2160 in e3bc361
another example would be for the developer extend the class of // ConditionalThresholdNode is extended of ThresholdNode
// its add conditional feature
var mask = new THREE.ConditionalThresholdNode( maskNode, floatNode );
mask.conditional = ">=";
material.alpha = mask; otherwise it would closely resemble the parameterized system, for example: material.alpha = maskNode;
material.alphaTest = floatNode;
material.alphaTestConditional = ">="; |
@sunag I don't think I understand... the suggested ThresholdNode would still have a float output connected to Because threejs already has an |
Really var mask = new THREE.ClipNode( maskNode, floatNode );
mask.conditional = ">=";
material.alpha = mask; instead of: material.alpha = maskNode;
material.alphaTest = floatNode;
material.alphaTestConditional = ">=";
material.alphaMode = THREE.AlphaMask;
I see a lot of usefulness in |
I think I generated this confusion because of the third argument. Sorry. material.color = new THREE.ClipNode( maskNode, floatNode, colorNode ); |
It don't see a reason for that – if we consider the default value of material.alpha = /* procedural texture, etc. */;
material.alphaTest = new Math1Node( new TimerNode(), Math1Node.SIN ); ... I would argue that we haven't added any new sockets. We've just made A weird part of material.metalness = new OperatorNode(
new ClipNode( ... ),
new FloatNode( 0.0 ),
OperatorNode.MUL
); In that case, the main effect of ClipNode has nothing to do with its output... I'm not sure I see an advantage in that, over the current In your code... var clipCode = "if ( " + testValue + " " + this.conditional + " " + thresholdValue + " ) discard;"
// clip
builder.addNodeCode( clipCode );
return this.output.build( builder, output ); ... is this order-independent enough to be safe? What guarantees that the appended
What do you mean by BypassNode? Also, I like the new example! 🎊 We should create a Noise3DNode so it doesn't need to follow UVs maybe. |
for now keep them both. remove
this follows a hierarchy, and share nodes between slots for optimization, in case of
if added only in
in case of added the same three.js/examples/js/nodes/core/Node.js Line 23 in e3bc361
It came from of this issue: It has been assigned to define
Yes, this would be wonderful. Thanks! |
I see, thanks! I'm ok with whatever API for clipping you find best, then. :) |
@donmccurdy Thank you for your effort and support in I'm still not completely satisfied with ClipNode, the problem of I thought of a third solution, a boolean slot called material.clip = new CondNode( ... ) |
it would also be material.mask = new CondNode( ... ); |
https://rawgit.com/sunag/three.js/dev-mask/examples/webgl_materials_nodes.html?e=dissolve // CondNode returns a boolean value
// show fragment only if CondNode returns true
material.mask = new THREE.CondNode(
maskNode, // mask node
new THREE.FloatNode( .1 ), // threshold
THREE.CondNode.GREATER // condition
); |
I post a PR to help the workflow, but if we see something better we will changes in sequence. 👍 |
@donmccurdy Do you support #15654 (comment)? I have hacked a proof-of-concept and it seems to work great. I have not touched node materials or GLTF import/export though. |
@WestLangley I'm fine with that change too, yes. The use cases for procedural clipping that I can think of are specific to NodeMaterial; glTF does not animate alphaTest, and I'm not aware that users have requested it for fixed-input materials. But it's a simple backward-compatible change that may save someone a recompile, so why not. :) |
@donmccurdy Well, unless there is renewed demand for it, I don't see the point, to be honest. I think I will leave the built-in materials as-is. |
Ok, let's close this since #15663 has merged and reconsider if we get more requests for it. |
A material's
.alphaTest
property is currently translated into:As a result of using a macro, the value cannot be changed or animated without recompiling. I'd like to propose that we allow animating the value, which may require an API addition to skip the conditional when it isn't needed. For example:
In the example above,
alphaMode
replaces.transparent
. Alternatively, we could use separate boolean flags like.transparent=true
and.mask=true
.Animating
alphaTest
is of limited use with fixed material inputs, but it becomes much more interesting when paired with NodeMaterial, where procedural offset, opacity, alphaTest, and emissive values can be used for effects like these:For further reading, see http://glowfishinteractive.com/dissolving-the-world-part-2/. Previous discussion in #5623.
Do we want a PR for this, and if so: (1) any preference on the API, and (2) should it affect core materials or just NodeMaterial?
/cc @sunag
The text was updated successfully, but these errors were encountered: