 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> LPC might be a little different, but can't you negate a variable by saying
> a=-a;? Saves a little CPU cost.
I think he would have to define the unary minus operator for the vector
class before he could write -n instead of n*-1.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Vincent Le Chevalier
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 08:58:32
Message: <4b4f2308@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible wrote:
> Vincent Le Chevalier wrote:
>
>> if (++depth>5) {if (erand48(Xi)<p) f=f*(1/p); else return obj.e;}
>
> Ouch. This isn't going to be pretty...
What do you mean?
> Clearly it flips a coin to decide whether to process further [all of the
> code paths beyond this point involve sending out a new ray] or just stop
> here. However, "f" is the object colour, and I have absolutely no idea
> why it's being scaled by the reciprocol of the brightest component...
I think that it's the part that makes the method unbiased. You have to
scale the rays that you keep in order to account for the fact that you
don't keep them all, or something like that.
--
Vincent
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> if (++depth>5) {if (erand48(Xi)<p) f=f*(1/p); else return obj.e;}
>>
>> Ouch. This isn't going to be pretty...
>
> What do you mean?
I mean implementing this in a language where the else-part is
*mandatory* for all if-blocks makes this slightly tricky to do. (But not
as tricky as I thought; I've found a clean way to do it.)
>> However, "f" is the object colour, and I have
>> absolutely no idea why it's being scaled by the reciprocol of the
>> brightest component...
>
> I think that it's the part that makes the method unbiased. You have to
> scale the rays that you keep in order to account for the fact that you
> don't keep them all, or something like that.
Well, we'll see I guess...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> nemesis wrote:
>
>> yes. I wonder how it'd look like in Haskell. ;)
>
> In any language, I suspect the answer will depend on:
>
> - Which libraries are you allowed to use? [Get a ray tracing library and
> the program surely becomes trivial...]
>
> - How fast does it have to be? [A highly-efficient program is likely to
> be a lot bigger than a program written specifically to demonstrate how
> terse you can be.]
That's what I'm willing to know. That piece of code is not using a
"raytracing library", just implementing algorithms from well-known papers.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 11:33:41
Message: <4b4f4765@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> yes. I wonder how it'd look like in Haskell. ;)
I had a go at implementing this, but I have clearly screwed up the math
somewhere, because the program is behaving very strangely.
(I've turned off all the fancy stuff until it's just a normal depth-1
ray tracer, and the image still just consists of a few bent lines.)
So far I've found at least a dozen bugs in the ray/intersection code, a
typo in the cross-product (typed an X instead of a Z), and I'm still
finding more. What can I say? I fail at math! o_O
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> nemesis wrote:
>
>> yes. I wonder how it'd look like in Haskell. ;)
>
> I had a go at implementing this, but I have clearly screwed up the math
> somewhere, because the program is behaving very strangely.
>
> (I've turned off all the fancy stuff until it's just a normal depth-1
> ray tracer, and the image still just consists of a few bent lines.)
>
> So far I've found at least a dozen bugs in the ray/intersection code, a
> typo in the cross-product (typed an X instead of a Z), and I'm still
> finding more. What can I say? I fail at math! o_O
perhaps you just fail at translating crazy C++ code, which is perfectly
fine.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Vincent Le Chevalier
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 12:24:05
Message: <4b4f5335$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> perhaps you just fail at translating crazy C++ code, which is perfectly
> fine.
I don't find it really crazy, actually I was expecting far worse before
opening the file...
It uses some tricks to achieve compactness but it's still mostly
legible. I've seen far worse as far as variables names are concerned,
for instance :-\
--
Vincent
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Vincent Le Chevalier wrote:
> I don't find it really crazy, actually I was expecting far worse before
> opening the file...
Me too, honestly. You can see what it's doing, and you could probably
translate it by hand into some other OO imperative language without even
knowing what it's trying to do. It's not obfuscated as much as terse.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible wrote:
> 44: double n=sizeof(spheres)/sizeof(Sphere);
>
> Well... that's... one way to figure out how big an array is. :-.
That's the usual way to figure out how big an array is in C and C++.
> Evidently my C++ is weak, but... how is
> 53: Vec nl=n.dot(r.d)<0?n:n*-1;
> different from "nl = -abs(n.dot(r.d))"?
In the lack of needing to define the abs() function?
> Also, where THE HELL is "Xi" defined? I can see it *used* in several
> places, but I can't find a definitions.
Line 48. It's an argument to the function. Note that text search will
usually answer that sort of question on a C program, and often on a C++
program too.
Not always, mind, but usually.
> Line 79 means each row of pixels is computed in parallel, right?
Got me. It looks like someone is asking the compiler to do that if it can.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Nicolas Alvarez
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 14:06:31
Message: <4b4f6b37$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Darren New wrote:
> Invisible wrote:
>> Line 79 means each row of pixels is computed in parallel, right?
>
> Got me. It looks like someone is asking the compiler to do that if it can.
http://en.wikipedia.org/wiki/Openmp#Work-sharing_constructs
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Vincent Le Chevalier
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 14:07:41
Message: <4b4f6b7d$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Darren New wrote:
>> Line 79 means each row of pixels is computed in parallel, right?
>
> Got me. It looks like someone is asking the compiler to do that if it can.
>
It's using the OpenMP directives
(http://en.wikipedia.org/wiki/OpenMP)... I discovered that last year,
can be pretty useful and makes it quite easy to take advantage of
multiple cores when the algorithms are already mostly suited to being
run in parallel.
--
Vincent
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid XP v8
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 14:18:53
Message: <4b4f6e1d@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> I don't find it really crazy, actually I was expecting far worse
>> before opening the file...
>
> Me too, honestly. You can see what it's doing, and you could probably
> translate it by hand into some other OO imperative language without even
> knowing what it's trying to do. It's not obfuscated as much as terse.
It's just shoved together into a very small space, so it's a big awkward
to read.
What I've probably done is got a plus sign instead of a minus somewhere,
or something equally trivial, which has none the less completely screwed
up the math. And damn, it's going to take a while to find it! :-/
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> 44: double n=sizeof(spheres)/sizeof(Sphere);
>>
>> Well... that's... one way to figure out how big an array is. :-.
>
> That's the usual way to figure out how big an array is in C and C++.
It is surprising to me that this actually works. I was under the
impression that C does not actually distinguish between pointers and
arrays (and integers and booleans and...)
>> Evidently my C++ is weak, but... how is
>> 53: Vec nl=n.dot(r.d)<0?n:n*-1;
>> different from "nl = -abs(n.dot(r.d))"?
>
> In the lack of needing to define the abs() function?
No, I misread the code. It's actually deciding whether to negate n based
on a function of n, not n itself.
>> Also, where THE HELL is "Xi" defined? I can see it *used* in several
>> places, but I can't find a definitions.
>
> Line 48. It's an argument to the function.
No, it's an argument in the radiance() function, I meant where is it
defined in main().
> Note that text search will
> usually answer that sort of question on a C program, and often on a C++
> program too.
>
> Not always, mind, but usually.
Yeah, I tried that too...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tim Cook <z99### [at] gmail com> wrote:
> scott wrote:
> >> 53: Vec nl=n.dot(r.d)<0?n:n*-1;
> >>
> >> different from "nl = -abs(n.dot(r.d))"?
> >
> > a?b:c evaluates to b if a is true, or c otherwise.
> LPC might be a little different, but can't you negate a variable by
> saying a=-a;? Saves a little CPU cost.
Yes, but since 'nl' is of type struct Vec, he would have to define
operator-() for it for that to work. Maybe he wanted to save one line
of code.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Vincent Le Chevalier <gal### [at] libertyallsurfsp amfr> wrote:
> Darren New wrote:
> >> Line 79 means each row of pixels is computed in parallel, right?
> >
> > Got me. It looks like someone is asking the compiler to do that if it can.
> >
> It's using the OpenMP directives
> (http://en.wikipedia.org/wiki/OpenMP)... I discovered that last year,
> can be pretty useful and makes it quite easy to take advantage of
> multiple cores when the algorithms are already mostly suited to being
> run in parallel.
The advantage of OpenMP is that the routine will run in parallel if
the compiler supports it, but if the compiler doesn't support OpenMP,
it doesn't matter: The program will still compile and work properly
(it will just be single-threaded). Compilers ignore #pragmas they don't
recognize (per the standard), so the addition #pragma openmp's don't
matter.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> http://www.kevinbeason.com/smallpt/
A small pitty that it's not 100% standard C++, as erand48() is not part of
the standard (it's a glibc extension). OTOH, better use erand48() than rand(),
as the latter is just plain horrible in quality.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 <voi### [at] dev null> wrote:
> >> 44: double n=sizeof(spheres)/sizeof(Sphere);
> >>
> >> Well... that's... one way to figure out how big an array is. :-.
> >
> > That's the usual way to figure out how big an array is in C and C++.
> It is surprising to me that this actually works. I was under the
> impression that C does not actually distinguish between pointers and
> arrays (and integers and booleans and...)
There is a big difference between a pointer and an array in C (and hence
in C++).
Basically each array is a type of its own, defined by the element type
and the number of elements. What makes an array distinctly a type of its
own is that sizeof() always returns the number of bytes that a type
requires when allocated in memory, and an array is no different: sizeof()
for an array returns the amount of bytes taken by the entire array. This
is drastically different from a sizeof() of a pointer, which will always
return 4 or 8 (depending on whether you are compiling a 32-bit or 64-bit
program).
Since sizeof() of an array returns the total amount of bytes taken by
an array, if you divide it by the amount of bytes of one element, you get
the total number of elements.
For example if in C++ you instantiate a template using an array as a
template parameter, a distinct instanstiation will be made for each specified
type and size of array.
Of course what makes this confusing is that an array implicitly casts to
a pointer of the element type. In other words, wherever a pointer of the
element type is required, you can give an array of that type instead (there
will be an implicity cast to the pointer type).
Also the syntax of indexing an array and indexing memory using a pointer
is identical, adding to the confusion.
It can sometimes be difficult to distinguish between an array and a
const pointer (a pointer which cannot be changed to point somewhere else).
sizeof() is one thing which makes the distinction.
> >> Also, where THE HELL is "Xi" defined? I can see it *used* in several
> >> places, but I can't find a definitions.
> >
> > Line 48. It's an argument to the function.
> No, it's an argument in the radiance() function, I meant where is it
> defined in main().
Line 82.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid XP v8
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 15:18:04
Message: <4b4f7bfc@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Warp wrote:
> There is a big difference between a pointer and an array in C (and hence
> in C++).
Really?
> Since sizeof() of an array returns the total amount of bytes taken by
> an array, if you divide it by the amount of bytes of one element, you get
> the total number of elements.
This is plain. What surprises me is that sizeof() can give you an
accurate size in the first place.
> Of course what makes this confusing is that an array implicitly casts to
> a pointer of the element type. In other words, wherever a pointer of the
> element type is required, you can give an array of that type instead (there
> will be an implicity cast to the pointer type).
Ah. I didn't know that. All the books I've seen claim that they are *the
same type*.
This makes more sense now...
>>>> Also, where THE HELL is "Xi" defined? I can see it *used* in several
>>>> places, but I can't find a definitions.
>>> Line 48. It's an argument to the function.
>
>> No, it's an argument in the radiance() function, I meant where is it
>> defined in main().
>
> Line 82.
Yes, we've established that now. I wasn't aware that you could actually
define more than one variable in a loop initialiser...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 <voi### [at] dev null> wrote:
> > Since sizeof() of an array returns the total amount of bytes taken by
> > an array, if you divide it by the amount of bytes of one element, you get
> > the total number of elements.
> This is plain. What surprises me is that sizeof() can give you an
> accurate size in the first place.
Why wouldn't it? The compiler has to know the size of the array if it
wants to allocate it in memory.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Also the syntax of indexing an array and indexing memory using a pointer
> is identical, adding to the confusion.
Plus, you can't pass an array to a function, at least in C.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid XP v8
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 16:41:40
Message: <4b4f8f94@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>>> Since sizeof() of an array returns the total amount of bytes taken by
>>> an array, if you divide it by the amount of bytes of one element, you get
>>> the total number of elements.
>
>> This is plain. What surprises me is that sizeof() can give you an
>> accurate size in the first place.
>
> Why wouldn't it? The compiler has to know the size of the array if it
> wants to allocate it in memory.
All that stuff about "C does not know the size of an array at run-time,
and does not check array bounds". But then, this is from the same books
that claim that pointers *are* arrays... Certainly if you asked for
sizeof() on a pointer, you wouldn't get the size of the array it points to.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 <voi### [at] dev null> wrote:
> >>> Since sizeof() of an array returns the total amount of bytes taken by
> >>> an array, if you divide it by the amount of bytes of one element, you get
> >>> the total number of elements.
> >
> >> This is plain. What surprises me is that sizeof() can give you an
> >> accurate size in the first place.
> >
> > Why wouldn't it? The compiler has to know the size of the array if it
> > wants to allocate it in memory.
> All that stuff about "C does not know the size of an array at run-time,
> and does not check array bounds".
That talks about dynamically allocated arrays, not statically allocated
ones. They are different.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > Also the syntax of indexing an array and indexing memory using a pointer
> > is identical, adding to the confusion.
> Plus, you can't pass an array to a function, at least in C.
Not directly, but you can do it indirectly if you enclose the array inside
a struct (in that case the array (inside the struct) is truly passed by
value rather than by-pointer).
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Plus, you can't pass an array to a function, at least in C.
>
> Not directly, but you can do it indirectly if you enclose the array inside
> a struct (in that case the array (inside the struct) is truly passed by
> value rather than by-pointer).
...you really have been doing this for a long time, haven't you?
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v8 <voi### [at] dev null> wrote:
> >> Plus, you can't pass an array to a function, at least in C.
> >
> > Not directly, but you can do it indirectly if you enclose the array inside
> > a struct (in that case the array (inside the struct) is truly passed by
> > value rather than by-pointer).
> ...you really have been doing this for a long time, haven't you?
Well, it's rather basic C.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Orchid XP v8 <voi### [at] dev null> wrote:
>>>>> Since sizeof() of an array returns the total amount of bytes taken by
>>>>> an array, if you divide it by the amount of bytes of one element, you get
>>>>> the total number of elements.
>>>> This is plain. What surprises me is that sizeof() can give you an
>>>> accurate size in the first place.
>>> Why wouldn't it? The compiler has to know the size of the array if it
>>> wants to allocate it in memory.
>
>> All that stuff about "C does not know the size of an array at run-time,
>> and does not check array bounds".
>
> That talks about dynamically allocated arrays, not statically allocated
> ones. They are different.
He's right, tho. C doesn't know the size of an array at run time. sizeof()
is a compile-time operator.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> Warp wrote:
>>> Also the syntax of indexing an array and indexing memory using a pointer
>>> is identical, adding to the confusion.
>
>> Plus, you can't pass an array to a function, at least in C.
>
> Not directly, but you can do it indirectly if you enclose the array inside
> a struct (in that case the array (inside the struct) is truly passed by
> value rather than by-pointer).
And in the original versions of C, you couldn't pass a struct by value
either. :-)
But yah, that's a good point I hadn't considered.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> He's right, tho. C doesn't know the size of an array at run time. sizeof()
> is a compile-time operator.
If it knows it at compile time, it knows it at runtime. It's not like
it forgets somewhere in between... :P
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Out of curiosity I changed the location of the light to see that it really
renders it properly:
http://warp.povusers.org/images/smallpt.jpg
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Darren New
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 14 Jan 2010 23:50:25
Message: <4b4ff411@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> He's right, tho. C doesn't know the size of an array at run time. sizeof()
>> is a compile-time operator.
>
> If it knows it at compile time, it knows it at runtime. It's not like
> it forgets somewhere in between... :P
Well, no, I disagree. How do you find the size of an array at runtime?
That's exactly why you have to pass it around along with the pointer.
OK, I'll grant you that the generated code has that available, in the sense
that the loader avoids overwriting that space with other stuff, but it's not
available to the C-level program in any way at runtime.
You can take sizeof(x) at compile time, and store that somewhere that
runtime can find it, but there's nothing like Ada's myvariable'size
expression that would tell you at runtime what the size is for an arbitrary
array. There's no way to apply sizeof() to a non-array-name and find out the
size of an array (i.e., no way to say "what's the size of the array this
pointer points to").
Hmmm... If you put an array in a struct, can you ask
"sizeof(myrecord.thearray)" and get an appropriate size? I suppose you
could, but still I wouldn't count that as such.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Well, no, I disagree. How do you find the size of an array at runtime?
It's a constant integral value, hence known at runtime.
> That's exactly why you have to pass it around along with the pointer.
Now you are confusing dynamically allocated arrays with static arrays.
They are not the same thing.
The size of dynamically allocated arrays cannot be resolved either at
runtime nor at compile time (eg. you cannot use the size of a dynamically
allocated array somewhere where a compile-time constant is expected).
> Hmmm... If you put an array in a struct, can you ask
> "sizeof(myrecord.thearray)" and get an appropriate size?
Yes, actually.
> I suppose you
> could, but still I wouldn't count that as such.
"As such"? What? Runtime? sizeof() always works at compile time.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 09:48:31
Message: <4b50803f@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Warp escreveu:
> Out of curiosity I changed the location of the light to see that it really
> renders it properly:
>
> http://warp.povusers.org/images/smallpt.jpg
did you make it coincident with the surface?
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis <nam### [at] gmail com> wrote:
> Warp escreveu:
> > Out of curiosity I changed the location of the light to see that it really
> > renders it properly:
> >
> > http://warp.povusers.org/images/smallpt.jpg
> did you make it coincident with the surface?
I have hard time deciding whether that was humorous or a serious question.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 11:20:32
Message: <4b5095d0@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Warp escreveu:
> nemesis <nam### [at] gmail com> wrote:
>> Warp escreveu:
>>> Out of curiosity I changed the location of the light to see that it really
>>> renders it properly:
>>>
>>> http://warp.povusers.org/images/smallpt.jpg
>
>> did you make it coincident with the surface?
>
> I have hard time deciding whether that was humorous or a serious question.
serious. Did you put right where the left sphere surface would hit?
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis <nam### [at] gmail com> wrote:
> Warp escreveu:
> > nemesis <nam### [at] gmail com> wrote:
> >> Warp escreveu:
> >>> Out of curiosity I changed the location of the light to see that it really
> >>> renders it properly:
> >>>
> >>> http://warp.povusers.org/images/smallpt.jpg
> >
> >> did you make it coincident with the surface?
> >
> > I have hard time deciding whether that was humorous or a serious question.
> serious. Did you put right where the left sphere surface would hit?
Unbiased monte-carlo rendering sends rays in a random fashion. It starts
extremely grainy, but the graininess gets reduced over time as the number
of samples gets increased. That image is the result of 30 minutes of
rendering in my computer (a virtually grainless result would have taken
days).
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 11:50:39
Message: <4b509cdf@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Warp wrote:
> That image is the result of 30 minutes of
> rendering in my computer (a virtually grainless result would have taken
> days).
Or a GPU implementation...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp escreveu:
> nemesis <nam### [at] gmail com> wrote:
>>>>> http://warp.povusers.org/images/smallpt.jpg
>>>> did you make it coincident with the surface?
>>> I have hard time deciding whether that was humorous or a serious question.
>
>> serious. Did you put right where the left sphere surface would hit?
>
> Unbiased monte-carlo rendering sends rays in a random fashion. It starts
> extremely grainy, but the graininess gets reduced over time as the number
> of samples gets increased. That image is the result of 30 minutes of
> rendering in my computer (a virtually grainless result would have taken
> days).
I know. I'm concerned about that huge circular, pure white light
artifact next to the wall, aren't you? Looks like a bug, which is why I
thought you posted the picture.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 11:53:04
Message: <4b509d70@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Warp escreveu:
> That image is the result of 30 minutes of
> rendering in my computer (a virtually grainless result would have taken
> days).
and no, you don't need days to get grainless result anymore than what
you would need with povray and area lights and radiosity. Specially for
such a simple scene. Though a pure simplified path tracer is very slow.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis wrote:
> I know. I'm concerned about that huge circular, pure white light
> artifact next to the wall, aren't you? Looks like a bug, which is why I
> thought you posted the picture.
It's a light source. It's what illuminates the rest of the scene.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 11:58:01
Message: <4b509e99@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> and no, you don't need days to get grainless result anymore than what
> you would need with povray and area lights and radiosity.
Er, no, POV-Ray uses an utterly different algorithm for this. In
particular, it uses a shedload of statistical tests to reduce the number
of samples taken. *This* program just endlessly resamples everything
until all the randomness averages out; this is orders of magnitude slower.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 12:25:14
Message: <4b50a4fa@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> nemesis wrote:
>
>> I know. I'm concerned about that huge circular, pure white light
>> artifact next to the wall, aren't you? Looks like a bug, which is why
>> I thought you posted the picture.
>
> It's a light source. It's what illuminates the rest of the scene.
oh good. I thought it was a ghost. silly me.
really, this topic went surreal by now...
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> nemesis wrote:
>
>> and no, you don't need days to get grainless result anymore than what
>> you would need with povray and area lights and radiosity.
>
> Er, no, POV-Ray uses an utterly different algorithm for this. In
> particular, it uses a shedload of statistical tests to reduce the number
> of samples taken.
Povray still shows a lot of graininess for insuficient samples. Lots of
samples still get very slow rendering.
> *This* program just endlessly resamples everything
> until all the randomness averages out; this is orders of magnitude slower.
But that's for a pure simple path tracer. There are far smarter
samplers out there, most notably Metropolis Light Transport, that are
able to converge the image much faster.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> and no, you don't need days to get grainless result anymore than what
>>> you would need with povray and area lights and radiosity.
>>
>> Er, no, POV-Ray uses an utterly different algorithm for this. In
>> particular, it uses a shedload of statistical tests to reduce the
>> number of samples taken.
>
> Povray still shows a lot of graininess for insuficient samples. Lots of
> samples still get very slow rendering.
It doesn't show graininess, it shows patchiness. Because it reuses a
single sample for multiple pixels. That means it needs to take about one
millionth of the number of samples that this program takes. Hence, a
*slight* speed difference.
>> *This* program just endlessly resamples everything until all the
>> randomness averages out; this is orders of magnitude slower.
>
> But that's for a pure simple path tracer. There are far smarter
> samplers out there, most notably Metropolis Light Transport, that are
> able to converge the image much faster.
...which still has nothing to do with *this* program.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 13:37:37
Message: <4b50b5f1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Orchid XP v8 escreveu:
>>>> and no, you don't need days to get grainless result anymore than
>>>> what you would need with povray and area lights and radiosity.
>>>
>>> Er, no, POV-Ray uses an utterly different algorithm for this. In
>>> particular, it uses a shedload of statistical tests to reduce the
>>> number of samples taken.
>>
>> Povray still shows a lot of graininess for insuficient samples. Lots
>> of samples still get very slow rendering.
>
> It doesn't show graininess, it shows patchiness.
#default {pigment { rgb .8 } finish { ambient .2 diffuse .8 }}
union {
plane { y 0 }
sphere { <2,1> 1 }
sphere { <-2,2> 2 }
light_source { 3*<1,3,1> 1 area_light x,z,2,2 adaptive 0 jitter }
light_source { 3*<-3,1,-2> .5 area_light x,z,2,2 adaptive 0 jitter }
rotate y*40
rotate -x*30
translate <0,-1,8>
}
plenty of graininess in the shadow edges. And, yes, plenty of
patchiness as for radiosity if used with few samples.
> Because it reuses a
> single sample for multiple pixels. That means it needs to take about one
> millionth of the number of samples that this program takes. Hence, a
> *slight* speed difference.
Which will mean nothing if it doesn't move on to GPU like everyone else
and begins eating dust for such slow and more realistic renderers.
> ...which still has nothing to do with *this* program.
ah, I thought you were talking about unbiased renderers in general.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Because it reuses a single sample for multiple pixels. That means it
>> needs to take about one millionth of the number of samples that this
>> program takes. Hence, a *slight* speed difference.
>
> Which will mean nothing if it doesn't move on to GPU like everyone else
> and begins eating dust for such slow and more realistic renderers.
The GPU has been producing graphics far faster than POV-Ray for decades.
It's only now that it can start to do the sorts of things that POV-Ray
can do.
I haven't yet seem a GPU renderer that can render actual curves. Also,
can any of these unbiased renderers handle scattering particle media yet?
>> ...which still has nothing to do with *this* program.
>
> ah, I thought you were talking about unbiased renderers in general.
No, I was just pointing out that this particular program may take many
hours to render something that POV-Ray does in minutes because POV-Ray
uses a totally different algorithm.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nemesis <nam### [at] gmail com> wrote:
> light_source { 3*<1,3,1> 1 area_light x,z,2,2 adaptive 0 jitter }
That reminds me of a conversation I had in another forum where someone
basically made the claim that if you double the resolution of a video (in
both axes, making each frame have 4 times as many pixels), encoding it to
x264 would require four times as much bitrate in order to preserve the same
quality as the original (because, you know, four times as many pixels equal
four times the needed bitrate).
I countered that in my experience scaling up the video and then encoding
it requires next to no upscaling of the bitrate in order to preserve the
same visual quality. (Claiming that quadrupling the amount of pixels would
require quadruple amount of bitrate is as silly as claiming that quadrupling
the size of a text file would make it compress to four times the size of the
original text file compressed.)
He was determined to prove me wrong, so he took an original 256x192 pixels
video (showing gameplay of a console game) and scaled it up to 1600x1200
and encoded it to x264 with the same bitrate (and seemingly without
fine-tuning any other parameters). The end result had slightly more visual
artifacts than the original.
The original question was whether it would be possible to double the
resolution of the video without enlarging file size, and he "proved" my
affirmative allegation wrong by taking a video and making it over *six*
times larger, resulting in *slightly* more visual artifacts.
(Amusingly, while he tried to prove my allegation wrong, he inadvertedly
also succeeded in proving wrong the allegation that doubling the video
resolution would require four times as much bitrate to preserve the same
visual quality. He made the video over six times larger and with the same
bitrate there were only slightly more visual artifacts.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> Well, no, I disagree. How do you find the size of an array at runtime?
>
> It's a constant integral value, hence known at runtime.
If you ask for it, the compiler will give you some value that's unassociated
with the array that happens to contain the size of the array, sure.
>> That's exactly why you have to pass it around along with the pointer.
>
> Now you are confusing dynamically allocated arrays with static arrays.
> They are not the same thing.
Not at all. My point is that in many languages, you can ask an array for its
size, regardless of where you use it. Because of the fact that arrays are
not first class in C, you cannot talk about an array except where the name
of the array is in scope. So, in order for a subroutine to know how big is
the array you've passed in, you have to pass in the size separately.
strcpy() has no way of doing what strncpy() does, and you need an extra
argument to strncpy() that may or may not be the size of the destination
array. Hence, there's no way to get the size of an array at runtime.
Certainly C knows the size of a dynamically allocated array at runtime
*better* than it knows the size of a statically allocated array at runtime.
>> Hmmm... If you put an array in a struct, can you ask
>> "sizeof(myrecord.thearray)" and get an appropriate size?
>
> Yes, actually.
>
>> I suppose you
>> could, but still I wouldn't count that as such.
>
> "As such"? What? Runtime? sizeof() always works at compile time.
That's what I'm saying. sizeof() works at compile time. Hence, there's no
way to ask what the size of an array is at runtime, whether it's static or
not. The only way to get the size of an array is if the *declaration* of the
array is in scope.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I don't want to prove anyone wrong, just pointing out that with
sufficiently low samples graininess is noticeable in pov's area lights.
Of course pov is several times faster than any unbiased algorithm. Then
again, the more light transport phenomena you try to simulate with pov,
the more it approaches unbiased algorithms "speed".
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Vincent Le Chevalier
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 14:48:58
Message: <4b50c6aa$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Orchid XP v8 wrote:
> No, I was just pointing out that this particular program may take many
> hours to render something that POV-Ray does in minutes because POV-Ray
> uses a totally different algorithm.
Arguably that program and POV-Ray do not do the same thing and do not
give the same results, so comparing both is a bit misleading. POV-Ray
does not do it in minutes... It does a different, less accurate
approximation.
--
Vincent
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: 99 lines of C++ for an unbiased ray tracer
Date: 15 Jan 2010 15:03:58
Message: <4b50ca2e@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Orchid XP v8 escreveu:
> I haven't yet seem a GPU renderer that can render actual curves.
Seemingly there's no such need for them when triangle meshes are so
flexible, fast and look just the same. (at the expense of memory)
> Also,
> can any of these unbiased renderers handle scattering particle media yet?
Why would it not handle? Lux handles participating media, but just the
path tracer integrator, not bidir. Not much used of course because I
guess it's insanely slow.
BTW, real-time scattering media will be soon enough in games from some
tech I've seen from Microsoft.
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |