public virtual void UpdateMaterials(GraphicsDevice graphicsDevice, OceanComponent component, Material[] materials, WavesCascade[] cascades)
        {
            foreach (var material in materials)
            {
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Displacement_c0, cascades[0].Displacement);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Displacement_c1, cascades[1].Displacement);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Displacement_c2, cascades[2].Displacement);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Turbulence_c0, cascades[0].Turbulence);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Turbulence_c1, cascades[1].Turbulence);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Turbulence_c2, cascades[2].Turbulence);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Derivatives_c0, cascades[0].Derivatives);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Derivatives_c1, cascades[1].Derivatives);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Derivatives_c2, cascades[2].Derivatives);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.LengthScale0, component.LengthScale0);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.LengthScale1, component.LengthScale1);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.LengthScale2, component.LengthScale2);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.LodScale, LodScale);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.SSSBase, SSSBase);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.SSSScale, SSSScale);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.SSSStrength, SSSStrength);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.SSSColor, SSSColor);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.FoamBiasLOD0, FoamBiasLOD0);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.FoamBiasLOD1, FoamBiasLOD1);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.FoamBiasLOD2, FoamBiasLOD2);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.FoamScale, FoamScale);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.FoamColor, FoamColor);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.ContactFoam, ContactFoam);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.FoamTexture, FoamTexture);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Roughness, Roughness);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.RoughnessScale, RoughnessScale);
                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.MaxGloss, MaxGloss);

                material.Passes[0].Parameters.Set(OceanShadingCommonKeys.Color, Color);

                if (Sun != null)
                {
                    var lightDirection = Vector3.TransformNormal(-Vector3.UnitZ, Sun.Entity.Transform.WorldMatrix);
                    lightDirection.Normalize();

                    material.Passes[0].Parameters.Set(OceanShadingCommonKeys.LightDirectionWS, lightDirection);
                }
            }
        }
Example #2
0
 public void SetOcean(OceanComponent ocean, Material[] materials)
 {
     _ocean = ocean;
     _materials = materials;
     _isDirty = true;
 }