I have a My3DScene, which adds SCNTechnique to the camera. The technique simply adds a border to a 3d model.
Then the following code works fine:
// Here: Notice the 400x300 size
let scnView = SCNView(frame: CGRectMake(0, 0, 400, 300))
view.addSubview(scnView)
scnView.present(My3DScene(), with: .fade(withDuration: 0.1), incomingPointOfView: nil)
However, if I change the view size to be smaller, then it renders strangely:
// Here: Note the 40x40 size here
let v2 = SCNView(frame: CGRectMake(0, 400, 40, 40))
view.addSubview(v2)
v2.present(My3DScene(), with: .fade(withDuration: 0.1), incomingPointOfView: nil)
In the screenshot below, the top is a SCNView that renders correctly. The bottom is a smaller SCNView that renders strangely.
I have attached my project:
The following is another screenshot with 4 SCNView
s, from top to bottom, their sizes are:
400x300 (renders correctly) 40x40 100x100 150x150
I have a My3DScene, which adds SCNTechnique to the camera. The technique simply adds a border to a 3d model.
Then the following code works fine:
// Here: Notice the 400x300 size
let scnView = SCNView(frame: CGRectMake(0, 0, 400, 300))
view.addSubview(scnView)
scnView.present(My3DScene(), with: .fade(withDuration: 0.1), incomingPointOfView: nil)
However, if I change the view size to be smaller, then it renders strangely:
// Here: Note the 40x40 size here
let v2 = SCNView(frame: CGRectMake(0, 400, 40, 40))
view.addSubview(v2)
v2.present(My3DScene(), with: .fade(withDuration: 0.1), incomingPointOfView: nil)
In the screenshot below, the top is a SCNView that renders correctly. The bottom is a smaller SCNView that renders strangely.
I have attached my project:
https://drive.google/file/d/1BITsN7gucSU9fsbqjUBPxPiU6h7JN1uB/view?usp=sharing
The following is another screenshot with 4 SCNView
s, from top to bottom, their sizes are:
400x300 (renders correctly) 40x40 100x100 150x150
Share Improve this question edited Feb 16 at 7:53 OMGPOP asked Feb 16 at 7:48 OMGPOPOMGPOP 9848 gold badges53 silver badges101 bronze badges1 Answer
Reset to default 0The issue occurs because of a fixed MASK size
definition in your glowing_border_technique.plist
Since your MASK texture has a fixed size of 512x512, when applied to a smaller SCNView, the resolution mismatch might cause sampling errors or misalignment. The effect might look fine on larger views but appear distorted or incomplete on smaller ones.
Change this:
<key>size</key>
<string>512x512</string>
To:
<key>size</key>
<string>auto</string>
This is the out coming result and should fix your issue:
OPTIONAL: In addition you might want to check (or make somehow dynamic) the constant float bufferSize = 512.0;
in your glowing_border_technique.metal
file.