How to generate shadow png file from Autodesk Maya? - scenekit

I am rendering 3d furniture models in Autodesk Maya for an AR app. For showing a shadow of 3d model in scene file I need export of transparent PNG file from Autodesk Maya which I can use as diffuse image for shadow plain. I have attached example of the kind of file needed but I don't know how to generate the same in Autodesk Maya. Please help.Shadow file generated for chair model.

If you want to generate in Maya a UV texture containing shadows for ARKit / SceneKit models follow these steps (I should say that it's not easy if you're a beginner in Maya):
Create objects with appropriate shaders
Create UV map for your models in UV Editor
Activate Maya Software Renderer
Create lights with Raytraced Shadows
Don't forget turn Raytracing on in Render Options
Duplicate all 3D objects and lights
Select an object with cast shadows and a corresponding light
Go to Rendering module and choose Lighting/Shading - Transfer Maps... menu.
Setup all the properties for Shaded Output Map and its appropriate location and then press Bake.
Also you can output four additional passes in Maya Software Renderer:
Normal Map
Displace Map
Diffuse Map
Alpha Map
If you want just shadows, without diffuse texture, use white coloured Lambertt Shader in Maya.

Related

Decals and React

I’ve been stuck for days, and couldn’t figure it out.
I’m trying to put a small graphic (as in Team Badge, and player’s number at the back) onto a basketball jersey. I can’t use Texture as anything I specified will cover the whole jersey.
From this https://threejs.org/examples/#webgl_decals I believe decal is the way to go. What I don’t understand is that I need to shove a Mesh into the Constructor of DecalGeometry. What kind of mesh should I use? Not the mesh of the basketball jersey?
Is this the right step?
get the upload of PNG from browser
create DecalGeometry using an arbitrary Geometry (may be a square?)
specify some material (I want it to be transparent)
create a new mesh using the above DecalGeometry and material (I can’t figure out what values to use for the decal projector…)
load the PNG into a Texture
load the basketball jersey’s Mesh
merge the basketball jersey’s Mesh with the new Mesh containing the DecalGeometry
Also, how do I control the size of the graphic inside the DecalGeometry? As the graphic has color, I’m not sure if the basketball jersey’s color will affect the graphic and make the graphic look broken?
Thanks a lot!

How to draw a polygon shaped data annotation shape for image detection?

I am training some images using imageAI object detection. What i want to do is draw a polygon shaped data annotation around the objects in an image. Not a square box. Even though I ca draw the shape, the imageAI class doesn't consider polygon shapes. If some one can help me to find if is there is some model where polygon shapes are allowed in image training, that would be great.
ImageAI only supports PascalVOC image annotation format, which is upright rectangular bounding boxes. You would need to change frameworks for this to work. For a workaround, consider using an image editing tool to get rid of the background and then provide a square bounding box.

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

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.

Reduce Application Lag while using shadows in SceneKit

I am working on a 3D map in SceneKit. When I enable the Cast Shadow Property of a directional light in SceneKit, the shadows appear, but the application becomes very slow.
How do I reduce the lag while still maintaining shadows in the scene?
Use Fake Shadows (shadows generated as a texture in 3D authoring or 2D authoring app) rather than True Shadow Map. To apply fake shadows as a texture for 3D plane use PNG file format with premultiplied alpha channel (RGB * A). It considerably reduces Processing and Memory Usage when using shadows in RealityKit or SceneKit.

How do I load/parse a SceneKit .scn file into my Metal app?

I want to create a 3D scene with the SceneKit modeler and then read it into my Metal app. I see there is SceneKit and ModelIO API to do this but I am unclear on how the pieces fit together.
So, what I need is path from .scn file -> MDL Mesh -> geometry + texture. I am unclear on how I would sync my Metal shaders with materials created in the SceneKit modeler.
There's two main parts to what you're asking here: getting SceneKit data into ModelIO, and rendering ModelIO data with Metal.
To get SceneKit scenes into ModelIO, first use SceneKit API (SCNScene or SCNSceneSource to load the .scn file, then use ModelIO API to get the objects you want as meshes. You can create a MDLAsset from the entire scene using assetWithSCNScene:bufferAllocator: and then walk through the asset's object hierarchy in ModelIO to find the mesh you want, or walk through the node hierarchy in SceneKit to find the SCNNode or SCNGeometry you want and then get the mesh to ModelIO using objectWithSCNNode:bufferAllocator: or meshWithSCNGeometry:bufferAllocator:.
As for using ModelIO meshes in a Metal app, Apple has a sample code project that shows how to use ModelIO to load an OBJ mesh, use MetalKit to get the mesh data into Metal GPU buffers, and hook up the material information you get from ModelIO to shader variables for use in your own renderer.
You should be able to put the two of these together: where the sample code loads an OBJ to get a MDLAsset or MDLMesh, use the methods in (1) to get an asset or mesh out of a SceneKit file instead.
The SceneKit material model is of course much more complicated than the simple Phong shader used in the sample code. But the sample code does show how to iterate through a MDLMaterial's properties and set corresponding arguments in a Metal shader — if you create a more complicated shader, just follow the same steps to map the material properties to whatever your shader's inputs are.

Resources