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)
}
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.