GRP1 discussion

Programming topics can be found here.
User avatar
122675
Posts: 25
Joined: Mon Sep 30, 2013 9:48 am
Contact:

Re: GRP1 discussion

Post by 122675 » Sun Oct 13, 2013 5:59 pm

Also added some simple chromatic dispersion. It's not completely physically correct, but it adds a nice touch to diamonds.

Image
Tom Veltmeijer

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Tue Oct 15, 2013 10:34 am

Amazing image!

120448
Posts: 11
Joined: Mon Sep 30, 2013 1:00 pm

Re: GRP1 discussion

Post by 120448 » Wed Oct 16, 2013 12:10 am

Nice Tom! I implemented a job system today and need to work on the BVH a bit more before I can go on. I tried to do some research about the chromatic dispersion, but couldn't really find anything useful yet. Do you maybe know a good source of information for this feature?
Marc Peyré
Programmer - 2nd year
http://twirlbound.com

User avatar
122675
Posts: 25
Joined: Mon Sep 30, 2013 9:48 am
Contact:

Re: GRP1 discussion

Post by 122675 » Wed Oct 16, 2013 9:43 am

I spent a few days Googling it and there is indeed not much to find, but the idea is pretty simple: every ray has a random wavelength in the visible spectrum (about 400-700nm). When it refracts, use that wavelength to determine the ray's color and index of refraction (IOR). To calculate the IOR you use Cauchy's equation, or the Sellmeier equation. The hard part was converting wavelengths into RGB colors. There are some formulas for it that involve the CIE color spectrum, you can Google that but it's quite confusing. That's why I'm using a simpler way:
I got a picture of the visible spectrum from the web, cropped and scaled it to 300x1 and use it as a lookup table. That means all my wavelengths are integers, but it's accurate to the nanometer, so good enough for me :P With a little more research you should be able to figure it out now, good luck!
Tom Veltmeijer

120186
Posts: 7
Joined: Sun Sep 29, 2013 3:08 pm
Location: Boxtel, Noord-Brabant

Re: GRP1 discussion

Post by 120186 » Mon Oct 21, 2013 1:35 pm

Hey all, I noticed something interesting in real life that also kinda applies to ray tracing.
In this picture you see my LED strip casting an interesting shadow on my sticky notes holder. This is actually what we are simulating in our ray tracers so I wanted to drop it here and maybe serve as inspiration or something :D

http://i.imgur.com/836VfFK.jpg (Because the image was too big to fit here :P )
Jasper de Laat
2GA-2PR

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Mon Oct 21, 2013 10:08 pm

Your led strip could really use some random sampling. :)

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Thu Oct 24, 2013 11:29 am

Code for random reflection with a distribution proportional to the Lambertian BRDF:

Code: Select all

int MinAxis( const float3& _V )
{
	return (fabs( _V.x ) <= fabs( _V.y ) ? 
       ((fabs( _V.x ) <= fabs( _V.z )) ? 0 : 2 ) : ((fabs( _V.y ) <= fabs( _V.z )) ? 1 : 2 )); 
}

float3 Perpendicular( const float3& _V )
{
	const int ma = MinAxis( _V ); 
	if (ma == 0) return float3( 0, _V.z, -_V.y ); 
        else if (ma == 1) return float3( _V.z, 0, -_V.x ); 
        else return float3( _V.y, -_V.x, 0 );
}

float3 DiffuseReflection( const float3& _Rand, const float3& _N, const float3& _Nsurf )
{
	const float r1 = _Rand.y;
        const float tmp = sqrtf( 1.0f - r1 );
        const float tmp2 = 2.0f * PI * _Rand.z;
	float3 T = Perpendicular( _N );
	float3 B = cross( T, _N );
	T = (T * (cosf( tmp2 ) * tmp)) + 
            (B * (sinf( tmp2 ) * tmp)) + 
            (_N * sqrtf( r1 ));
	T = (dot( T, _Nsurf ) > 0) ? T : (T * -1.0f);
	return T;
}

User avatar
100066
Posts: 9
Joined: Sun Sep 29, 2013 11:13 pm
Contact:

Re: GRP1 discussion

Post by 100066 » Fri Oct 25, 2013 12:31 am

All these nice images make me want to write another ray (or path) tracer again...
Bryan Keiren - Programmer
http://bryankeiren.com/

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Fri Oct 25, 2013 12:03 pm

Well you did some decent stuff yourself. :)

Image

User avatar
100066
Posts: 9
Joined: Sun Sep 29, 2013 11:13 pm
Contact:

Re: GRP1 discussion

Post by 100066 » Fri Oct 25, 2013 12:41 pm

bikker wrote:Well you did some decent stuff yourself. :)

Image
Hahaha yes, but I'd love to implement more features that I didn't implement back then (like texturing, or caustics. Nice, shiny caustics... ooooooh :P)

And I'd like to make it faster too. It takes a good while to render one frame with all features enabled, even though it's multi threaded and utilizes the CPU for 100%.
Bryan Keiren - Programmer
http://bryankeiren.com/

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests