1616from SettingsManager import SettingsManager
1717from MemoryMonitor import MemoryMonitor
1818from DistributedTaskManager import DistributedTaskManager
19+ from GUI .FastText import FastText
1920
2021from RenderPasses .GlobalIlluminationPass import GlobalIlluminationPass
2122from RenderPasses .VoxelizePass import VoxelizePass
@@ -62,12 +63,12 @@ def __init__(self, pipeline):
6263 self .voxelGridSize = self .pipeline .settings .giVoxelGridSize
6364
6465 # Grid resolution in pixels
65- self .voxelGridResolution = 64
66+ self .voxelGridResolution = 128
6667
6768 # Has to be a multiple of 2
68- self .distributionSteps = 30
69-
70- self .slideCount = int ( math . sqrt ( self .voxelGridResolution ))
69+ self .distributionSteps = 40
70+ self . slideCount = int ( self . voxelGridResolution / 8 )
71+ self .slideVertCount = self .voxelGridResolution / self . slideCount
7172
7273 self .bounds = BoundingBox ()
7374 self .renderCount = 0
@@ -85,24 +86,16 @@ def __init__(self, pipeline):
8586 self .frameIndex = 0
8687 self .steps = []
8788
88-
89-
9089 def _createDebugTexts (self ):
9190 """ Creates a debug overlay to show GI status """
9291 self .debugText = None
9392 self .buildingText = None
9493
9594 if self .pipeline .settings .displayDebugStats :
96- try :
97- from .GUI .FastText import FastText
98- self .debugText = FastText (pos = Vec2 (
99- Globals .base .getAspectRatio () - 0.1 , 0.88 ), rightAligned = True , color = Vec3 (1 , 1 , 0 ), size = 0.03 )
100- self .buildingText = FastText (pos = Vec2 (- 0.3 , 0 ), rightAligned = False , color = Vec3 (1 , 1 , 0 ), size = 0.03 )
101- self .buildingText .setText ("PREPARING GI, PLEASE BE PATIENT ...." )
102-
103- except Exception , msg :
104- self .debug (
105- "GI-Debug text is disabled because FastText wasn't loaded" )
95+ self .debugText = FastText (pos = Vec2 (
96+ Globals .base .getAspectRatio () - 0.1 , 0.88 ), rightAligned = True , color = Vec3 (1 , 1 , 0 ), size = 0.03 )
97+ self .buildingText = FastText (pos = Vec2 (- 0.3 , 0 ), rightAligned = False , color = Vec3 (1 , 1 , 0 ), size = 0.03 )
98+ self .buildingText .setText ("PREPARING GI, PLEASE BE PATIENT ...." )
10699
107100 def stepVoxelize (self , idx ):
108101
@@ -126,14 +119,13 @@ def stepVoxelize(self, idx):
126119 self .buildingText .remove ()
127120 self .buildingText = None
128121
129- self .voxelizePass .voxelizeSceneFromDirection (self .gridPosTemp [0 ], "yxz " [idx ])
122+ self .voxelizePass .voxelizeSceneFromDirection (self .gridPosTemp [0 ], "xyz " [idx ])
130123
131124
132125 def stepDistribute (self , idx ):
133126
134127 if idx == 0 :
135- self .convertGridTarget .setActive (True )
136-
128+ self .convertGridTarget .setActive (True )
137129
138130 self .distributeTarget .setActive (True )
139131
@@ -143,14 +135,14 @@ def stepDistribute(self, idx):
143135
144136 if idx == self .distributionSteps - 1 :
145137 self .publishGrid ()
146-
147-
148138 dests = self .dataTextures
149139
150140 for i in xrange (5 ):
151141 self .distributeTarget .setShaderInput ("src" + str (i ), sources [i ])
152142 self .distributeTarget .setShaderInput ("dst" + str (i ), dests [i ])
153143
144+ self .distributeTarget .setShaderInput ("isLastStep" , idx >= self .distributionSteps - 4 )
145+
154146 def publishGrid (self ):
155147 """ This function gets called when the grid is ready to be used, and updates
156148 the live grid data """
@@ -219,7 +211,7 @@ def setup(self):
219211 self .bindTo (Globals .render , "giData" )
220212
221213 self .convertGridTarget = RenderTarget ("ConvertGIGrid" )
222- self .convertGridTarget .setSize (self .voxelGridResolution * self .slideCount , self .voxelGridResolution * self .slideCount )
214+ self .convertGridTarget .setSize (self .voxelGridResolution * self .slideCount , self .voxelGridResolution * self .slideVertCount )
223215
224216 if self .pipeline .settings .useDebugAttachments :
225217 self .convertGridTarget .addColorTexture ()
@@ -231,7 +223,7 @@ def setup(self):
231223 self .convertGridTarget .getColorTexture ().setMagfilter (Texture .FTNearest )
232224
233225 self .clearGridTarget = RenderTarget ("ClearGIGrid" )
234- self .clearGridTarget .setSize (self .voxelGridResolution * self .slideCount , self .voxelGridResolution * self .slideCount )
226+ self .clearGridTarget .setSize (self .voxelGridResolution * self .slideCount , self .voxelGridResolution * self .slideVertCount )
235227 if self .pipeline .settings .useDebugAttachments :
236228 self .clearGridTarget .addColorTexture ()
237229 self .clearGridTarget .prepareOffscreenBuffer ()
@@ -240,6 +232,7 @@ def setup(self):
240232 self .convertGridTarget .setShaderInput ("voxelGenSrc" + color .upper (), self .generationTextures [idx ])
241233 self .clearGridTarget .setShaderInput ("voxelGenTex" + color .upper (), self .generationTextures [idx ])
242234
235+
243236 # Create the data textures
244237 self .dataTextures = []
245238
@@ -267,10 +260,10 @@ def setup(self):
267260 self .pongDataTextures .append (texPong )
268261
269262 self .convertGridTarget .setShaderInput ("voxelDataDest" + str (i ), self .pingDataTextures [i ])
270-
263+ # self.clearGridTarget.setShaderInput("voxelDataDest" + str(i), self.pongDataTextures[i])
271264
272265 # Set texture wrap modes
273- for tex in self .pingDataTextures + self .pongDataTextures + self .dataTextures :
266+ for tex in self .pingDataTextures + self .pongDataTextures + self .dataTextures + self . generationTextures :
274267 tex .setMinfilter (Texture .FTNearest )
275268 tex .setMagfilter (Texture .FTNearest )
276269 tex .setWrapU (Texture .WMBorderColor )
@@ -283,7 +276,7 @@ def setup(self):
283276 tex .setMagfilter (Texture .FTLinear )
284277
285278 self .distributeTarget = RenderTarget ("DistributeVoxels" )
286- self .distributeTarget .setSize (self .voxelGridResolution * self .slideCount , self .voxelGridResolution * self .slideCount )
279+ self .distributeTarget .setSize (self .voxelGridResolution * self .slideCount , self .voxelGridResolution * self .slideVertCount )
287280
288281 if self .pipeline .settings .useDebugAttachments :
289282 self .distributeTarget .addColorTexture ()
@@ -294,6 +287,7 @@ def setup(self):
294287 self .distributeTarget .getColorTexture ().setMinfilter (Texture .FTNearest )
295288 self .distributeTarget .getColorTexture ().setMagfilter (Texture .FTNearest )
296289
290+
297291 # Create the various render targets to generate the mipmaps of the stable voxel grid
298292 # self.mipmapTargets = []
299293 # computeSize = self.voxelGridResolution
@@ -326,7 +320,7 @@ def setup(self):
326320 if False :
327321 self .voxelCube = loader .loadModel ("Box" )
328322 self .voxelCube .reparentTo (render )
329- self .voxelCube .setTwoSided (True )
323+ # self.voxelCube.setTwoSided(True)
330324 self .voxelCube .node ().setFinal (True )
331325 self .voxelCube .node ().setBounds (OmniBoundingVolume ())
332326 self .voxelCube .setInstanceCount (self .voxelGridResolution ** 3 )
0 commit comments