Explorar o código

better caching of blueNoise texture (we don't want other rfx to create a blueNoise texture again).

clementlandrin hai 2 semanas
pai
achega
156bb95277
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      hrt/prefab/rfx/VolumetricLighting.hx

+ 8 - 2
hrt/prefab/rfx/VolumetricLighting.hx

@@ -344,8 +344,14 @@ class VolumetricLighting extends RendererFX {
 			vshader.steps = steps;
 			vshader.invViewProj = r.ctx.camera.getInverseViewProj();
 			if ( vshader.ditheringNoise == null ) {
-				#if !multidriver static #end var image = hxd.res.Embed.getResource("hrt/prefab/rfx/blueNoise.png").toImage();
-				vshader.ditheringNoise = r.ctx.engine.cacheImage(image);
+				// can't wrap the following code in a method in h3d.Engine because of macro.
+				var resCache = @:privateAccess r.ctx.engine.resCache;
+				var t : h3d.mat.Texture = resCache.get("hrt/prefab/rfx/blueNoise.png");
+				if ( t == null ) {
+					t = hxd.res.Embed.getResource("hrt/prefab/rfx/blueNoise.png").toImage().toTexture();
+					resCache.set("hrt/prefab/rfx/blueNoise.png", t);
+				}
+				vshader.ditheringNoise = t;
 				vshader.ditheringNoise.wrap = Repeat;
 			}
 			vshader.targetSize.set(tex.width, tex.height);