What you are looking for is called Barrel Distrortion.
There are several ways to do this, they all use GLSL shaders.
You can use the classic OpenGL code, for example this example for Occulus Rift (you need to change the shader a bit), or my personal favorite: SCNTechnique .
Create a technique containing the trunk fragment shader (.fsh) and set the draw parameter to DRAW_QUAD . Then just apply the technique to your camera.
Here you can find an example of the Barrel Distortion shader: http://www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/2/
EDIT: here is a sample code:
barrel.json (this should come with scnassets)
{ "passes" : { "barrel" : { "outputs" : { "color" : "COLOR" }, "inputs" : { "colorSampler" : "COLOR", "noiseSampler" : "noiseSymbol", "a_position" : "a_position-symbol" }, "program" : "art.scnassets/barrel", "draw" : "DRAW_QUAD" } }, "sequence" : [ "barrel" ], "symbols" : { "a_position-symbol" : { "semantic" : "vertex" }, "noiseSymbol" : { "image" : "noise.png", "type" : "sampler2D" }, "barrelPower" : { "type" : "float" } } }
barrel.vsh
attribute vec4 a_position; varying vec2 uv; void main() { gl_Position = a_position; uv = a_position.xy; }
barrel.fsh
// Adapted from : // http://www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/2/ uniform sampler2D colorSampler; const float PI = 3.1415926535; uniform float barrelPower; varying vec2 uv; vec2 Distort(vec2 p) { float theta = atan(py, px); float radius = length(p); radius = pow(radius, barrelPower); px = radius * cos(theta); py = radius * sin(theta); return 0.5 * (p + 1.0); } void main() { vec2 rg = 2.0 * uv.xy - 1.0; vec2 uv2; float d = length(xy); if (d < 1.0){ uv2 = Distort(xy); }else{ uv2 = uv.xy; } gl_FragColor = texture2D(colorSampler, uv2); }
something.m
NSURL *url = [[NSBundle mainBundle] URLForResource:@"art.scnassets/barrel" withExtension:@"json"]; NSDictionary *tecDic = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL: url] options:nil error:nil]; SCNTechnique* technique = [SCNTechnique techniqueWithDictionary:tecDic]; [technique setValue: [NSNumber numberWithFloat:0.5] forKey:@"barrelPower"]; cameraNode.technique = technique;