Пример #1
0
        /// <summary>
        /// Set ParticleSystem rotationBySpeed field value.
        /// </summary>
        /// <param name="particleSystem"></param>
        /// <param name="vgoModule"></param>
        protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_RotationBySpeedModule vgoModule)
        {
            if (vgoModule == null)
            {
                return;
            }

            RotationBySpeedModule module = particleSystem.rotationBySpeed;

            module.enabled      = vgoModule.enabled;
            module.separateAxes = vgoModule.separateAxes;

            if (vgoModule.separateAxes)
            {
                module.x           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.x);
                module.y           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.y);
                module.z           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.z);
                module.xMultiplier = vgoModule.xMultiplier;
                module.yMultiplier = vgoModule.yMultiplier;
                module.zMultiplier = vgoModule.zMultiplier;
            }
            else
            {
                module.x           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.x);
                module.xMultiplier = vgoModule.xMultiplier;
            }

            module.range = ArrayConverter.ToVector2(vgoModule.range);
        }
Пример #2
0
        /// <summary>
        /// Set ParticleSystem colorOverLifetime field value.
        /// </summary>
        /// <param name="particleSystem"></param>
        /// <param name="vgoModule"></param>
        protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_ColorBySpeedModule vgoModule)
        {
            if (vgoModule == null)
            {
                return;
            }

            ColorBySpeedModule module = particleSystem.colorBySpeed;

            module.enabled = vgoModule.enabled;
            module.color   = VgoParticleSystemMinMaxGradientConverter.CreateMinMaxGradient(vgoModule.color);
            module.range   = ArrayConverter.ToVector2(vgoModule.range);
        }
