Physically Based lighting lost after using metal shader on another model? - scenekit

i got 2 models on my scene (using SceneKit) - ring and diamond. Ring is with gold pbr material (SCNLightingModelPhysicallyBased) - second is diamond with "custom" material using Metal shader (SCNProgram). Right after developing diamond shader my golden ring stopped working and is pure black. Why is that ? When i simply set my ring to yellow and drop pbr lighting model it works, just not pbr - with pbr its solid black. I cant use SCNProgram with PBR ?

Are you setting the scene's lightingEnvironment? You will need a light source in the scene for the object to be lit. You can either use point lights or leverage image-based lighting (IBL) which is what the lightingEnvironment is for.
You can also try the autoenablesDefaultLighting property. With it SceneKit will try to adjust and add light sources in the scene depending on its contents, but its behaviour is subject to changes.

Related

Scenekit - add red tint to camera

Is it possible to add a red tint to a given camera in SceneKit? I would like to accomplish this without the (what I consider to be) hacky solution of just trying to shove a red object with < 1 opacity in front of the camera. That could be a solution but I haven't had great success in SceneKit showing an object right in front of the camera.
Also, ideally, I could fade the red tint in and out using SCNAction or some other way.
Finally, a perfect solution would work in ARKit, and give a red tint to the whole world around you. So it would have to be something more than a red scenekit light.
SCNCamera's colorGrading property can do that (that would be the most efficient option).
Using a SCNTechnique to apply a custom post process would work too but it requires an additional pass.
Both options would be faster than a blended node in front of the camera, or a red-ish spritekit overlay or a UIView on top of the SCNView.
Instead of adding a red-tinted SCNNode into the scene, you could just add a tinted UIView in front of the ARSCNView in the storyboard. With an outlet to that view fading it in and out would be easy.

Create light rays (like a spotlight) in SceneKit

How would I go about creating a spotlight in SceneKit where you can actually see the cone of light, not just the light on the surface of the object it hits? Sort of like how you can see the Bat Signal's cone of light in the night sky.
It doesn't seem like SceneKit lights support this out of the box. The best I can come up with so far is adding cone geometry with material properties that sort of make it look light a light. But then how would I fade out the top part of the cone?

How to implement halo effect with Wpf 3D?

I'm trying to build a 3D earth with Wpf Viewport3D. I have created the earth and it works pretty good. Then I want to add a halo effect around the earth like this attached image:
.
Some recommend to use diffuse material for the globe model. Then build a slight larger globe model with emissive material and little opacity. But the effect is not very good. It affects the color of diffusion material like this:
How can I implement the effect like the first screenshot?
I've done exactly this by creating a ring, inner radius the same radius as the planet and an outer radius to relect the atmospheric depth. Oriented to 'face me'. Using texture coordinates into a LinearGradientBrush to have the atmosphere fade from sky blue to transparent black.
Alternatively, there are some fairly good PNGs around of semi-transparent cloud layers you could use on the slightly larger sphere.

WPF 3D transparent textures - clipping?

http://www.youtube.com/watch?v=gZNdfVwkttM - you can see all of the problem described on this video if you can't see pictures.
All of walls in all images below have a semitransparent PNG texture. Each square wall, floor and ceiling tile is a separate GeometryModel3D (I know that is no good for performance but...). The floor and the ceiling of the central cube have no any geometry and textures - so they have a color the same as Window.Background (black). But the effect considered appears in any way of transparency obtaining: texture for ImageBrush with transparency, Material.Color (for example DiffuseMAterial.Color) where Color has alpha channel, ImageBrush as material where ImageBrush has Opacity - all the way I have the same problem.
All of walls consists of two triangles. Where are no explicit normals , because I define triangle indices so normals culculated automatically by WPF.
http://imagepost.ru/images/i/ma/image00001.png
It also haven't any back material or extra triangles from the back side.
As you can see there is no problem if you look only from +Z to -Z (standing on the blue square and looking to the red square - that is the second picture).
But if you look backward (from red to blue - the first picture) there is no transparency!
Well, I desided to look from the yellow square (third picture).
And then I walked nearer - you can see what was happening (pictures from 4 to 6).
There are no geometry construction error or texture mapping error or lighting error! It is some kind of clipping, I guessed! In addition there are some interested pictures 7 and 8 to prove my guess.
The last picture shows the white background of the window that hosted Viewport3D (previous was black), and my guess about clipping confirmed - WPF just not painted this part of the scene and we can see the window background!
BUT! If this happens from various looks, why the look from +Z to -Z (second picture) seems well?!
You need to sort the triangles based on their distances from the viewpoint. Only then, wpf will be able to blend the transparent textures.
DirectX is able to blend triangles on top of each other but only when drawing them back to front
http://www.ericsink.com/wpf3d/2_Transparency.html

Light Map projection

What i'm trying to do is making a "light projector" with visible ray(like with fog) also called volumetric light;
and which project a image (bitmap) ;
Because i would like to keep this project connected with a wpf application ( to get brush, position, rotation from data), i've choose to use WPF 3D
But it seem that WPF can't handle light projection or render ray.
So to do that, i have extruded each pixel of my source bitmap into a polygon colored by a solidColorBrush of the pixel color.
and keep the pixel order with (x,y) position.
For performance issue, i've set all the bitmaps to 32x32 px ( 1024 polygon for only one light !!)
But the result is too pixelated as you can see on the picture.
Moreover, it probably take much memory for nothing ...
my question is, how can i make it smooth or even rethink the extrusion system to optimize performance ...
Is any other tehnology that can be integrated into a wpf application and do that better or easier ?
Thanks, and sorry my English is pretty bad ...
alt text http://www.visualdmx.fr/pic_example.png

Resources