Ejemplo n.º 1
0
    public static void DumpAllForFigure(ImportSettings settings, Device device, ShaderCache shaderCache, ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Figure figure, TextureProcessorSharer textureProcessorSharer)
    {
        MaterialSetImportConfiguration[] configurations = MaterialSetImportConfiguration.Load(figure.Name);

        var baseConf = configurations.Single(conf => conf.name == "Base");

        var surfaceProperties = SurfacePropertiesJson.Load(figure);
        TextureProcessor sharedTextureProcessor = surfaceProperties.ShareTextures != null?
                                                  textureProcessorSharer.GetSharedProcessor(surfaceProperties.ShareTextures) : null;

        foreach (var conf in configurations)
        {
            if (conf == baseConf)
            {
                continue;
            }

            if (!settings.ShouldImportMaterialSet(figure.Name, conf.name))
            {
                continue;
            }

            DumpMaterialSetAndScattering(settings, device, shaderCache, fileLocator, objectLocator, figure, baseConf, conf, sharedTextureProcessor);
        }
    }
Ejemplo n.º 2
0
    public static void Dump(Figure figure, IMaterialSettings[] materialSettingsArray, string materialSetName)
    {
        var surfaceProperties = SurfacePropertiesJson.Load(figure);

        if (!surfaceProperties.PrecomputeScattering)
        {
            return;
        }

        new ScatteringDumper(figure, materialSettingsArray, materialSetName).Dump();
    }
Ejemplo n.º 3
0
    private void DumpRefinement()
    {
        var surfaceProperties = SurfacePropertiesJson.Load(figure);

        DumpControl();

        DumpRefinementLevel(0);

        if (surfaceProperties.SubdivisionLevel != 0)
        {
            DumpRefinementLevel(surfaceProperties.SubdivisionLevel);
        }
    }
Ejemplo n.º 4
0
    public FigureDumper LoadDumper(string figureName)
    {
        var figure = figureName == parentFigure.Name ?
                     parentFigure :
                     figureRecipeLoader.LoadFigureRecipe(figureName, parentFigureRecipe).Bake(parentFigure);

        var figureConfDir = pathManager.GetConfDirForFigure(figure.Name);
        MaterialSetImportConfiguration baseMaterialSetConfiguration = MaterialSetImportConfiguration.Load(figureConfDir).Single(conf => conf.name == "Base");
        ShapeImportConfiguration       baseShapeImportConfiguration = ShapeImportConfiguration.Load(figureConfDir).SingleOrDefault(conf => conf.name == "Base");
        SurfaceProperties surfaceProperties = SurfacePropertiesJson.Load(pathManager, figure);

        ShapeDumper shapeDumper = new ShapeDumper(fileLocator, device, shaderCache, parentFigure, parentFaceTransparencies, figure, surfaceProperties, baseShapeImportConfiguration);

        return(new FigureDumper(fileLocator, objectLocator, device, shaderCache, parentFigure, figure, surfaceProperties, baseMaterialSetConfiguration, baseShapeImportConfiguration, shapeDumper));
    }
Ejemplo n.º 5
0
    public static float[] For(Figure figure)
    {
        var surfaceProperties = SurfacePropertiesJson.Load(figure);

        if (surfaceProperties.MaterialSetForOpacities != null)
        {
            var figureDir          = CommonPaths.WorkDir.Subdirectory("figures").Subdirectory(figure.Name);
            var materialSetDir     = figureDir.Subdirectory("material-sets").Subdirectory(surfaceProperties.MaterialSetForOpacities);
            var transparenciesFile = materialSetDir.File("face-transparencies.array");
            return(transparenciesFile.ReadArray <float>());
        }

        var surfaceMap = figure.Geometry.SurfaceMap;

        return(surfaceMap
               .Select(surfaceIdx => 1 - surfaceProperties.Opacities[surfaceIdx])
               .ToArray());
    }
