Open appleweed opened 6 years ago
Can you share a screenshot?
Same problem here. It only occurs on the opposite edge when the other edge goes over a glowing part.
I think this is due to the texture sampler using 'repeat' addressing. I just pushed something that should fix this. Please give it a shot and let me know if it's working OK.
Here’s a quick video running on my iPhone. You’ll notice the screen edges. I’ll try the new build later today.
https://drive.google.com/open?id=1h3p5x1WW9OpjfLDmvIYiHSdelkMop1t_
With the standard scnView implementation ( with zooming incorporated as appleweed is doing)... address::clamp_to_zero stops the glowing around the edges from happening.
Using ARSCNView as the implementation... address:: clamp_to_zero is causing the entire screen to go black.
Just want to start by cautioning, I have very limited knowledge about metal shaders. Anyway, a quick read of the spec. Metal Shading Language Specification - goto page 29
Talks about being able to set different address types s_address, r_address, t_address.
I initially tried setting address::clamp_to_edge... however, this gave a distorted rendering of the ARSCNView... but at least better than a black screen.
I tried this combination and it works! to fix the problem in both ARSCNView and the scnView (with zoom)
r_address: clamp_to_edge, t_address: repeat,
@cclaan The new push fixed the problem for me! Thank you!
@wave-electron Thanks for testing that.. my knowledge on metal shaders is limited too. When I have more time I can dig in to what's going on. I suspect there are coordinate differences between ARSCNView and SCNView that could be fixed in a few ways. If you'd like to submit a pull request we can go with that solution for now if it works on both ARSCNView and SCNView.
no problem, thanks for sharing such a nice example of a metal shader implementation with scenekit! I managed to get a flag waving in scenekit using openGL shaders a few months ago, but found it a steep learning curve and the shader/scenekit examples limited & usually poorly documented. BTW, just submitted a pull request for those changes.
I had the same issue, I fixed it by changing every address
to clamp_to_edge
. So now it looks like this
texture2d<float, access::sample> colorSampler [[texture(0)]])
{
constexpr sampler sampler2d(coord::normalized, filter::linear, address::clamp_to_edge);
return half4(1.0);
};
////////////
constexpr sampler s = sampler(coord::normalized,
r_address::clamp_to_edge,
t_address::clamp_to_edge,
filter::linear);```
Since some people say they have a something else working from them I will not make a pull request.
Hi,
First, thanks for the excellent example for using SCNTechnique! I noticed when I zoom in on the plane that the glow effect will draw to the edges of the view / screen when the model clips to the edges. Is there a method to make sure the glow only draws on the model when it clips to the edges?
Thanks!