Пример #1
0
    private PackedLists <WeightedIndex> CalculateFormFactorsForColorComponent(
        ScatteringFormFactorCalculator formFactorCalculator,
        IMaterialSettings[] materialSettingsArray, int componentIdx)
    {
        var profiles = materialSettingsArray
                       .Select(baseMaterialSettings => {
            UberMaterialSettings materialSettings = baseMaterialSettings as UberMaterialSettings;
            if (materialSettings is null)
            {
                return(null);
            }

            if (materialSettings.thinWalled)
            {
                return(null);
            }

            var volumeSettings = new VolumeParameters(
                materialSettings.transmittedMeasurementDistance,
                materialSettings.transmittedColor[componentIdx],
                materialSettings.scatteringMeasurementDistance,
                materialSettings.sssAmount,
                materialSettings.sssDirection);
            ScatteringProfile profile = new ScatteringProfile(
                volumeSettings.SurfaceAlbedo,
                volumeSettings.MeanFreePathLength);
            return(profile);
        })
                       .ToArray();

        PackedLists <WeightedIndex> formFactors = formFactorCalculator.Calculate(profiles);

        return(formFactors);
    }
Пример #2
0
 public VolumeStrategy(
     ISearcher searcher,
     IStakingService stakingService,
     VolumeParameters parameters)
 {
     _searcher       = searcher;
     _stakingService = stakingService;
     _parameters     = parameters;
 }
Пример #3
0
        public void VolumeStrategyTest()
        {
            var data       = CreateMarketData();
            var parameters = new VolumeParameters();

            var target = SimulateStrategy(data, x => x.Create(parameters));
            var actual = ToApprovedString(target);

            Approvals.Verify(actual);
        }
Пример #4
0
        public void Optimise(DateTime fromDate, DateTime endDate)
        {
            _stakingService.Evaluate(fromDate, endDate);

            var potentials = Enumerable.Range(1, 800).Select(x =>
                                                             new VolumeParameters {
                Threshold = x
            });

            var optimum = _searcher.Maximum(potentials, fromDate, endDate);

            _parameters = (VolumeParameters)optimum;
        }
    public void TestSurfaceAlbedo()
    {
        //parameters from Eva 7 Torso surface
        double transmittedDistanceOfMeasurement = 0.3;
        double transmittedColor = 0.95f;
        double scatteringDistanceOfMeasurement = 0.12;
        double subSurfaceScatteringAmount      = 0.69;
        double subSurfaceScatteringDirection   = -0.650;

        var volumeParameters = new VolumeParameters(
            transmittedDistanceOfMeasurement,
            transmittedColor,
            scatteringDistanceOfMeasurement,
            subSurfaceScatteringAmount,
            subSurfaceScatteringDirection);

        Assert.AreEqual(0.75678f, volumeParameters.SurfaceAlbedo, 5e-6);
    }
