convert values stored in texDepth back to actual distance
- Author
- Message
-
Offline
- Posts: 14
- Joined: 07 Jan 2013, 11:51
convert values stored in texDepth back to actual distance
Just wondering how since there is no documentation about the formula used to convert distance to color values.
-
Offline
- *blah-blah-blah maniac*
- Posts: 17559
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: convert values stored in texDepth back to actual distanc
There is no math for that, because camera near and far planes distances are not available in shader. The only thing you may use is convert data to linear space like this
result=depth/(max(1.0-depth, 0.000000001));
result=depth/(max(1.0-depth, 0.000000001));
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- Posts: 14
- Joined: 07 Jan 2013, 11:51
Re: convert values stored in texDepth back to actual distanc
So the raw data is converted to the range of 0.0 to 1.0 with the formula f(x) = x/(x+c) (c is the curve) instead of clamping it to a maximum and minimum value (of b and a in the following formula) and linearly mapped to 0 to 1 like (x-a)/(b-a)?ENBSeries wrote:There is no math for that, because camera near and far planes distances are not available in shader. The only thing you may use is convert data to linear space like this
result=depth/(max(1.0-depth, 0.000000001));
-
Offline
- *blah-blah-blah maniac*
- Posts: 17559
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: convert values stored in texDepth back to actual distanc
Depth is in range 0..1, but linear result is not. I never thought how to map to 0..1 range without forcing limits.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- Posts: 14
- Joined: 07 Jan 2013, 11:51
Re: convert values stored in texDepth back to actual distanc
lim x->inf (x/(x+c)) should be equal to 1, where c is a constant, and it crosses the origin as well
so it does map any distance to the range 0 to 1.
And the inverse is c*x/(1-x) which is what you gave me. ( I didn't think of this before you gave me the formula so thanks a lot for that )
A higher value of c should map higher input value better to that range because then the slope is not as steep and there is less rounding errors for higher distances.
Is there a way to debug with the enb plugin? I want to know what sort of values are going in and out.
Thanks.
so it does map any distance to the range 0 to 1.
And the inverse is c*x/(1-x) which is what you gave me. ( I didn't think of this before you gave me the formula so thanks a lot for that )
A higher value of c should map higher input value better to that range because then the slope is not as steep and there is less rounding errors for higher distances.
Is there a way to debug with the enb plugin? I want to know what sort of values are going in and out.
Thanks.
-
Offline
- *blah-blah-blah maniac*
- Posts: 17559
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: convert values stored in texDepth back to actual distanc
Depth passed to external shaders are already in range 0..1, but non linear.
Debugging not available, almost don't have in debug build of the mod, don't need it actually.
Debugging not available, almost don't have in debug build of the mod, don't need it actually.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7