/*void RunTest() * { * var lightPos = this.gbuffer.transform.position; * Debug.Log("LightPos " + lightPos); * * //var b = this.output[25]; * foreach (var b in this.output) * { * Debug.Log("pos in " + b.pos.ToString("F3")); * Debug.Log("normal " + b.normal.ToString("F3")); * Debug.Log("gpu refrect " + b.refrect.ToString("F3")); * * var input = (b.pos - lightPos).normalized; * var cos1 = Vector3.Dot(-input, b.normal); * var left = Mathf.Sqrt(1 - cos1 * cos1); * Debug.Log("Sin1 x 1 =" + left.ToString("F3")); * * var cos2 = Vector3.Dot(b.refrect.normalized, -b.normal); * var right = (Mathf.Sqrt(1 - cos2 * cos2) * 1.33f); * Debug.Log("Sin2 x 1.33 =" + right.ToString("F3")); * * //Verify Snell's law * if (cos1 > 0 && cos2 > 0) * { * Assert.IsTrue(Mathf.Approximately(left, right)); * } * } * }*/ // Update is called once per frame void Update() { if (this.kernalID != -1) { //this.refractionIndex = 1 / 1.33f; var lightPos = lightCamera.IsDirection() ? lightCamera.Direction():this.gbuffer.transform.position; this.cs.SetTexture(this.kernalID, "PosTex", this.gbuffer.GBuffer[0]); this.cs.SetTexture(this.kernalID, "NormalTex", this.gbuffer.GBuffer[1]); this.cs.SetVector("LightPos", lightPos); this.cs.SetVector("LightParamters", new Vector4(this.refractionIndex, lightCamera.IsDirection()?1:0, 0, 0)); this.cs.SetBuffer(this.kernalID, "Result", this.beamsBuffer); this.cs.Dispatch(this.kernalID, 1, 1, 1); this.beamsBuffer.GetData(this.output); } }