Пример #1
0
    public void UpdateSettings(CelestialBodyGenerator generator, Shader shader)
    {
        if (material == null || material.shader != shader)
        {
            material = new Material(shader);
        }

        if (light == null)
        {
            light = GameObject.FindObjectOfType <SunShadowCaster> ()?.GetComponent <Light> ();
        }

        Vector3 centre = generator.transform.position;
        float   radius = generator.GetOceanRadius();

        material.SetVector("oceanCentre", centre);
        material.SetFloat("oceanRadius", radius);

        material.SetFloat("planetScale", generator.BodyScale);
        if (light)
        {
            material.SetVector("dirToSun", -light.transform.forward);
        }
        else
        {
            material.SetVector("dirToSun", Vector3.up);
            Debug.Log("No SunShadowCaster found");
        }
        generator.body.shading.SetOceanProperties(material);
    }
Пример #2
0
    public override Material GetMaterial()
    {
        // Validate inputs
        if (material == null || material.shader != shader)
        {
            if (shader == null)
            {
                shader = Shader.Find("Unlit/Texture");
            }
            material = new Material(shader);
        }

        // Set
        Sphere sphere = new Sphere()
        {
            centre      = planet.transform.position,
            radius      = (1 + atmosphereScale) * planet.BodyScale,
            waterRadius = planet.GetOceanRadius()
        };

        buffer = new ComputeBuffer(1, Sphere.Size);
        buffer.SetData(new Sphere[] { sphere });
        material.SetBuffer("spheres", buffer);
        material.SetVector("params", testParams);
        material.SetColor("_Color", color);
        material.SetFloat("planetRadius", planet.BodyScale);

        CelestialBodyShading.TextureFromGradient(ref falloffTex, gradientRes, falloff);
        material.SetTexture("_Falloff", falloffTex);
        material.SetTexture("_BlueNoise", blueNoise);
        material.SetInt("numSteps", numSteps);
        return(material);
    }
Пример #3
0
    public void UpdateSettings(CelestialBodyGenerator generator)
    {
        Shader shader = generator.body.shading.atmosphereSettings.atmosphereShader;

        if (material == null || material.shader != shader)
        {
            material = new Material(shader);
        }

        if (light == null)
        {
            light = GameObject.FindObjectOfType <SunShadowCaster> ()?.GetComponent <Light> ();
        }

        //generator.shading.SetAtmosphereProperties (material);
        generator.body.shading.atmosphereSettings.SetProperties(material, generator.BodyScale);

        material.SetVector("planetCentre", generator.transform.position);
        //material.SetFloat ("atmosphereRadius", (1 + 0.5f) * generator.BodyScale);
        material.SetFloat("oceanRadius", generator.GetOceanRadius());

        if (light)
        {
            Vector3 dirFromPlanetToSun = (light.transform.position - generator.transform.position).normalized;
            //Debug.Log(dirFromPlanetToSun);
            material.SetVector("dirToSun", dirFromPlanetToSun);
        }
        else
        {
            material.SetVector("dirToSun", Vector3.up);
            Debug.Log("No SunShadowCaster found");
        }
    }