Ejemplo n.º 6
0
    public static void DumpFigure(Figure figure)
    {
        DirectoryInfo figureDirectory = CommonPaths.WorkDir.Subdirectory("figures")
                                        .Subdirectory(figure.Name);

        var           surfaceProperties   = SurfacePropertiesJson.Load(figure);
        DirectoryInfo refinementDirectory = figureDirectory.Subdirectory("refinement").Subdirectory("level-" + surfaceProperties.SubdivisionLevel);

        Quad[] spatialFaces = refinementDirectory.File("faces.array").ReadArray <Quad>();
        SubdivisionTopologyInfo spatialTopologyInfo = Persistance.Load <SubdivisionTopologyInfo>(UnpackedArchiveFile.Make(refinementDirectory.File("topology-info.dat")));

        DirectoryInfo uvSetsDirectory = figureDirectory.Subdirectory("uv-sets");
        UVSetDumper   dumper          = new UVSetDumper(figure, surfaceProperties, uvSetsDirectory, spatialFaces, spatialTopologyInfo);

        foreach (var pair in figure.UvSets)
        {
            dumper.Dump(pair.Key, pair.Value);
        }
    }
Ejemplo n.º 7
0
    public void DumpAll()
    {
        var surfaceProperties = SurfacePropertiesJson.Load(figure);

        targetDirectory.CreateWithParents();
        Persistance.Save(targetDirectory.File("surface-properties.dat"), surfaceProperties);

        Dump("shaper-parameters.dat", () => figure.MakeShaperParameters(channelsToInclude));
        Dump("channel-system-recipe.dat", () => figure.MakeChannelSystemRecipe());

        if (figure.Parent == null)
        {
            ValidateBoneSystemAssumptions(figure);
            Dump("bone-system-recipe.dat", () => figure.MakeBoneSystemRecipe());
            Dump("inverter-parameters.dat", () => figure.MakeInverterParameters());
        }
        else
        {
            Dump("child-to-parent-bind-pose-transforms.dat", () => figure.ChildToParentBindPoseTransforms);
        }
    }
Ejemplo n.º 8
0
    public FaceTransparencyProcessor(Device device, ShaderCache shaderCache, Figure figure)
    {
        this.device = device;
        this.figure = figure;

        surfaceProperties  = SurfacePropertiesJson.Load(figure);
        faceCount          = figure.Geometry.Faces.Length;
        faceTransparencies = new float[faceCount];

        var vertexShaderAndBytecode = shaderCache.GetVertexShader <TextureMaskRenderer>("occlusion/facetransparency/TransparencyCounting");

        inputLayout  = new InputLayout(device, vertexShaderAndBytecode.Bytecode, MeshBuffers.InputElements);
        vertexShader = vertexShaderAndBytecode;

        addingPixelShader = shaderCache.GetPixelShader <TextureMaskRenderer>("occlusion/facetransparency/TransparencyCounting_Add");
        maxingPixelShader = shaderCache.GetPixelShader <TextureMaskRenderer>("occlusion/facetransparency/TransparencyCounting_Max");

        var statesDesc = StateDescriptions.Default();

        statesDesc.rasterizer.CullMode = CullMode.None;
        states = new States(device, statesDesc);
    }
Ejemplo n.º 9
0
    public FigureDumperLoader(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, ImporterPathManager pathManager, Device device, ShaderCache shaderCache)
    {
        this.fileLocator   = fileLocator;
        this.objectLocator = objectLocator;
        this.pathManager   = pathManager;
        this.device        = device;
        this.shaderCache   = shaderCache;

        figureRecipeLoader = new FigureRecipeLoader(objectLocator, pathManager);

        FigureRecipe      genesis3FemaleRecipe = figureRecipeLoader.LoadFigureRecipe("genesis-3-female", null);
        FigureRecipe      genitaliaRecipe      = figureRecipeLoader.LoadFigureRecipe("genesis-3-female-genitalia", genesis3FemaleRecipe);
        FigureRecipe      genesis3FemaleWithGenitaliaRecipe = new FigureRecipeMerger(genesis3FemaleRecipe, genitaliaRecipe).Merge();
        Figure            genesis3FemaleWithGenitalia       = genesis3FemaleWithGenitaliaRecipe.Bake(null);
        SurfaceProperties genesis3FemaleSurfaceProperties   = SurfacePropertiesJson.Load(pathManager, genesis3FemaleWithGenitalia);

        float[] genesis3FemaleFaceTransparencies = FaceTransparencies.For(genesis3FemaleWithGenitalia, genesis3FemaleSurfaceProperties, null);

        parentFigureRecipe       = genesis3FemaleRecipe;
        parentFigure             = genesis3FemaleWithGenitalia;
        parentFaceTransparencies = genesis3FemaleFaceTransparencies;
    }
    public void Run()
    {
        var loader = new FigureRecipeLoader(fileLocator, objectLocator, pathManager);

        FigureRecipe genesis3FemaleRecipe = loader.LoadFigureRecipe("genesis-3-female", null);
        FigureRecipe genitaliaRecipe      = loader.LoadFigureRecipe("genesis-3-female-genitalia", genesis3FemaleRecipe);
        FigureRecipe genesis3FemaleWithGenitaliaRecipe = new FigureRecipeMerger(genesis3FemaleRecipe, genitaliaRecipe).Merge();
        Figure       genesis3FemaleWithGenitalia       = genesis3FemaleWithGenitaliaRecipe.Bake(fileLocator, null);

        Figure parentFigure = genesis3FemaleWithGenitalia;

        FigureRecipe livHairRecipe = loader.LoadFigureRecipe("liv-hair", null);
        var          livHairFigure = livHairRecipe.Bake(fileLocator, parentFigure);

        var surfaceProperties = SurfacePropertiesJson.Load(pathManager, livHairFigure);
        var processor         = new FaceTransparencyProcessor(device, shaderCache, livHairFigure, surfaceProperties);

        for (int surfaceIdx = 0; surfaceIdx < livHairFigure.Geometry.SurfaceCount; ++surfaceIdx)
        {
            string surfaceName = livHairFigure.Geometry.SurfaceNames[surfaceIdx];

            FileInfo textureFile;
            if (surfaceName == "Hairband")
            {
                continue;
            }
            else if (surfaceName == "Cap")
            {
                textureFile = fileLocator.Locate("/Runtime/Textures/outoftouch/!hair/OOTHairblending2/Liv/OOTUtilityLivCapT.jpg").File;
            }
            else
            {
                textureFile = fileLocator.Locate("/Runtime/Textures/outoftouch/!hair/OOTHairblending2/Liv/OOTUtilityLivHairT.png").File;
            }

            RawFloatTexture opacityTexture = new RawFloatTexture {
                value = 1,
                image = new RawImageInfo {
                    file  = textureFile,
                    gamma = 1
                }
            };

            processor.ProcessSurface(surfaceIdx, livHairFigure.DefaultUvSet.Name, opacityTexture);
        }

        var transparencies = processor.FaceTransparencies;

        for (int i = 0; i < 10; ++i)
        {
            int    faceIdx     = i * 3000;
            int    surfaceIdx  = livHairFigure.Geometry.SurfaceMap[faceIdx];
            string surfaceName = livHairFigure.Geometry.SurfaceNames[surfaceIdx];

            var  uvSet = livHairFigure.DefaultUvSet;
            Quad face  = uvSet.Faces[faceIdx];

            Console.WriteLine("face {0}: ", faceIdx);
            Console.WriteLine("  transparency: " + transparencies[faceIdx]);
            Console.WriteLine("  surface: " + surfaceName);
            Console.WriteLine("  uv 0: {0}", uvSet.Uvs[face.Index0]);
            Console.WriteLine("  uv 1: {0}", uvSet.Uvs[face.Index1]);
            Console.WriteLine("  uv 2: {0}", uvSet.Uvs[face.Index2]);
            Console.WriteLine("  uv 3: {0}", uvSet.Uvs[face.Index3]);
            Console.WriteLine();
        }
        Console.WriteLine("min = " + transparencies.Min());
        Console.WriteLine("avg = " + transparencies.Average());
        Console.WriteLine("max = " + transparencies.Max());
    }