Exemplo n.º 1
0
        private void CreateProceduralTextureMods(int p, TextureUnitState t)
        {
            // Procedural mods
            // Custom - don't use mod if generating environment
            // Because I do env a different way it look horrible
            if (pass[p].texGen != ShaderTextureGen.Environment)
            {
                if (pass[p].tcModRotate != 0.0f)
                {
                    t.SetRotateAnimation(pass[p].tcModRotate);
                }

                if ((pass[p].tcModScroll[0] != 0.0f) || (pass[p].tcModScroll[1] != 0.0f))
                {
                    if (pass[p].tcModTurbOn)
                    {
                        // Turbulent scroll
                        if (pass[p].tcModScroll[0] != 0.0f)
                        {
                            t.SetTransformAnimation(TextureTransform.TranslateU, WaveformType.Sine,
                                                    pass[p].tcModTurb[0], pass[p].tcModTurb[3], pass[p].tcModTurb[2], pass[p].tcModTurb[1]);
                        }
                        if (pass[p].tcModScroll[1] != 0.0f)
                        {
                            t.SetTransformAnimation(TextureTransform.TranslateV, WaveformType.Sine,
                                                    pass[p].tcModTurb[0], pass[p].tcModTurb[3], pass[p].tcModTurb[2], pass[p].tcModTurb[1]);
                        }
                    }
                    else
                    {
                        // Constant scroll
                        t.SetScrollAnimation(pass[p].tcModScroll[0], pass[p].tcModScroll[1]);
                    }
                }

                if (pass[p].tcModStretchWave != ShaderWaveType.None)
                {
                    WaveformType wft = WaveformType.Sine;
                    switch (pass[p].tcModStretchWave)
                    {
                    case ShaderWaveType.Sin:
                        wft = WaveformType.Sine;
                        break;

                    case ShaderWaveType.Triangle:
                        wft = WaveformType.Triangle;
                        break;

                    case ShaderWaveType.Square:
                        wft = WaveformType.Square;
                        break;

                    case ShaderWaveType.SawTooth:
                        wft = WaveformType.Sawtooth;
                        break;

                    case ShaderWaveType.InverseSawtooth:
                        wft = WaveformType.InverseSawtooth;
                        break;
                    }

                    // Create wave-based stretcher
                    t.SetTransformAnimation(TextureTransform.ScaleU, wft, pass[p].tcModStretchParams[3],
                                            pass[p].tcModStretchParams[0], pass[p].tcModStretchParams[2], pass[p].tcModStretchParams[1]);
                    t.SetTransformAnimation(TextureTransform.ScaleV, wft, pass[p].tcModStretchParams[3],
                                            pass[p].tcModStretchParams[0], pass[p].tcModStretchParams[2], pass[p].tcModStretchParams[1]);
                }
            }
        }