david-cattermole / mayaMatchMoveSolver

A Bundle Adjustment solver for MatchMove related tasks.
https://david-cattermole.github.io/mayaMatchMoveSolver/
Other
102 stars 27 forks source link

MM Image Plane - Transparent Objects Disappear #252

Closed david-cattermole closed 3 months ago

david-cattermole commented 7 months ago

Problem

Any foreground geometry that isn't fully opaque disappears when in front of the image plane.

Expected behavior: Semi-Transparent objects should be visible in front of the MM Image Plane.

Actual behavior: Transparent objects disappear as soon as they are not fully opaque.

Steps to Reproduce

  1. Create a camera and mmSolver image plane with an image sequence.
  2. Place a default sphere in view between the camera and image plane.
  3. On the sphere's lambert shader, move the transparency slider forward a little bit. Any part of the sphere that's in front of the image plane immediately disappear and anything outside it has the correct partial transparency.

Software Versions

david-cattermole commented 6 months ago

Looks like I've found the heart of the problem - the shader is being treated as transparent, but visually we don't want it to be treated as transparent.

MShaderInstance::setIsTransparent() will set the transparency of the shader. Strangely enough, setting m_shader->setIsTransparent(true) actually causes the problem - not fixes it (in my tests) Try setting m_shader->setIsTransparent(false), and see if it fixes the problem.

The reason why the MM Image Plane (as it currently is in v0.4.9 and v0.5.0.beta3) doesn't use MShaderInstance::setIsTransparent() is because it's evaluating the shader network of a real Maya shader and assigning that shader to a MRenderItem directly using MRenderItem::setShaderFromNode(). I use MRenderItem::setShaderFromNode() so I can avoid implementing colour space conversions that are inbuilt into Maya's File node, but are not available in the Maya API.

To fix this for MM Image Plane it's going to be tricky as the use of MRenderItem::setShaderFromNode() means I cannot setIsTransparent(false) on it directly, therefore my only way forward is to write a new shader (which I've pretty much done while debugging this) and add OCIO support and image caching to mmSolver - something I've wanted to avoid.

david-cattermole commented 3 months ago

This has been merged into the "develop" branch via #258. This contains a new node; mmImagePlaneShape2, and many other new features. These are all created to reproduce the similar features as in the original mmImagePlaneShape node as mmSolver now embeds OpenColorIO and is used to generate real-time colour-space conversion.

This will be part of the next beta release.