コード例 #1
0
ファイル: renderDrivers.py プロジェクト: connoryang/1v1dec
    def ApplyShaders(self, doll, meshes):
        self.wrinkleFx = []
        if not meshes:
            return
        skinSpotLightShadowsActive = lambda : SkinSpotLightShadows.instance is not None
        skinLightmapRendererActive = lambda : doll.skinLightmapRenderer is not None
        tasklets = []
        asyncMeshes = {}

        def DoClothMesh(mesh):
            isHair = False
            isHair = self.BindClothShaders(mesh, doll, isHair)
            if type(mesh.effect) == trinity.Tr2Effect:
                loadingResources = []
                if mesh.effect and type(mesh.effect) == trinity.Tr2Effect:
                    loadingResources.append(mesh.effect.effectResource)
                if mesh.effectReversed:
                    loadingResources.append(mesh.effectReversed.effectResource)
                pdCf.WaitForAll(loadingResources, lambda x: x.isLoading)
                if mesh.effect:
                    mesh.effect.PopulateParameters()
                if mesh.effectReversed:
                    mesh.effectReversed.PopulateParameters()
            if SkinSpotLightShadows.instance is not None:
                SkinSpotLightShadows.instance.CreateEffectParamsForMesh(mesh, isClothMesh=True)
            if isHair and hasattr(mesh, 'useTransparentBatches'):
                mesh.useTransparentBatches = True

        for mesh in iter(meshes):
            if type(mesh) is trinity.Tr2ClothingActor:
                t = uthread.new(DoClothMesh, mesh)
            else:
                if skinSpotLightShadowsActive() or skinLightmapRendererActive():
                    asyncMeshes[mesh] = False
                if pdDef.DOLL_PARTS.HEAD in mesh.name:
                    t = uthread.new(self.SetInteriorShader, *(asyncMeshes,
                     mesh,
                     self.wrinkleFx,
                     doll))
                else:
                    t = uthread.new(self.SetInteriorShader, *(asyncMeshes,
                     mesh,
                     None,
                     doll))
            tasklets.append(t)
            uthread.schedule(t)

        pdCf.WaitForAll(tasklets, lambda x: x.alive)
        for mesh in asyncMeshes.iterkeys():
            if skinSpotLightShadowsActive():
                SkinSpotLightShadows.instance.CreateEffectParamsForMesh(mesh)
            if skinLightmapRendererActive() and asyncMeshes[mesh]:
                doll.skinLightmapRenderer.BindLightmapShader(mesh)
コード例 #2
0
    def SetInteriorShader(self, asyncMeshes, mesh, wrinkleFx, doll):
        """
        Applies interior shaders to the given mesh
        """
        fx = pdCcf.GetEffectsFromMesh(mesh)
        tasklets = []
        for f in iter(fx):
            if type(f) == trinity.Tr2ShaderMaterial:
                continue
            t = uthread.new(self.SetInteriorShaderForFx_t,
                            *(f, asyncMeshes, mesh, wrinkleFx, doll))
            tasklets.append(t)

        pdCf.WaitForAll(tasklets, lambda x: x.alive)
コード例 #3
0
ファイル: renderDrivers.py プロジェクト: connoryang/1v1dec
 def DoClothMesh(mesh):
     isHair = False
     isHair = self.BindClothShaders(mesh, doll, isHair)
     if type(mesh.effect) == trinity.Tr2Effect:
         loadingResources = []
         if mesh.effect and type(mesh.effect) == trinity.Tr2Effect:
             loadingResources.append(mesh.effect.effectResource)
         if mesh.effectReversed:
             loadingResources.append(mesh.effectReversed.effectResource)
         pdCf.WaitForAll(loadingResources, lambda x: x.isLoading)
         if mesh.effect:
             mesh.effect.PopulateParameters()
         if mesh.effectReversed:
             mesh.effectReversed.PopulateParameters()
     if SkinSpotLightShadows.instance is not None:
         SkinSpotLightShadows.instance.CreateEffectParamsForMesh(mesh, isClothMesh=True)
     if isHair and hasattr(mesh, 'useTransparentBatches'):
         mesh.useTransparentBatches = True