sigtrapgames / VrTunnellingPro-Unity

Plug-and-play VR comfort for Unity.
http://www.sigtrapgames.com/vrtp/
MIT License
179 stars 21 forks source link

Some problems about calculating the parameter "r" in Tunnelling.shader #10

Closed a962097364 closed 2 years ago

a962097364 commented 2 years ago

Hello! I can't understand the process of calculate : float r = max(_Overlay, saturate((radius - fxMin) / (fxMax - fxMin))); I think (fxMax - fxMin) is the effectfeather which is set in TunnellingImageBase.cs, but why do this calculation "max(_Overlay, saturate((radius - fxMin) / (fxMax - fxMin)))" to control the central vision? I want use a value which is between 0~1 to control the central fov from zero to max, so I really need the relation between fx value and the r value. Thank you.

sigtrapgames commented 2 years ago

(fxMax - fxMin) is the feather, yes. The property _FxInner is the central FoV as a fraction of screen space. If _FxInner is 0 and feather is 0, the screen will be totally black.

The calculation is just an inverse lerp - it maps the radius value to the feather value.

_FxInner is set in TunnellingImageBase.cs line 506 - you should be able to trace that back to see how it's calculated.

_Overlay is set by effectOverlay on the Tunnelling component - if you're not using that you can ignore it.

a962097364 commented 2 years ago

Thank you!I will confirm it。