How can one use additive blending in SceneKit?
I'd be okay if I have to use a shader but I hope there's an easier way, as even SpriteKit supports blend modes.
EDIT: As this was marked as a duplicate: I'm not sure if the solution to the other question is really talking about additive blending. I haven't got it to work yet, so I'm asking if somebody is actually able to get additive blending to work.
EDIT 2: I actually tried the "solution"in the other thead now and it doesn't work. My shapes (SCNShape) get solid pink then and there's no additive blending at all.
EDIT 3: After trying and fiddling more, I got it somewhat to work, but it's not a proper additive blend (yet?). The colors get definitely brighter but they don't behave exactly like addtive blending. If anybody has an addition to this / knows how to make it function properly, I'd 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 lower "row", the left side of the circle is lighter than I'd expect it to be (as the background is black), or am I wrong?