Exemplo n.º 1
0
        private void Simulate(int expiry, int tenor)
        {
            var accumulateSum = new DenseVector[tenor + 1];

            for (int i = 0; i < tenor + 1; i++)
            {
                accumulateSum[i] = new DenseVector(_param.NumberOfFactors);
            }
            for (int i = 0; i < expiry; i++)
            {
                var bm = BrownianMotion.BMStep(0.25, _param.NumberOfFactors);
                accumulateSum[i].Clear();
                for (int j = i + 1; j < tenor + 1; j++)
                {
                    double temp = System.Math.Max(0, System.Math.Min(1, _v[i][j] / _discount[i][j]));
                    accumulateSum[j] = accumulateSum[j - 1] + temp * _xi[i].RowD(j - i - 1);//accumulateSum[j - 1] + temp * _xi[i][j - i - 1, Range.All];
                }
                for (int j = tenor; j > i; j--)
                {
                    var vol = _xi[i].RowD(j - i - 1) - accumulateSum[j]; //_xi[i][j - i - 1, Range.All] - accumulateSum[j];
                    _v[i + 1][j] = _v[i][j] * System.Math.Exp(vol * bm - 0.5 * (vol * vol) * 0.25);
                    if (j < tenor)
                    {
                        _discount[i + 1][j] = _discount[i + 1][j + 1] * (1 - 0.25 * _shift[j]) + _v[i + 1][j];
                    }
                    else
                    {
                        _discount[i + 1][j] = _v[i + 1][j];
                    }
                }
            }
        }
Exemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        slowMo                  = GetComponent <SlowMotionCamera>();
        browianMotion           = GetComponent <BrownianMotion>();
        browianInitialFrequency = browianMotion.positionFrequency;

        GlobalVariables.Instance.OnEndMode += () => positionOnPause = Vector3.zero;
        GlobalVariables.Instance.OnMenu    += () => positionOnPause = Vector3.zero;
    }
    // Use this for initialization
    void Start()
    {
        postProcessProfile = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PostProcessingBehaviour>().profile;
        bloom            = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Bloom>();
        distorsion       = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <LensDistortionBlur>();
        rgbSplit         = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <RGBSplit>();
        slowMoVignetting = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <ContrastVignette>();
        bcgScript        = FindObjectOfType <BrightnessContrastGamma>();
        slowmoScript     = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <SlowMotionCamera>();
        browianMotion    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <BrownianMotion>();

        //Video
        brightnessSlider.onValueChanged.AddListener(Brightness);
        contrastSlider.onValueChanged.AddListener(Contrast);
        gammaSlider.onValueChanged.AddListener(Gamma);

        //Advanced
        antialiasingSlider.onValueChanged.AddListener(AntiAliasing);
        bloomSlider.onValueChanged.AddListener(Bloom);
        shadowsSlider.onValueChanged.AddListener(Shadows);

        ambiantOcclusionToggle.onValueChanged.AddListener((bool arg0) =>
        {
            postProcessProfile.ambientOcclusion.enabled = arg0;
            EnableApplyButton();
        });
        blurToggle.onValueChanged.AddListener((bool arg0) =>
        {
            postProcessProfile.motionBlur.enabled = arg0;
            EnableApplyButton();
        });
        grainToggle.onValueChanged.AddListener((bool arg0) =>
        {
            postProcessProfile.grain.enabled = arg0;
            EnableApplyButton();
        });
        vignettingToggle.onValueChanged.AddListener((bool arg0) =>
        {
            postProcessProfile.vignette.enabled = arg0;
            EnableApplyButton();
        });

        cameraMotionToggle.onValueChanged.AddListener((bool arg0) =>
        {
            browianMotion.enabled = arg0;
            browianMotionEnabled  = arg0;

            if (!arg0 && MenuManager.Instance.currentMenu != null)
            {
                GlobalVariables.Instance.menuCameraMovement.MenuPositionGraphics();
            }

            if (arg0)
            {
                GlobalVariables.Instance.menuCameraMovement.EnableBrowianMotion();
            }

            EnableApplyButton();
        });
        rgbToggle.onValueChanged.AddListener((bool arg0) =>
        {
            rgbSplit.enabled = arg0;
            EnableApplyButton();
        });
        distorsionToggle.onValueChanged.AddListener((bool arg0) =>
        {
            distorsion.enabled = arg0;
            EnableApplyButton();
        });
        slowMoVignettingToggle.onValueChanged.AddListener((bool arg0) =>
        {
            slowMoVignetting.enabled = arg0;
            EnableApplyButton();
        });


        if (PlayerPrefs.HasKey("QualityLevel"))
        {
            LoadData();
        }
        else
        {
            Reset();
            ResetAdvanced();
        }

        SaveData();

        applyButton.SetActive(false);
        apply = true;
    }
