I have a scene that has many objects, that all have different textures. For some reason 2 objects have a red hue to them, even though their textures have no red. You can still see the pattern in the texture, it just has different shades on red. (On the simulator the 2 objects have black and white textures and on device shades of red) Does anyone have any idea why this is happening? Other objects are working fine.
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
- Swift - Snapshotting a view that has not been rend
I've had the same problem with loading (grey) .png images as texture for a
SCNMaterial
.On the simulator it rendered fine. But on the device all images with only black, white or grey, renders with a red base color.
I solved this problem by creating a new
UIImage
from the givenUIImage
:HTH
I had the same problem with an indexed-color png texture.
What I did for solving the problem was to convert the indexed-color png into the truecolor png.
It might be an NSImage bug. When I used CGImage to load the png file, it didn't cause any problem.
For material properties such as
metalness
androughness
SceneKit has support for 1 channel (grayscale) images. In order to save memory these images are kept as grayscale textures, they are not converted to RGB textures that have the same data in each channel.When you use such an image for a "coloured" material property (such as
diffuse
), SceneKit will ask for the red, green and blue components of the sample but green and blue will always be 0 and the image will appear red.One unfortunate solution consists in reworking your texture in an image editing app so that it's saved as RBG instead of grayscale.
You can also try shader modifiers to convert from grayscale to RGB:
Edit
Starting iOS 11 you can use the
textureComponents
property when using single channel textures: