Esempio n. 1
0
    // -- Upload light buffer to GPU
    void UploadLights()
    {
        if (lights.Length > 0)
        {
            int numLights = lights.Length;

            ptLight[] tempLights = new ptLight[numLights];

            for (int i = 0; i < numLights; i++)
            {
                tempLights[i] = lights[i].handledLight;
            }

            lightBuffer.SetData(tempLights);
            int kHandle = computeShader.FindKernel("CSMain");
            if (lightBuffer != null)
            {
                computeShader.SetBuffer(kHandle, "lights", lightBuffer);
            }
        }
    }
Esempio n. 2
0
    public ptLightHandler(Light a_light)
    {
        Vector3   color       = new Vector3(a_light.color.r, a_light.color.g, a_light.color.b);
        float     intensity   = a_light.intensity;
        float     range       = a_light.range;
        Matrix4x4 worldMatrix = a_light.transform.localToWorldMatrix;
        uint      lightType   = 0;

        switch (a_light.type)
        {
        case LightType.Point: lightType = (uint)ptLightType.POINT; break;

        case LightType.Directional: lightType = (uint)ptLightType.DIRECTIONAL; break;

        case LightType.Spot: lightType = (uint)ptLightType.SPOT; break;

        default: lightType = (uint)ptLightType.DIRECTIONAL; break;
        }

        lightRef     = a_light;
        handledLight = new ptLight(color, intensity, range, lightType, worldMatrix);
    }