Пример #6
0
 public IStrategy Create(IParameters parameters)
 {
     return(parameters switch
     {
         LinearRegressionParameters p => Create(p),
         RelativeStrengthParameters p => Create(p),
         DeltaParameters p => Create(p),
         VolumeParameters p => Create(p),
         GradientParameters p => Create(p),
         EntropyParameters p => Create(p),
         StaticDatesParameters p => Create(p),
         MovingAverageParameters p => Create(p),
         HolidayEffectParameters p => Create(p),
         WeightedParameters p => Create(p),
         OptimalStoppingParameters p => Create(p),
         ProbabilityParameters p => Create(p),
         SpreadParameters p => Create(p),
         ClusteringParameters p => Create(p),
         _ => throw new NotImplementedException(),
     });
    public static UberMaterial Load(Device device, ShaderCache shaderCache, TextureLoader textureLoader, UberMaterialSettings settings)
    {
        UberConstants constants;
        UberTextures  textures;

        //Base / Mixing
        constants.baseMixingMode = settings.baseMixing;

        //Base / Diffuse / Reflection
        SetFloatTexture(textureLoader, settings.metallicWeight, out constants.metallicWeight, out textures.metallicWeight);
        SetFloatTexture(textureLoader, settings.diffuseWeight, out constants.diffuseWeight, out textures.diffuseWeight);
        SetColorTexture(textureLoader, settings.baseColor, out constants.baseColor, out textures.baseColor);

        //Base / Diffuse Translucency
        SetFloatTexture(textureLoader, settings.translucencyWeight, out constants.translucencyWeight, out textures.translucencyWeight);
        constants.baseColorEffect = settings.baseColorEffect;
        SetColorTexture(textureLoader, settings.translucencyColor, out constants.translucencyColor, out textures.translucencyColor);
        constants.sssReflectanceTint = settings.sssReflectanceTint;

        //Base / Glossy / Reflection
        SetFloatTexture(textureLoader, settings.glossyWeight, out constants.glossyWeight, out textures.glossyWeight);
        SetFloatTexture(textureLoader, settings.glossyLayeredWeight, out constants.glossyLayeredWeight, out textures.glossyLayeredWeight);
        SetColorTexture(textureLoader, settings.glossyColor, out constants.glossyColor, out textures.glossyColor);
        constants.glossyColorEffect = settings.glossyColorEffect;
        SetColorTexture(textureLoader, settings.glossySpecular, out constants.glossySpecular, out textures.glossySpecular);
        SetFloatTexture(textureLoader, settings.glossiness, out constants.glossiness, out textures.glossiness);
        SetFloatTexture(textureLoader, settings.glossyReflectivity, out constants.glossyReflectivity, out textures.glossyReflectivity);
        SetFloatTexture(textureLoader, settings.glossyRoughness, out constants.glossyRoughness, out textures.glossyRoughness);

        //Base / Glossy / Refraction
        constants.refractionIndex = settings.refractionIndex;
        SetFloatTexture(textureLoader, settings.refractionWeight, out constants.refractionWeight, out textures.refractionWeight);

        //Base Bump
        SetBumpTexture(textureLoader, settings.bumpStrength, out constants.bumpStrength, out textures.bumpStrength);
        SetBumpTexture(textureLoader, settings.normalMap, out constants.normalMap, out textures.normalMap);

        // Top Coat
        SetFloatTexture(textureLoader, settings.topCoatWeight, out constants.topCoatWeight, out textures.topCoatWeight);
        SetColorTexture(textureLoader, settings.topCoatColor, out constants.topCoatColor, out textures.topCoatColor);
        constants.topCoatColorEffect = settings.topCoatColorEffect;
        SetFloatTexture(textureLoader, settings.topCoatRoughness, out constants.topCoatRoughness, out textures.topCoatRoughness);
        constants.topCoatLayeringMode = settings.topCoatLayeringMode;
        SetFloatTexture(textureLoader, settings.topCoatReflectivity, out constants.topCoatReflectivity, out textures.topCoatReflectivity);
        SetFloatTexture(textureLoader, settings.topCoatIor, out constants.topCoatIOR, out textures.topCoatIOR);
        SetFloatTexture(textureLoader, settings.topCoatCurveNormal, out constants.topCoatCurveNormal, out textures.topCoatCurveNormal);
        SetFloatTexture(textureLoader, settings.topCoatCurveGrazing, out constants.topCoatCurveGrazing, out textures.topCoatCurveGrazing);

        // Top Coat Bump
        SetBumpTexture(textureLoader, settings.topCoatBump, out constants.topCoatBump, out textures.topCoatBump);

        // Volume
        constants.thinWalled = settings.thinWalled ? 1 : 0;
        var volumeColor = Vector3.Zero;

        for (int colorComponent = 0; colorComponent < 3; ++colorComponent)
        {
            var volumeParameters = new VolumeParameters(
                settings.transmittedMeasurementDistance,
                settings.transmittedColor[colorComponent],
                settings.scatteringMeasurementDistance,
                settings.sssAmount,
                settings.sssDirection);
            volumeColor[colorComponent] = (float)volumeParameters.SurfaceAlbedo;
        }
        constants.volumeColor = volumeColor;

        // Geometry/Cutout
        SetFloatTexture(textureLoader, settings.cutoutOpacity, out constants.cutoutOpacity, out textures.cutoutOpacity);

        var constantBuffer = Buffer.Create(device, BindFlags.ConstantBuffer, ref constants, usage: ResourceUsage.Immutable);

        var defaultBumpTexture = textureLoader.Load(null, TextureLoader.DefaultMode.Bump);

        return(new UberMaterial(device, shaderCache, settings, constantBuffer, textures.ToArray(), defaultBumpTexture));
    }