Jump to content

  • Log In with Google      Sign In   
  • Create Account

Chimera 3D

Member Since 12 Jan 2011
Offline Last Active Apr 25 2015 03:10 PM

Posts I've Made

In Topic: Emulated Double Precision Subtraction & Division

09 April 2015 - 12:57 PM

Start by implementing normal exp function without exp.

Yeah, what is the best way to do this considering I only have addition, subtraction, and multiplication (and division for some constants) to work with, is my question.

EDIT: Nevermind I found an implementation of exactly what I needed here: http://andrewthall.org/papers/df64_qf128.pdf

In Topic: Emulated Double Precision Subtraction & Division

09 April 2015 - 12:18 AM

Apologies for bumping this thread but I have another question, how could I go about implementing an emulated double precision exp function?

In Topic: Emulated Double Precision Subtraction & Division

22 March 2015 - 07:13 PM

return dAdd(doubleA, vec2(-doubleB.x, doubleB.y);


Oh, yeah that is really simple, but why wouldn't the low part of doubleB also be negative?

In Topic: Atmospheric Scattering Errors

14 January 2015 - 02:49 PM

Since you're dividing muStart by startAlt and if the error only occurs when


muStart^2 - 1 < 0

muStart^2 < 1

muStart < 1


so maybe the problem is that startAlt is too large?

Also, in the square root function issue, what if you take the absolute value first? So it never receives a negative number.


Well I made the shader output muStart^2 (not at my computer atm so no screenshots) and it demonstrated similar behavior to the first image in the OP as muStart^2 starts out as white (near 1 or 1) towards the center of the planet and approaches 0 (black) towards the top atmosphere boundary then begins to approach 1 again from Rt out into space and after a certain distance (I'm guessing the startAlt), from either the center of the planet or the top atmosphere boundary, abruptly cuts off. So I'm pretty sure that's the ultimate cause of the repeating problem, still not sure why this isn't a problem in the original implementation as the computation of muStart and pretty much everything else is the same.

In Topic: Atmospheric Scattering Errors

13 January 2015 - 03:45 PM

After finally getting around to fixing the errors I tried adding this bit of code to check if the "surfacePos" was not above the top atmosphere boundary when doing the multiple scattering and it removed the secondary error described above.

  if(r0 < Rt){
	inscatter = max(inscatter - attenuation.rgbr * Texture4D(_Inscatter, r0, mu0, muS0, nu), 0.0);

I updated the code in the OP to reflect this change. As it turns out the atmosphere repeating error is not related to the other error shown in the last two screenshots, I haven't figured out exactly what's causing that yet. However if in the line:

float din = -startAlt * muStart - sqrt(startAlt * startAlt * (muStart * muStart - 1.0) + Rt * Rt);

I check if the input of the sqrt function is negative and if it is output a really large number it seems to fix the first problem.




But technically this isn't supposed to be necessary so I'm trying to figure why

startAlt * startAlt * (muStart * muStart - 1.0) + Rt * Rt < 0 if startAlt > Rt

and if muStart (assuming that this is the only value that could be negative if startAlt > Rt) being negative causes the repeat error.


After implementing the fix and sort-of-fix above I discovered some artifacts that seem to appear when viewing the atmosphere at a grazing angle (when the view direction [camera to surfacePos] is nearly perpendicular to the sun direction). Screens below. 




Anybody know what could be causing this? Anyhow I'll post my final code once I get everything else resolved.


EDIT: Quickly realized that muStart being negative or positive doesn't matter so I guess only if muStart^2 -1 < 0 then that produces the error.