Ejemplo n.º 1
0
    void Awake()
    {
        camera = GetComponent <Camera>();
        camera.depthTextureMode = DepthTextureMode.Depth;

        width       = 160;
        height      = 90;
        volumeDepth = 128;

        lightShadow = sunLight.GetComponent <LightShadow>();
        lightShadow.setVolumetricFog(this);

        lighting                   = new RenderTexture(width, height, 0, RenderTextureFormat.ARGBHalf);
        lighting.useMipMap         = true;
        lighting.dimension         = TextureDimension.Tex3D;
        lighting.volumeDepth       = volumeDepth;
        lighting.filterMode        = FilterMode.Trilinear;
        lighting.enableRandomWrite = true;
        lighting.Create();

        fog                   = new RenderTexture(width, height, 0, RenderTextureFormat.ARGBHalf);
        fog.useMipMap         = true;
        fog.dimension         = TextureDimension.Tex3D;
        fog.volumeDepth       = volumeDepth;
        fog.filterMode        = FilterMode.Trilinear;
        fog.enableRandomWrite = true;
        fog.Create();

        cascadeDepth = new float[] {
            camera.nearClipPlane,
            30.0f
        };

        lights = (Light[])GameObject.FindObjectsOfType(typeof(Light));
    }
Ejemplo n.º 2
0
 public LightParam(LightShadow lightShadow, Light light)
 {
     pos       = light.transform.position;
     dir       = light.transform.forward;
     mat       = lightShadow.getLightMatrix();
     angle     = light.spotAngle;
     intensity = light.intensity;
     color     = new Vector3(light.color.r, light.color.g, light.color.b);
     type      = (int)light.type;
 }