Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MoMoRenderer: Speed up the cached MoMoRenderer for the same instance. #91

Merged
merged 1 commit into from
Mar 24, 2018

Conversation

andreas-schneider
Copy link

Problem

Currently when using the cached version of the MoMoRenderer a mesh is generated from the model every time something in the RenderParameter changes. Including illumination and pose, which do not affect mesh generation.

Affected Usecase

This results in unnecessary computation when rendering the same MoMoInstance under different illuminations or poses.

Solution

Do not cache accoding to the RenderParameter but only according to the MoMoInstance part of the RenderParameter.

Result

Speed up of 4 for rendering the same mesh with different poses and illuminations (512x512) when the proposed changes are applied.

def test() = {
  val model = ???
  val renderer = MoMoRenderer(model).cached(5)
  val res: immutable.Seq[(PixelImage[RGBA], Double)] = for(i<- 0.0 until 50.0 by 1.0) yield {
    val p = RenderParameter.defaultSquare.withMoMo(MoMoInstance.zero(100, 100, 0, new URI(""))).withPose(Pose(1.0, Vector(0,0,1000), 0, i*0.01, 0)).withEnvironmentMap(SphericalHarmonicsLight.fromAmbientDiffuse(RGB(0.5), RGB(0.5), Vector(0,0,i)))
    LanguageUtilities.timed{
      renderer.renderImage(p)
    }
  }

  val times = res.slice(10,40).map(_._2)
  println(times.sum / times.length)
}

…rent poses and illuminations by caching the instance() according to the MoMoCoefficients and not the full RenderParameter.
@Andreas-Forster
Copy link
Member

Thx. This makes absolute sense and is definitively a better solution.

@Andreas-Forster Andreas-Forster merged commit 5d22eab into master Mar 24, 2018
@Andreas-Forster Andreas-Forster deleted the feature-better-cached-momo-renderer branch March 24, 2018 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants