learn-raytracing icon indicating copy to clipboard operation
learn-raytracing copied to clipboard

float random( vec2 p )

Open vinjn opened this issue 11 years ago • 4 comments

// Input: It uses texture coords as the random number seed.
// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive.
// Author: Michael Pohoreski
// Copyright: Copyleft 2012 :-)

float random( vec2 p )
{
  // We need irrationals for pseudo randomness.
  // Most (all?) known transcendental numbers will (generally) work.
  const vec2 r = vec2(
    23.1406926327792690,  // e^pi (Gelfond's constant)
     2.6651441426902251); // 2^sqrt(2) (Gelfond–Schneider constant)
  return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) );  
}

vinjn avatar Jul 23 '13 09:07 vinjn

Hi, I find your repository interesting and would love to learn how you code it. Please try not to kill me if I ask any stupid questions. Haha.. :-) Here is one: The project uses OpenMP, however, I have not experience with that, should I read some tutorials of OpenMP and understand it before beginning to read your code, or I can just install OpenMP and let it go? Thanks.

IanZhang1990 avatar Jul 24 '13 03:07 IanZhang1990

OpenMP is a built-in feature of compiler, both gcc and msvc supports it. It's just an optional acceleration technique, you could just omit it.

Have fun. -Vinjn

vinjn avatar Jul 24 '13 03:07 vinjn

Guess I should download a VCOMP90.DLL file first, or the executable cannot run.

Thanks,

-Yinan

IanZhang1990 avatar Jul 24 '13 03:07 IanZhang1990

I have uploaded the dll now, pls sync again.

vinjn avatar Jul 24 '13 04:07 vinjn