Multi-Layered Blending in 3D - xna

I'm using XNA 4.0 and I have a layer that I need to blend into a 3D scene. I draw particles to a render target which I then draw. This is necessary in order to create the correct effect with additive blending for particles. I need to be able to blend the layer into the scene at the correct depth. How would I go about doing this?

Related

Drop shadow on face in RealityKit

The task is to show glasses shadow on the user's face. Right now there is no shadow under the glasses. AnchorEntity(.face) is being used as the main anchor for glasses!
How it works now:
How it should work:
Limited Raytracing options for glass
In RealityKit 2.0 there are very limited raytracing options for transparent and semi-transparent objects (like glasses, vases or windows). There are no properties that control how raytracing should work. Remember, RealityKit's renderer isn't the same as Arnold in Autodesk Maya, for example. So there are no robust semi-transparent shadows behind glasses in RealityKit. Only frames cast opaque shadows, but these shadows are insignificant, barely noticeable.
Solution I
Here is a first solution for this situation - you need to use baked shadows (fake shadows) on the texture of a canonical face mesh. But, of course, using this approach, you can't "cast" shadows on real-user eyes to get a robust shading experience.
Solution II
To shade real-user eyes and areas around eyes in AR app you need to create two alpha-channel masks to apply a lower intensity for eyes and areas around them. For changing intensity of certain areas of background video you need to use compositing methods (CI filters) available in CoreImage framework.

SceneKit: Transform texture to fill only part of a sphere

I'm developing an application that uses SceneKit API and I faced the problem that I basically cannot apply a texture to a sphere object and keep texture's pre-defined size. I'm able to either scale the texture up to the object's surface (default SceneKit's behavior) or repeat it. But what I want to achieve is similar to the billiard ball:
Let's say I have a a .png image of a white circle with the number "13" at the center of it. I want to put it like the one on the picture. Generally, I want it to be scaled up to a fixed size, not the whole surface.
I use material.diffuse.contents property of SCNGeometry to set the texture and I found contentsTransform property in the documentation which can probably help me sort it out but I didn't find an explanation how to use it with the sphere object.
Is it something that is possible with pure SceneKit? Any help would be very appreciated.
You need a preliminarily modelled geometry (polygonal sphere in your case) and its UV Mapped texture that's made in 3D modelling software (Autodesk Maya for instance).
Watch this short movie to find out how to get UV-mapped texture.

iOS - Adding a 2D image to a scenekit game

Hello i can't for the life of me work out how to add a 2D image in the scene using scenekit is it even possible? What I'm trying to accomplish is have a 3D flying plane over a 2D background image but the background image can't cover the whole screen. Thanks to anyone that can help
Others have said plenty good suggestions above.
Let me summarize each solution with different scenarios:
Using scnScene.background: Easiest, but fullscreen and static. You cannot display in a smaller area of the scene, nor can you customize the transformations.
Using scnScene.overlaySKScene to display a 2D SKScene and adding image sprite. This is probably what fits your scenario. If you want static but with configurable transformations, this is a good choice. Notably overlaySKScene is recommended by Apple to create HUD in your 3D scene.
However, if you want the 2D content to track the 3D movement, you need to do some coordinate conversion from 3D space to 2D space every frame. Bad news is the job is done by CPU, which will add performance drag. (Believe me, this frustrate me too!)
Using SCNNode with SCNPlane geometry and set the diffuse.content with the image; add SCNBillBoardConstraint to the node to ensure it's always facing the camera.
Most flexible. However if your camera is not orthographic, the picture is going to zoom as the fov of camera changes, which doesn't look 2D but rather a hanging 3D billboard.
SceneKit and SpriteKit play very nicely together.
Implement the background 2D image as a SceneKit node with SCNPlane geometry, using your image as the plane's material. If you want to get fancier, use a full, live SpriteKit scene as the SCNPlane's material. Place that node at the far end of your camera's frustum, with your 3D aircraft in front of it.
You might also consider providing a cube map (skybox) as your scene's background. See SCNScene.background.
You can use the background property on SCNScene to set a background image.
scnScene.background.contents = UIImage(named: "myImage")
Contents
You can set a value for this property using any of the following
types:
A color (NSColor/UIColor or CGColorRef), specifying a constant color
across the material’s surface
An image (NSImage/UIImage or CGImageRef), specifying a texture to be
mapped across the material’s surface
An NSString or NSURL object specifying the location of an image file
An array of six images (NSArray), specifying the faces of a cube map
A Core Animation layer (CALayer)
A texture (SKTexture, MDLTexture, MTLTexture, or GLKTextureInfo)
A Sprite Kit scene (SKScene)

What functions can I use to render a SkyPlane(explaiend below) in DirectX9?

Basically it's like a SkyBox,but a plane that is perfectly flat and infront of the screen.My idea is to have a big texture and depending on how you rotate the camera it renders different parts of the texture on the plane as if you are moving relative to the "sky" drawn on the plane and when you reach the edge it renders it +the part from the other side(I'll use a seamless texture,so it won't look seamed).I have figured out the formulas to do it,but I'm not sure what method to use.I mean I'm not sure if I should do it in C++ or is it supposed to be done in the shader in some .fx file and directly on the GPU?
All you need to do is draw a full-screen quad behind the rest of your scene, or use depth states to push it out to infinity.
If you want a simple plane, then you create the four necessary verts, bind your texture, and draw (disable writing to depth), then go about drawing the rest of the scene. This is done with a simple draw call in your C++, although you can use vertex buffers and such if necessary.
If you need something more complex, like layers or parallax, you'll need to use multiple planes and shift them, or a shader to composite multiple textures.

DirectX: How to draw smooth 2D water (particle based water)

I recently got a water simulation using particles (1000-1500) working (using the stokes equation), but my problem is that I use a IDXSprite which just draws the particles using blue texture quads (7x7), that doesnt look very smooth.
Is there any way or known technique for drawing such systems so the surface will look smooth (and the water shouldnt have the edges from the textures in it)

Resources