聚光燈的衰減計算

https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.media.media3d.spotlight.innerconeangle?view=netcore-3.1
https://catlikecoding.com/unity/tutorials/custom-srp/point-and-spot-lights/

在這裏插入圖片描述

float spotAttenuation = Square(saturate(dot(_OtherLightDirections[index].xyz, light.direction) * spotAngles.x + spotAngles.y));
	void SetupSpotLight (int index, ref VisibleLight visibleLight) {
		…

		Light light = visibleLight.light;
		float innerCos = Mathf.Cos(Mathf.Deg2Rad * 0.5f * light.innerSpotAngle);
		float outerCos = Mathf.Cos(Mathf.Deg2Rad * 0.5f * visibleLight.spotAngle);
		float angleRangeInv = 1f / Mathf.Max(innerCos - outerCos, 0.001f);
		otherLightSpots[index] = new Vector4(angleRangeInv, -outerCos * angleRangeInv);
	}

why is not the inner angle stored in VisibleLight?

The configurable inner angle is a recent addition to Unity. The VisibleLight struct probably doesn't have it because it would change its size and require refactoring of Unity internal code.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章