Пример #3
0
        /// <summary>
        /// Set Light parameter.
        /// </summary>
        /// <param name="light"></param>
        /// <param name="vgoLight"></param>
        public static void SetComponentValue(Light light, VGO_Light vgoLight)
        {
            if (light == null)
            {
                return;
            }

            if (vgoLight == null)
            {
                return;
            }

            switch (vgoLight.type)
            {
            case LightType.Spot:
            case LightType.Directional:
            case LightType.Point:
            case LightType.Rectangle:
            case LightType.Disc:
                break;

            default:
                return;
            }

            light.enabled         = vgoLight.enabled;
            light.type            = vgoLight.type;
            light.color           = ArrayConverter.ToColor(vgoLight.color, gamma: true);
            light.intensity       = vgoLight.intensity;
            light.bounceIntensity = vgoLight.bounceIntensity;
            light.renderMode      = vgoLight.renderMode;
            light.cullingMask     = vgoLight.cullingMask;

#if UNITY_EDITOR
            light.lightmapBakeType = vgoLight.lightmapBakeType;
#endif

            switch (vgoLight.type)
            {
            case LightType.Spot:
                light.shape     = vgoLight.shape;
                light.range     = vgoLight.range;
                light.spotAngle = vgoLight.spotAngle;
                break;

            case LightType.Point:
                light.range = vgoLight.range;
                break;

#if UNITY_EDITOR
            case LightType.Rectangle:
                light.areaSize = ArrayConverter.ToVector2(vgoLight.areaSize);
                break;

            case LightType.Disc:
                light.areaSize = new Vector2(vgoLight.areaRadius, 1.0f);
                break;
#endif
            default:
                break;
            }

            light.shadows = vgoLight.shadows;

#if UNITY_EDITOR
            // Baked Shadows
            if ((vgoLight.lightmapBakeType == LightmapBakeType.Baked) ||
                (vgoLight.lightmapBakeType == LightmapBakeType.Mixed))
            {
                if (vgoLight.shadows == LightShadows.Soft)
                {
                    switch (vgoLight.type)
                    {
                    case LightType.Spot:
                    case LightType.Point:
                        light.shadowRadius = vgoLight.shadowRadius;
                        break;

                    case LightType.Directional:
                        light.shadowAngle = vgoLight.shadowAngle;
                        break;

                    default:
                        break;
                    }
                }
            }
#endif
            // Realtime Shadows
            if ((vgoLight.lightmapBakeType == LightmapBakeType.Realtime) ||
                (vgoLight.lightmapBakeType == LightmapBakeType.Mixed))
            {
                if ((vgoLight.type == LightType.Directional) ||
                    (vgoLight.type == LightType.Point))
                {
                    light.shadowStrength   = vgoLight.shadowStrength;
                    light.shadowResolution = vgoLight.shadowResolution;
                    light.shadowBias       = vgoLight.shadowBias;
                    light.shadowNormalBias = vgoLight.shadowNormalBias;
                    light.shadowNearPlane  = vgoLight.shadowNearPlane;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Create a MToon definition.
        /// </summary>
        /// <param name="mtoon"></param>
        /// <returns></returns>
        protected virtual MToonDefinition CreateMtoonDefinition(VRMC_materials_mtoon mtoon)
        {
            MToonDefinition mtoonDefinition = new MToonDefinition();

            // Meta
            mtoonDefinition.Meta = new MetaDefinition()
            {
                VersionNumber  = MToon.Utils.VersionNumber,
                Implementation = MToon.Utils.Implementation,
            };

            // Rendering
            mtoonDefinition.Rendering = new RenderingDefinition()
            {
                RenderMode = (MToon.RenderMode)mtoon.renderMode,
                CullMode   = (MToon.CullMode)mtoon.cullMode,
                RenderQueueOffsetNumber = mtoon.renderQueueOffsetNumber,
            };

            // Color
            mtoonDefinition.Color = new ColorDefinition()
            {
                LitColor             = ArrayConverter.ToColor(mtoon.litFactor, gamma: true),
                LitMultiplyTexture   = GetTexture(MToon.Utils.PropMainTex, mtoon.litMultiplyTexture),
                ShadeColor           = ArrayConverter.ToColor(mtoon.shadeFactor, gamma: true),
                ShadeMultiplyTexture = GetTexture(MToon.Utils.PropShadeTexture, mtoon.shadeMultiplyTexture),
                CutoutThresholdValue = mtoon.cutoutThresholdFactor,
            };

            // Lighting
            mtoonDefinition.Lighting = new LightingDefinition();
            mtoonDefinition.Lighting.LitAndShadeMixing = new LitAndShadeMixingDefinition()
            {
                ShadingShiftValue                          = mtoon.shadingShiftFactor,
                ShadingToonyValue                          = mtoon.shadingToonyFactor,
                ShadowReceiveMultiplierValue               = mtoon.shadowReceiveMultiplierFactor,
                ShadowReceiveMultiplierMultiplyTexture     = GetTexture(MToon.Utils.PropReceiveShadowTexture, mtoon.shadowReceiveMultiplierMultiplyTexture),
                LitAndShadeMixingMultiplierValue           = mtoon.litAndShadeMixingMultiplierFactor,
                LitAndShadeMixingMultiplierMultiplyTexture = GetTexture(MToon.Utils.PropShadingGradeTexture, mtoon.litAndShadeMixingMultiplierMultiplyTexture),
            };
            mtoonDefinition.Lighting.LightingInfluence = new LightingInfluenceDefinition()
            {
                LightColorAttenuationValue = mtoon.lightColorAttenuationFactor,
                GiIntensityValue           = mtoon.giIntensityFactor,
            };
            mtoonDefinition.Lighting.Normal = new NormalDefinition()
            {
                NormalTexture    = GetTexture(MToon.Utils.PropBumpMap, mtoon.normalTexture),
                NormalScaleValue = mtoon.normalScaleFactor,
            };

            // Emission
            mtoonDefinition.Emission = new EmissionDefinition()
            {
                EmissionColor           = ArrayConverter.ToColor(mtoon.emissionFactor, gamma: true),
                EmissionMultiplyTexture = GetTexture(MToon.Utils.PropEmissionMap, mtoon.emissionMultiplyTexture),
            };

            // MatCap
            mtoonDefinition.MatCap = new MatCapDefinition()
            {
                AdditiveTexture = GetTexture(MToon.Utils.PropSphereAdd, mtoon.additiveTexture),
            };

            // Rim
            mtoonDefinition.Rim = new RimDefinition()
            {
                RimColor             = ArrayConverter.ToColor(mtoon.rimFactor, gamma: true),
                RimMultiplyTexture   = GetTexture(MToon.Utils.PropRimTexture, mtoon.rimMultiplyTexture),
                RimLightingMixValue  = mtoon.rimLightingMixFactor,
                RimFresnelPowerValue = mtoon.rimFresnelPowerFactor,
                RimLiftValue         = mtoon.rimLiftFactor,
            };

            // Outline
            mtoonDefinition.Outline = new OutlineDefinition()
            {
                OutlineWidthMode              = (MToon.OutlineWidthMode)mtoon.outlineWidthMode,
                OutlineWidthValue             = mtoon.outlineWidthFactor,
                OutlineWidthMultiplyTexture   = GetTexture(MToon.Utils.PropOutlineWidthTexture, mtoon.outlineWidthMultiplyTexture),
                OutlineScaledMaxDistanceValue = mtoon.outlineScaledMaxDistanceFactor,
                OutlineColorMode              = (MToon.OutlineColorMode)mtoon.outlineColorMode,
                OutlineColor            = ArrayConverter.ToColor(mtoon.outlineFactor, gamma: true),
                OutlineLightingMixValue = mtoon.outlineLightingMixFactor,
            };

            // Texture Option
            mtoonDefinition.TextureOption = new TextureUvCoordsDefinition()
            {
                MainTextureLeftBottomOriginScale  = ArrayConverter.ToVector2(mtoon.mainTextureLeftBottomOriginScale),
                MainTextureLeftBottomOriginOffset = ArrayConverter.ToVector2(mtoon.mainTextureLeftBottomOriginOffset),
                UvAnimationMaskTexture            = GetTexture(MToon.Utils.PropUvAnimMaskTexture, mtoon.uvAnimationMaskTexture),
                UvAnimationScrollXSpeedValue      = mtoon.uvAnimationScrollXSpeedFactor,
                UvAnimationScrollYSpeedValue      = mtoon.uvAnimationScrollYSpeedFactor,
                UvAnimationRotationSpeedValue     = mtoon.uvAnimationRotationSpeedFactor,
            };

            return(mtoonDefinition);
        }
Пример #5
0
        /// <summary>
        /// Set ParticleSystem main field value.
        /// </summary>
        /// <param name="particleSystem"></param>
        /// <param name="vgoModule"></param>
        protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_MainModule vgoModule)
        {
            if (vgoModule == null)
            {
                return;
            }

            MainModule module = particleSystem.main;

            // @notice
            if (Application.isPlaying == false)
            {
                module.duration = vgoModule.duration;
            }

            module.loop                    = vgoModule.loop;
            module.prewarm                 = vgoModule.prewarm;
            module.startDelay              = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startDelay);
            module.startDelayMultiplier    = vgoModule.startDelayMultiplier;
            module.startLifetime           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startLifetime);
            module.startLifetimeMultiplier = vgoModule.startLifetimeMultiplier;
            module.startSpeed              = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSpeed);
            module.startSpeedMultiplier    = vgoModule.startSpeedMultiplier;

            module.startSize3D = vgoModule.startSize3D;

            if (vgoModule.startSize3D)
            {
                module.startSizeX           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeX);
                module.startSizeY           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeY);
                module.startSizeZ           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeZ);
                module.startSizeXMultiplier = vgoModule.startSizeXMultiplier;
                module.startSizeYMultiplier = vgoModule.startSizeYMultiplier;
                module.startSizeZMultiplier = vgoModule.startSizeZMultiplier;
            }
            else
            {
                module.startSize           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSize);
                module.startSizeMultiplier = vgoModule.startSizeMultiplier;
            }

            module.startRotation3D = vgoModule.startRotation3D;

            if (vgoModule.startRotation3D)
            {
                module.startRotationX           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationX);
                module.startRotationY           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationY);
                module.startRotationZ           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationZ);
                module.startRotationXMultiplier = vgoModule.StartRotationXMultiplier;
                module.startRotationYMultiplier = vgoModule.StartRotationYMultiplier;
                module.startRotationZMultiplier = vgoModule.StartRotationZMultiplier;
            }
            else
            {
                module.startRotation           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotation);
                module.startRotationMultiplier = vgoModule.StartRotationMultiplier;
            }

            module.flipRotation              = vgoModule.flipRotation;
            module.startColor                = VgoParticleSystemMinMaxGradientConverter.CreateMinMaxGradient(vgoModule.startColor);
            module.gravityModifier           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.gravityModifier);
            module.gravityModifierMultiplier = vgoModule.gravityModifierMultiplier;

            module.simulationSpace = vgoModule.simulationSpace;
            module.simulationSpeed = vgoModule.simulationSpeed;
            VgoTransformConverter.SetComponentValue(module.customSimulationSpace, vgoModule.customSimulationSpace);

            module.useUnscaledTime     = vgoModule.useUnscaledTime;
            module.scalingMode         = vgoModule.scalingMode;
            module.playOnAwake         = vgoModule.playOnAwake;
            module.emitterVelocityMode = vgoModule.emitterVelocityMode;
            module.maxParticles        = vgoModule.maxParticles;
            module.stopAction          = vgoModule.stopAction;
            module.cullingMode         = vgoModule.cullingMode;
            module.ringBufferMode      = vgoModule.ringBufferMode;

            if (vgoModule.ringBufferMode == ParticleSystemRingBufferMode.LoopUntilReplaced)
            {
                module.ringBufferLoopRange = ArrayConverter.ToVector2(vgoModule.ringBufferLoopRange);
            }
        }