I have an app which uses SpriteKit and emitter particles (sks) which I find to be not as realistic as Scene kit's particles (scnp). So I wish to incorporate that into SKScene but I'm not sure if that is even possible. So I decided to create an SCNScene and particles(scnp). However I want to add a background image and the only 3D effect would be the particles. Can anyone help me set a background image to my SCNScene. Traditionally I would add it like this to an SKScene but I could not find any help online for the SceneKit.
let backgroundNode = SKSpriteNode(imageNamed: "backgroundImage")
backgroundNode.size = view.frame.size
backgroundNode.position = CGPointMake(view.frame.size.width/2, view.frame.height/2)
self.addChild(backgroundNode)
Thank you in advance
let scnScene = SCNScene()
scnScene.background.contents = UIImage(named: "earth.jpg")
Basically the same answer as @Kusal Shrestha, but I was able to put a gradient background using a bunch of different technologies. Still very simple and useful.
const CGFloat DIVISOR = 255.0f;
CIColor *bottomColor = [CIColor colorWithRed:(CGFloat)0xee / DIVISOR green:(CGFloat)0x78 / DIVISOR blue:(CGFloat)0x0f / DIVISOR alpha:1];
CIColor *topColor = [CIColor colorWithRed:0xff / DIVISOR green:0xfb / DIVISOR blue:0xcf / DIVISOR alpha:1];
SKTexture* textureGradient = [SKTexture textureWithVerticalGradientofSize:scnview.frame.size topColor:topColor bottomColor:bottomColor];
UIImage* uiimageGradient = [UIImage imageWithCGImage:textureGradient.CGImage];
self.background.contents = uiimageGradient;
Where "self" is a subclass of SCNScene.
This example requires the category on texture from here: https://gist.github.com/Tantas/7fc01803d6b559da48d6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With