Exemplo n.º 4
0
    public static void genNoise(int channelId)
    {
        moduleBase[channelId] = new Perlin();
        if (teNoiseChanTypeIndex[channelId] == 1)
        {
            int tIdx = teNoiseTypeIndex[channelId];
            if (tIdx == 0) { moduleBase[channelId] = new Perlin(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 1) { moduleBase[channelId] = new Billow(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 2) { moduleBase[channelId] = new RidgedMultifractal(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 3) { moduleBase[channelId] = new Voronoi(frequency[channelId], displacement[channelId], seed[channelId], distance[channelId]); }
            if (tIdx == 4) { moduleBase[channelId] = new BrownianMotion(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 5) { moduleBase[channelId] = new HeterogeneousMultiFractal(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], QualityMode.High); }
            if (tIdx == 6) { moduleBase[channelId] = new HybridMulti(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], gain[channelId], QualityMode.High); }
            if (tIdx == 7) { moduleBase[channelId] = new LinearGradientNoise(frequency[channelId]); }
        }
        if (teNoiseChanTypeIndex[channelId] == 2)
        {
            int fIdx = teFunctionTypeIndex[channelId];
            if (fIdx == 0) { moduleBase[channelId] = new Add(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 1) { moduleBase[channelId] = new Subtract(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 2) { moduleBase[channelId] = new Multiply(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 3) { moduleBase[channelId] = new Min(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 4) { moduleBase[channelId] = new Max(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 5) { moduleBase[channelId] = new Blend(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); }
            if (fIdx == 6) { moduleBase[channelId] = new Clamp((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 7) { moduleBase[channelId] = new Power(moduleBase[srcChannel1Id[channelId]],moduleBase[srcChannel2Id[channelId]]);}
			if (fIdx == 8) { Curve tmpCurve = new Curve(moduleBase[srcChannel1Id[channelId]]);
				double adjust = double.Parse((controlpointcount[channelId]-1).ToString())*0.5;
				for(int i=0;i<controlpointcount[channelId];i++){
					tmpCurve.Add(double.Parse(i.ToString())-adjust,(double)cpval[channelId,i]);
					moduleBase[channelId] = tmpCurve;
				}
			}
			if(fIdx==9){Terrace tmpTerrace = new Terrace(invertTerrace[channelId],moduleBase[srcChannel1Id[channelId]]);
				for(int i=0;i<controlpointcount[channelId];i++){
					tmpTerrace.Add((double)cpval[channelId,i]-0.5);
					moduleBase[channelId] = tmpTerrace;
				}
			}
            if (fIdx == 18) { moduleBase[channelId] = new Mask(moduleBase[srcChannel1Id[channelId]], (double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId]); }
            if (fIdx == 17) { moduleBase[channelId] = new WindexWarp(moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 16) { moduleBase[channelId] = new TEWarp(moduleBase[srcChannel1Id[channelId]]); }
            if (fIdx == 15) { moduleBase[channelId] = new Select((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], falloff[channelId], moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); }
			if (fIdx == 14) { moduleBase[channelId] = new Turbulence(power[channelId],moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 13) { moduleBase[channelId] = new ScaleBias(scale[channelId],bias[channelId],moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 12) { moduleBase[channelId] = new Invert(moduleBase[srcChannel1Id[channelId]]);}
			if (fIdx == 11) { moduleBase[channelId] = new Exponent(exponent[channelId],moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 10) { moduleBase[channelId] = new Abs(moduleBase[srcChannel1Id[channelId]]);}
		}
        int resolution = 64;
        int xoffset = 0; int yoffset = 0;
        m_noiseMap[channelId] = new Noise2D(resolution, resolution, moduleBase[channelId]);
        float x1 = xoffset * zoom[channelId];
        float x2 = (xoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1));
        float y1 = -yoffset * zoom[channelId];
        float y2 = (-yoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1));
        m_noiseMap[channelId].GeneratePlanar(x1, x2, y1, y2);
        m_textures[channelId] = m_noiseMap[channelId].GetTexture();
        m_textures[channelId].Apply();
    }