SceneKit - How to use different blending modes - for example. additive mix?

How can I use additive blending in SceneKit?

I would be nice if I had to use a shader, but I hope that there will be an easier way, since even SpriteKit supports blending modes.

EDIT: since this has been noted as a duplicate: I'm not sure if solving another question really speaks of additive mixing. I don't have the ability to work yet, so I ask if anyone can really make additive mixing work.

EDIT 2: I really tried the “solution” in another AED now, and it is not working. My shapes (SCNShape) are solid pink, and there is no additive blending at all.

EDIT 3: After I tried and played more, I had to work a little, but this is not a suitable additive mixture (for now?). Colors get definitely brighter, but they don't behave exactly like adding blends. If someone has an addition to this / knows how to make it function properly, I would be glad.

-(void) additiveTest {
{
SCNNode *node1 = [self createCircleWithRadius: 50.0 atPos:SCNVector3Make(100, 100, 0) withColor: [UIColor colorWithRed:0.5 green:0.0 blue:0.0 alpha: 0.5]];
[_baseNode addChildNode: node1];


SCNNode *node2 = [self createCircleWithRadius: 50.0 atPos:SCNVector3Make(125, 100, -1) withColor: [UIColor colorWithRed:0.5 green: 0.0 blue: 0.0 alpha: 0.5]];
[_baseNode addChildNode: node2];


NSMutableDictionary *dict = [NSMutableDictionary dictionary];
dict[SCNShaderModifierEntryPointFragment] = @"#pragma transparent\n#pragma body\n_output.color.a = 0.0;";
//    node2.geometry.firstMaterial.shaderModifiers = dict;
node1.geometry.firstMaterial.shaderModifiers = dict;
}

{

    SCNNode *node1 = [self createCircleWithRadius: 50.0 atPos:SCNVector3Make(100, 300, 0) withColor: [UIColor colorWithRed:0.5 green:0.0 blue:0.0 alpha: 0.5]];
    [_baseNode addChildNode: node1];

    SCNNode *node2 = [self createCircleWithRadius: 50.0 atPos:SCNVector3Make(125, 300, -1) withColor: [UIColor colorWithRed:0.5 green: 0.0 blue: 0.0 alpha: 0.5]];
    [_baseNode addChildNode: node2];


}
}

This is the result, in the bottom "line" the left side of the circle is lighter than I would expect (if the background is black), or am I mistaken?

enter image description here

+1
source share

All Articles