Why does my scene camera only show black screen when I use SCNTechnique?2019 Community Moderator ElectionFish Eye Wide-angle with a Scene Kit Camera: Possible?camera UIImagePickerController shows black screenXcode 6: Keyboard does not show up in simulatorSimple SceneKit scene shows black screen instead of SCNPlaneHow to use multiple cameras for the same scene in Scene KitSceneKit camera shows extra space when it should notCamera screen showing only blank black imageScenekit rotate camera around a sceneCamera screen showing blank blackCamera shows Black Screen when using SFSafariViewControllerARKit - Camera stutters when adding a 3D model to the scene
Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?
How to deal with a cynical class?
If curse and magic is two sides of the same coin, why the former is forbidden?
What should tie a collection of short-stories together?
What's the meaning of “spike” in the context of “adrenaline spike”?
A link redirect to http instead of https: how critical is it?
How to terminate ping <dest> &
how to write formula in word in latex
If I can solve Sudoku can I solve Travelling Salesman Problem(TSP)? If yes, how?
How to write cleanly even if my character uses expletive language?
Sailing the cryptic seas
What are substitutions for coconut in curry?
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
The difference between「N分で」and「後N分で」
How can you use ICE tables to solve multiple coupled equilibria?
Have researchers managed to "reverse time"? If so, what does that mean for physics?
Are there verbs that are neither telic, or atelic?
Opacity of an object in 2.8
Do I need life insurance if I can cover my own funeral costs?
What approach do we need to follow for projects without a test environment?
How to read the value of this capacitor?
What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?
Who is flying the vertibirds?
What options are left, if Britain cannot decide?
Why does my scene camera only show black screen when I use SCNTechnique?
2019 Community Moderator ElectionFish Eye Wide-angle with a Scene Kit Camera: Possible?camera UIImagePickerController shows black screenXcode 6: Keyboard does not show up in simulatorSimple SceneKit scene shows black screen instead of SCNPlaneHow to use multiple cameras for the same scene in Scene KitSceneKit camera shows extra space when it should notCamera screen showing only blank black imageScenekit rotate camera around a sceneCamera screen showing blank blackCamera shows Black Screen when using SFSafariViewControllerARKit - Camera stutters when adding a 3D model to the scene
So I'm using SceneKit with iOS 12 (Swift 4.2), and I want to add a twirl/bump distortion to the camera. I found something similar here (Fish Eye Wide-angle with a Scene Kit Camera: Possible?) that supposedly creates a barrel distortion. But when I tried adding it to my project the scene just turns black and I get an error in the console
2019-03-07 13:35:14.982232+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.064859+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.097517+0000 TestingSCN[551:66270] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.118445+0000 TestingSCN[551:66270] [SceneKit] Error: can not render without programs, using default
Now the method is basically using a JSON dictionary file to define a technique and GLSL vertex and fragment shader files. Then in my main swift file, I add that technique to the camera. This is the code I used:
barrel.json (located in art.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.fsh
uniform sampler2D colorSampler;
const float PI = 3.1415926535;
uniform float barrelPower;
varying vec2 uv;
vec2 Distort(vec2 p)
float theta = atan(p.y, p.x);
float radius = length(p);
radius = pow(radius, barrelPower);
p.x = radius * cos(theta);
p.y = 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);
barrel.vsh
attribute vec4 a_position;
varying vec2 uv;
void main()
gl_Position = a_position;
uv = a_position.xy;
GameViewController.swift (in viewDidLoad)
let url: URL = Bundle.main.url(forResource: "art.scnassets/barrel", withExtension: "json")!
do
let jsonData = try Data(contentsOf: url)
let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options:JSONSerialization.ReadingOptions(rawValue: 0))
guard let dictionary = jsonObject as? Dictionary<String, Any> else
print("Not a Dictionary")
return
var technique: SCNTechnique? = nil
technique = SCNTechnique(dictionary: dictionary)
technique?.setValue(NSNumber(value: 0.5), forKey: "barrelPower")
cameraNode.camera?.technique = technique
catch let error as NSError
print("Found an error - (error)")
I'm not really an expert in shaders, and I know that it's probably better to write an SCNProgram or something but I have not clue where to even begin with that.
Any help is appreciated :)
ios swift shader scenekit scntechnique
add a comment |
So I'm using SceneKit with iOS 12 (Swift 4.2), and I want to add a twirl/bump distortion to the camera. I found something similar here (Fish Eye Wide-angle with a Scene Kit Camera: Possible?) that supposedly creates a barrel distortion. But when I tried adding it to my project the scene just turns black and I get an error in the console
2019-03-07 13:35:14.982232+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.064859+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.097517+0000 TestingSCN[551:66270] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.118445+0000 TestingSCN[551:66270] [SceneKit] Error: can not render without programs, using default
Now the method is basically using a JSON dictionary file to define a technique and GLSL vertex and fragment shader files. Then in my main swift file, I add that technique to the camera. This is the code I used:
barrel.json (located in art.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.fsh
uniform sampler2D colorSampler;
const float PI = 3.1415926535;
uniform float barrelPower;
varying vec2 uv;
vec2 Distort(vec2 p)
float theta = atan(p.y, p.x);
float radius = length(p);
radius = pow(radius, barrelPower);
p.x = radius * cos(theta);
p.y = 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);
barrel.vsh
attribute vec4 a_position;
varying vec2 uv;
void main()
gl_Position = a_position;
uv = a_position.xy;
GameViewController.swift (in viewDidLoad)
let url: URL = Bundle.main.url(forResource: "art.scnassets/barrel", withExtension: "json")!
do
let jsonData = try Data(contentsOf: url)
let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options:JSONSerialization.ReadingOptions(rawValue: 0))
guard let dictionary = jsonObject as? Dictionary<String, Any> else
print("Not a Dictionary")
return
var technique: SCNTechnique? = nil
technique = SCNTechnique(dictionary: dictionary)
technique?.setValue(NSNumber(value: 0.5), forKey: "barrelPower")
cameraNode.camera?.technique = technique
catch let error as NSError
print("Found an error - (error)")
I'm not really an expert in shaders, and I know that it's probably better to write an SCNProgram or something but I have not clue where to even begin with that.
Any help is appreciated :)
ios swift shader scenekit scntechnique
add a comment |
So I'm using SceneKit with iOS 12 (Swift 4.2), and I want to add a twirl/bump distortion to the camera. I found something similar here (Fish Eye Wide-angle with a Scene Kit Camera: Possible?) that supposedly creates a barrel distortion. But when I tried adding it to my project the scene just turns black and I get an error in the console
2019-03-07 13:35:14.982232+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.064859+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.097517+0000 TestingSCN[551:66270] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.118445+0000 TestingSCN[551:66270] [SceneKit] Error: can not render without programs, using default
Now the method is basically using a JSON dictionary file to define a technique and GLSL vertex and fragment shader files. Then in my main swift file, I add that technique to the camera. This is the code I used:
barrel.json (located in art.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.fsh
uniform sampler2D colorSampler;
const float PI = 3.1415926535;
uniform float barrelPower;
varying vec2 uv;
vec2 Distort(vec2 p)
float theta = atan(p.y, p.x);
float radius = length(p);
radius = pow(radius, barrelPower);
p.x = radius * cos(theta);
p.y = 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);
barrel.vsh
attribute vec4 a_position;
varying vec2 uv;
void main()
gl_Position = a_position;
uv = a_position.xy;
GameViewController.swift (in viewDidLoad)
let url: URL = Bundle.main.url(forResource: "art.scnassets/barrel", withExtension: "json")!
do
let jsonData = try Data(contentsOf: url)
let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options:JSONSerialization.ReadingOptions(rawValue: 0))
guard let dictionary = jsonObject as? Dictionary<String, Any> else
print("Not a Dictionary")
return
var technique: SCNTechnique? = nil
technique = SCNTechnique(dictionary: dictionary)
technique?.setValue(NSNumber(value: 0.5), forKey: "barrelPower")
cameraNode.camera?.technique = technique
catch let error as NSError
print("Found an error - (error)")
I'm not really an expert in shaders, and I know that it's probably better to write an SCNProgram or something but I have not clue where to even begin with that.
Any help is appreciated :)
ios swift shader scenekit scntechnique
So I'm using SceneKit with iOS 12 (Swift 4.2), and I want to add a twirl/bump distortion to the camera. I found something similar here (Fish Eye Wide-angle with a Scene Kit Camera: Possible?) that supposedly creates a barrel distortion. But when I tried adding it to my project the scene just turns black and I get an error in the console
2019-03-07 13:35:14.982232+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.064859+0000 TestingSCN[551:66202] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.097517+0000 TestingSCN[551:66270] [framework] CUIThemeStore: No theme registered with id=0
2019-03-07 13:35:15.118445+0000 TestingSCN[551:66270] [SceneKit] Error: can not render without programs, using default
Now the method is basically using a JSON dictionary file to define a technique and GLSL vertex and fragment shader files. Then in my main swift file, I add that technique to the camera. This is the code I used:
barrel.json (located in art.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.fsh
uniform sampler2D colorSampler;
const float PI = 3.1415926535;
uniform float barrelPower;
varying vec2 uv;
vec2 Distort(vec2 p)
float theta = atan(p.y, p.x);
float radius = length(p);
radius = pow(radius, barrelPower);
p.x = radius * cos(theta);
p.y = 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);
barrel.vsh
attribute vec4 a_position;
varying vec2 uv;
void main()
gl_Position = a_position;
uv = a_position.xy;
GameViewController.swift (in viewDidLoad)
let url: URL = Bundle.main.url(forResource: "art.scnassets/barrel", withExtension: "json")!
do
let jsonData = try Data(contentsOf: url)
let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options:JSONSerialization.ReadingOptions(rawValue: 0))
guard let dictionary = jsonObject as? Dictionary<String, Any> else
print("Not a Dictionary")
return
var technique: SCNTechnique? = nil
technique = SCNTechnique(dictionary: dictionary)
technique?.setValue(NSNumber(value: 0.5), forKey: "barrelPower")
cameraNode.camera?.technique = technique
catch let error as NSError
print("Found an error - (error)")
I'm not really an expert in shaders, and I know that it's probably better to write an SCNProgram or something but I have not clue where to even begin with that.
Any help is appreciated :)
ios swift shader scenekit scntechnique
ios swift shader scenekit scntechnique
asked Mar 7 at 13:59
Eddie KadiEddie Kadi
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You may try
let scnView = self.view as! SCNView
scnView.technique = technique
as you are using a ("draw" : "DRAW_QUAD") which is rendering a texture of render objects.
Also there is a compiler error :
float d = length(xy); // `xy` is not defined
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045564%2fwhy-does-my-scene-camera-only-show-black-screen-when-i-use-scntechnique%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may try
let scnView = self.view as! SCNView
scnView.technique = technique
as you are using a ("draw" : "DRAW_QUAD") which is rendering a texture of render objects.
Also there is a compiler error :
float d = length(xy); // `xy` is not defined
add a comment |
You may try
let scnView = self.view as! SCNView
scnView.technique = technique
as you are using a ("draw" : "DRAW_QUAD") which is rendering a texture of render objects.
Also there is a compiler error :
float d = length(xy); // `xy` is not defined
add a comment |
You may try
let scnView = self.view as! SCNView
scnView.technique = technique
as you are using a ("draw" : "DRAW_QUAD") which is rendering a texture of render objects.
Also there is a compiler error :
float d = length(xy); // `xy` is not defined
You may try
let scnView = self.view as! SCNView
scnView.technique = technique
as you are using a ("draw" : "DRAW_QUAD") which is rendering a texture of render objects.
Also there is a compiler error :
float d = length(xy); // `xy` is not defined
answered Mar 7 at 21:44
E.ComsE.Coms
2,8182415
2,8182415
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045564%2fwhy-does-my-scene-camera-only-show-black-screen-when-i-use-scntechnique%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown