ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

Anybody here into non-realtime graphics rendering?



  53 Clio's & counting
Seriously Andy, they look awesome!

I just wish I had the slightest idea to what you are going on about :eek: ( me + computers = :S )
 

SharkyUK

ClioSport Club Member
Thanks Russ, glad you like them mate. Next time we meet up I'll talk you through the process... ;) LOL! In a nutshell it all boils down to physics and mathematics (lots of linear algebra and trigonometry) being used to simulate rays of light hitting objects, and then creating an image from that process. I can post up my code if it helps?!?!
 

Darren S

ClioSport Club Member
Good question, D... these are actually generated on my old home development PC. And when I say old, I mean old! Athlon dual core, 2GB RAM, nVidia 8800 GTX's in SLI, dual Velociraptor hd's, running 32-bit Windows XP! The thing is, this is the most reliable PC I have ever owned hence I'm reluctant to bin it! I also know that if my code works well on this machine then it should run a fair bit nicer on something more modern. ;) For the record, the ~1.3 million poly head rendered in around 5 minutes on my work PC.

Clever idea! Would be interesting to see your results on those dedicated external graphics card units!

If the head takes around 5mins on your work PC - what times are we looking at on your old home PC for comparison?

D.
 
  53 Clio's & counting
Thanks Russ, glad you like them mate. Next time we meet up I'll talk you through the process... ;) LOL! In a nutshell it all boils down to physics and mathematics (lots of linear algebra and trigonometry) being used to simulate rays of light hitting objects, and then creating an image from that process. I can post up my code if it helps?!?!

I tihnk you will need to be doing a whole lotta explaining to get my head around it :eek: lol

Clever idea! Would be interesting to see your results on those dedicated external graphics card units!

If the head takes around 5mins on your work PC - what times are we looking at on your old home PC for comparison?

D.

Andy's home computer has the processing power of the computer in the batcave, NASA, and that smart thing out of I-Robot
 

SharkyUK

ClioSport Club Member
If the head takes around 5mins on your work PC - what times are we looking at on your old home PC for comparison?
With exactly the same settings (resolution, antialiasing, camera position, etc.) that head took 52 minutes to render. :eek: But there are several optimisations I will look to put in at some point in the future.

Awesome work Andy!
Thanks mate. I just wish I could send you some money right now and take that system off your hands! LOL!

I tihnk you will need to be doing a whole lotta explaining to get my head around it :eek: lol

Andy's home computer has the processing power of the computer in the batcave, NASA, and that smart thing out of I-Robot
Set aside a quiet couple of years and I'll ring you up to speed mate ;) Sadly I spent far too much time growing up in front of a computer instead of tinkering with cars... could have been a whole different story otherwise! I do admit I'm extremely lucky though being able to enjoy this stuff as a hobby and a profession. Even if it is a bit geeky and sad. :p

Also, my home PC is in a bad way Russ. My last decent PC literally melted hence why I'm back on my old (and trusty) machine. My workstation in work is a whole different beast though. I just wish I could take it home with me at the end of each day.
 
I used to play with 3DS Max I actually have a DVD you can have a copy of called UltiMax it's about 18 hours long of a guy teaching you every in and out of 3DS Max 8 (If I remember) whilst he builds a super gigantic robot, skins it and animates it. Cost me £30 a while back. I have had an interest into modelling, rendering and playing with physics (like making flags fly in the wind and knocking stuff over with blocks and junk).

Here are some bullets I made and rendered one day when I was bored.

199967_10150161563747658_6058855_n.jpg


190416_10150161563817658_5181052_n.jpg


This one took about 2 hours to render believe it or not but I did it at a super resolution in BMP format... Why I have no idea

199063_10150161564067658_8086078_n.jpg


196242_10150161565027658_4042018_n.jpg


196026_10150161565207658_3793780_n.jpg


200521_10150161565272658_16139_n.jpg
 

SharkyUK

ClioSport Club Member
I made a start on improving the support for texture maps the other night. At the moment I only have the diffuse and specular texture maps working though... still got a few issues with the bump / displacement / normal maps. This will need a bit of a re-think due to the way I currently process the vertex data in the scene. It shouldn't be too difficult; all I need to really do is calculate per vertex tangents and bitangents and I can then use these values (along with per vertex normals) to apply normal maps to models in the scene. In the meantime, here's a (partial) render of an Alien Xeno Queen that I produced last night. The alien is lit by 3 point lights (Lambert diffuse shading with Phong lighting), has 4x supersampling and a high-res albedo / diffuse texture.

8674214630_0f5acc40cc_o.jpg

High Res Texture Mapping by SharkyUK, on Flickr
 
  Evo 5 RS
That looks ace mate. Need these things in real time!

Tessellation goes along way to emulate more realistic light sources I've noticed recently
 
Cool renders, mate - very bling for bullets! They look to be quite a high polygon count, too?

Cheers dude yeah I wanted them to look like bullets you would display I Was playing around with a chrome texture Made seeing how versatile it is. The bullets themselves won't be that high of a count (I never checked) but they where made from a spline lofted into the 3D shape probably sub 300 polys dare I say sub 200!
 

SharkyUK

ClioSport Club Member
That looks ace mate. Need these things in real time!

Tessellation goes along way to emulate more realistic light sources I've noticed recently
Thanks mate - glad you like it. In all truth the credit must go to whoever created the 3D model as they've done a great job. :) Mind you, I'm more than happy with how the shading and lighting algorithms work on this particular model. I think I might see where I can take it... (time permitting as always!)

Yes, tessellation can definitely improve the lighting when used hand-in-hand with some sort of refinement algorithm - as you've noticed first-hand. Most games utilising tessellation implement a variant of PN-Triangles (or N-patches) to take a low resolution model and convert it into curved surfaces of finely meshed triangles for rendering; resulting in the better-looking geometry and improved lighting

Cheers dude yeah I wanted them to look like bullets you would display I Was playing around with a chrome texture Made seeing how versatile it is. The bullets themselves won't be that high of a count (I never checked) but they where made from a spline lofted into the 3D shape probably sub 300 polys dare I say sub 200!
The chrome texture works well on those to be fair, especially with the colouring applied. I was wondering whether or not you'd created a loft'ed object rather than messing around with segmented cylinders. For such low poly items they give the impression of higher counts.
 
Thanks mate the chrome has a base of black with a ray tracer on it from what I remember it was 3 years a go when I did it. I might see if I can dig out the 3ds file and mtl (sp?) file. I can't remember how I did it now. I'm far from a modeller I must say I just like playing with simple shapes and lofts really do intrigue me the shapes you can make in the space of a few minutes.
 

SharkyUK

ClioSport Club Member

SharkyUK

ClioSport Club Member
I have updated the raytracing engine so that it now supports normal maps and bump maps (using per vertex normal, tangent and bitangent values - TBN). [For anyone interested...] This implementation is basically a software version of what modern GPU's do so well these days. From these values a TBN matrix can be calculated which then allows light direction vectors to be transformed to/from tangent space for correct lighting of primitives. Here are a few images similar to the last few I posted, albeit with the addition of normal / bump maps.

On the alien below, more definition can be seen across the model's polygonal surfaces (due to the perturbed normals). The polygons between the head and the torso are quite large and fairly few in number, yet the normal map provides a decent approximation of depth and curvature to that area.

8722930227_074e9fc362_o.jpg

Render Test - Normal Maps by SharkyUK, on Flickr

On the character below, the leathery skin is a lot more evident due to the normal maps (and specular lighting).

8724051258_26e70a7b7a_o.jpg

Render Test - Normal Maps by SharkyUK, on Flickr


On the head model below, the normal maps provide the subtle skin details - such as wrinkles, pores and similar.

8722930519_af138fa4b9_o.jpg

Render Test - Normal Maps by SharkyUK, on Flickr
 
Seriously jealous of your coding skills :(. Out of interest what are you using to code this render engine? Would you maybe code it to work with max/maya at some stage or is it just a play thing? Would you sell it once its finished or would it be a constant development? Also would you post a little code snippet of what you have wrote maybe 10 lines or so? I'm interested to see what the code looks like!
 

SharkyUK

ClioSport Club Member
Seriously jealous of your coding skills :(. Out of interest what are you using to code this render engine? Would you maybe code it to work with max/maya at some stage or is it just a play thing? Would you sell it once its finished or would it be a constant development? Also would you post a little code snippet of what you have wrote maybe 10 lines or so? I'm interested to see what the code looks like!
Hi mate - the render engine is written in C++ (I usual Microsoft Visual Studio as my integrated development environment). It could indeed be adapted to work as a plug-in for Max/Maya (or other tools) but for now it's mainly a play thing. It would need a fair bit of work and tidying up to get it into a state whereby I'd be happy to release it. As it's a "play thing" I've not got any formal plan or design and I'm simply having fun with it as I go along.

As much as I'd like to think I could turn this into something commercially viable I don't think I'd be able to compete against the existing renderers already out there (some of which have been established for years). I simply don't have the time and/or resource to compete against companies that have a team of professionals working on this stuff day-to-day. So, for now at least, it's going to remain homebrew and very much in the hobbyist realm! I plan to keep coming back to it though and adding/updating things. :)

Sure, I can show an example of the code (although I'm not sure how it will look embedded in this post...) It's not the best and it's not particularly well commented!

This snippet of code is (a simplfied) part of the recursive raytracing algorithm:

Code:
        if (pPrim->GetReceivesLight())
        {
            //>>


            Mat33 matTBN;
            matTBN.SetIdentity();
            bool bUseTBN = false;


            if (pPrim->GetType() == Primitive::PRIMTYPE_TRIANGLE)
            {
                if (pPrim->GetMaterial()->GetNormalTexture())
                {
                    PrimitiveTriangle* pTri = (PrimitiveTriangle*)pPrim;
                    if (pTri)
                    {
                        pTri->GetTBNMatrix(&matTBN);
                        bUseTBN = true;
                    }
                }
            }


            //>>


            // Trace contributing lights
            for (unsigned int lightIndex=0; lightIndex<mpScene->GetNumLights(); ++lightIndex)
            {
                Primitive* pLight = mpScene->GetLight(lightIndex);
                Vec3 L;


                //
                // Determine shadow/shading term
                //
                float shadowTerm = _CalculateShadowTerm(pLight, intersectionPt, L);


                //
                // Apply TBN matrix?
                //
                if (bUseTBN)
                {
                    L = L * matTBN;
                }


                if (shadowTerm > 0.0f)
                {
                    Vec3 N = pPrim->GetNormal(intersectionPt);


                    const float cAttenuation = 1.0f;


                    //
                    // Calculate diffuse shading
                    //
                    if (pPrim->GetMaterial()->GetDiffuseIntensity() > 0.0f)
                    {
                        float dotProd = (N ^ L);
                        if (dotProd > 0.0f)
                        {
                            float diffuse = dotProd * pPrim->GetMaterial()->GetDiffuseIntensity() * shadowTerm;
                            accumColour += diffuse * primDiffuseColour * pLight->GetMaterial()->GetDiffuseColour() * cAttenuation;
                        }
                    }


                    //
                    // Calculate specular
                    //
                    if (pPrim->GetMaterial()->GetSpecularIntensity() > 0.0f)
                    {
                        Vec3 V = ray.GetDirection() * matTBN;
                        Vec3 R = L - (2.0f * (N ^ L)) * N;


                        float dotProd = (V ^ R);
                        if (dotProd > 0.0f)
                        {
                            float specular = powf(dotProd, pPrim->GetMaterial()->GetSpecularPower()) * pPrim->GetMaterial()->GetSpecularIntensity() * shadowTerm;
                            accumColour += specular * primSpecularColour * pLight->GetMaterial()->GetDiffuseColour() * cAttenuation;
                        }
                    }
                }
            }
        }
        else
        {
            accumColour += primDiffuseColour;
        }


        if (mbEnableReflections)
        {
            //
            // Calculate reflection
            //
            float reflection = pPrim->GetMaterial()->GetReflection();
            if ((reflection > 0.0f) && (traceDepth < mMaxTraceDepth))
            {
                Vec3 N = pPrim->GetNormal(intersectionPt);
                Vec3 R = ray.GetDirection() - (2.0f * (ray.GetDirection() ^ N) * N);
                Vec4 reflColour(0.0f, 0.0f, 0.0f, 0.0f);
                float reflDist;
                RayTrace(Ray(intersectionPt + (R * scmEpsilon), R, ++mCurRayID), reflColour, traceDepth + 1, refractionIndex, reflDist);
                accumColour += reflection * reflColour * primDiffuseColour;
            }
        }


        if (mbEnableRefractions)
        {
            //
            // Calculate refractions
            //
            float refraction = pPrim->GetMaterial()->GetRefraction();
            if ((refraction > 0.0f) && (traceDepth < mMaxTraceDepth))
            {
                float currRefrIndex    = pPrim->GetMaterial()->GetRefractionIndex();
                float n                = refractionIndex / currRefrIndex;
                Vec3 N                = pPrim->GetNormal(intersectionPt) * (float)result;
                float cosI            = -(N ^ ray.GetDirection());
                float cosT2            = 1.0f - n * n * (1.0f - cosI * cosI);


                if (cosT2 > 0.0f)
                {
                    Vec3 T = (n * ray.GetDirection()) + (n * cosI - sqrtf(cosT2)) * N;
                    Vec4 refrColour(0.0f, 0.0f, 0.0f, 0.0f);
                    float refrDist;
                    RayTrace(Ray(intersectionPt + (T * scmEpsilon), T, ++mCurRayID), refrColour, traceDepth + 1, currRefrIndex, refrDist);


                    // Apply Beer's Law
                    Vec4 absorbance        = primDiffuseColour * 0.15f * -refrDist;
                    Vec4 transparency    = Vec4(expf(absorbance.mX), expf(absorbance.mY), expf(absorbance.mZ));
                    accumColour            += refrColour * transparency;
                }
            }
        }

(Sorry, the code layout above doesn't look so good on the forums!)
 
That is crazy thanks for sharing! Looks so confusing :( lol all the numbers, figures, identities and all that your an extremely clever person!

Might be worth signing up to a CG website maybe make a standalone executable and let people have a play with it with their CG models that would be cool they could suggest features and when you get time or get bored gives you ideas on what to add to it next?

Just thinking aloud though. Looking forward to the updates mate keep it up!
 

SharkyUK

ClioSport Club Member
LOL! Thanks mate! :) I'm far from clever and it looks more complicated than it probably is! The formulae I'm using have been around for years yet still (fundamentally) form the basis of today's cutting-edge rendering technology, albeit with a few more bells and whistles.

Many thanks for the suggestion of signing up to a CG website or two (I'm already on a few sites). I haven't really mentioned anything about my little project because making it available for others (i.e. so it becomes more than a simple personal project) would actually make things a bit awkward due to my current job. It could be seen as a conflict of interests amongst other things. :)

I hope I can continue to provide a few more updates soon. Cheers!
 

sn00p

ClioSport Club Member
  A blue one.
Recursive?

Do you limit the number of times (depth) that a ray that interact with the scene?

I've written cad software in the past and I would often have to do stuff that is recursive, but due to the immense number of objects recursion would not be a good idea.

Ray casting was something that I always intended to have a play with, the first wow game I ever played was wolfenstein.
 

SharkyUK

ClioSport Club Member
Yes mate - the heart of the raytracer is recursive. However, I have a configurable variable that is used to specify the maximum number of bounces a ray can take in a scene. When that limit is reached the recursion stops and that particular ray contributes no more to the output.

For an "old-skool" homebrew project like this the recursive nature isn't so much of an issue (well, not at the moment). With some decent acceleration structures in place, some half-decent hardware and (eventually) a multi-core/-threaded/GPU implementation it will run ok. But yes, the computation and rendering time can increase massively if complex materials are used along with large numbers of lights and primitives. Rendering performance is slowed further still when adding additional effects such as DoF and some form of indirect lighting - whereby billions and billions of rays are typically required. At this point it's best to start looking at hybrid methods that straddle the line between rasterisation and raytracing.

Ah yes, raycasting. I remember writing a small tech demo that simply allowed a 'player' to wander around a 3D maze. No monsters, no gameplay, no nothing. It was pretty dire to be honest. Wolfenstein, and games of that ilk, provided me with the inspiration whilst learning about the techniques involved helped later when it came to hunting for a job after university.

What CAD software have you written / worked on?
 

sn00p

ClioSport Club Member
  A blue one.
I realise what I wrote sounded stupid, when I said "recursive?" I actually wasn't surprised that it was a recursive algorithm (it obviously is), I was just surprised that you implemented it as recursive, but if you limit the depth that the stack could go then it's obviously not a problem.

I would often have to implement recursive algorithms in a non-recursive way (i.e create my own stack and manage memory) to prevent stack overflow.

Maybe it's because I was always nervous of recursive code because of the type of data I was processing.

It's software for designing printed circuit boards, I still work on it (we have a big update on it that I've been working on for a while) but we've become quite heavily involved in microwave radar systems for detecting stuff, so I've been doing all the software on that, everything from signal processing to GPRS comms to the analysis software at the PC end. We use our own design software to design the hardware!

The radar stuff is a massive time sink, very interesting though! (Makes my head hurt quite a lot of the time when things aren't quite working as you think they should).
 

SharkyUK

ClioSport Club Member
I realise what I wrote sounded stupid, when I said "recursive?" I actually wasn't surprised that it was a recursive algorithm (it obviously is), I was just surprised that you implemented it as recursive, but if you limit the depth that the stack could go then it's obviously not a problem.
No, it didn't sound stupid at all mate. I can fully appreciate where you are coming from and understand why you would want to control the 'recursion' and resulting stack yourself. It is possibly a route I will take at some point when looking to optimise the raytracer as I'm beginning to think that unmanaged recursive algorithms might not translate so well when looking to take advantage of GPU processing power through CUDA and similar languages. It's a little too early in the day for that though and I'm not sure I want to get that serious with this project just yet (if that makes sense).

Maybe it's because I was always nervous of recursive code because of the type of data I was processing.
Yes, I have to agree with you here as I'm always a bit wary when it comes to recursive code! Especially when working with data sets where data size, resource and processing requirements can grow exponentially. From your obvious knowledge and experience (and comments) I would hazard a guess that you've experienced the pain of unmanaged recursive code once or twice!

Thanks for sharing a bit of information about the work you have done (and continue to do). It sounds really interesting and varied; especially with designing and implementing the software pretty much from end-to-end. I can also sympathise with the hurting head and how time can just vanish into nowhere; it's very much a place I'm in at the moment. A 3-4 week task that is now into it's 3rd month... :eek:
 

SharkyUK

ClioSport Club Member
Nothing particularly new or exciting to report lately. All I've done is change the way lights are handled. They are no longer primitives and are separate entities. My naive implementation before meant that lights would cause other lights to cast shadows... oops. Just a couple of test render really.

8769967449_5524052a1f_o.jpg

Render Test - Warrior FV-510 by SharkyUK, on Flickr

8776507096_3aa65a781c_o.jpg

Render Test - T-90 by SharkyUK, on Flickr

I'm currently trying to implement a kd-tree acceleration structure but it's proving to be a real pain in the a**.
 
  265
Keep up the good work mate its looking great. How many sample passes did those renders take?

Only one week left to finish my project now then ill post up some images from it. My eyes are killing me from staring at a monitor all day :dead:
 

SharkyUK

ClioSport Club Member
Thanks, Semtax.

The majority of the renders I've posted so far are supersampled so each pixel's final colour is averaged from a sampling of 4 pixel traces (hence the 4x supersampling). Obviously this ups the processing time considerably but produces generally nicer results than trying to do some sort of post-process effect.

Also, these images are only exhibiting the most basic raytracing behaviours in terms of shadowing and reflection/refraction; e.g. I'm only currently shooting a single secondary ray at the moment whilst checking for occluders. This is why you can see the hard-edged shadows in the images. I do have support for area lights and soft-shadows but I'm yet to post any of those images up. For soft-shadowing with area lights I'm typically shooting 32, 64 or 128 secondary rays (Monte Carlo raytracing). I've also introduced a noise factor (using random noise generated with a Mersenne Twister algorithm) so that I don't get banding artifacts with the shadows at lower sample rates. Likewise, I'm only currently showing perfect reflections in these images. Again, I'm yet to post up images of diffuse glossy reflections and similar effects (where I'm using 16, 32 or 64 samples depending on the surface material properties). I'll hopefully post up images of this stuff at a later date.

Are you also working on a raytracer for your project mate? Sounds interesting! I look forward to seeing the images. :)
 
  265
Creating my own raytracer is beyond me so im using the Cycles render engine which i think is pretty much entirely ray tracing based. Im getting ideas from your images as to what settings to use for my project though as im relatively new to it :approve:
The animation im creating has characters made from glass so there is quite a bit of refraction/ reflection processing to be done. Im experimenting with different amounts of light bounces at the moment to try and get the render time down to an acceptable level without dithering etc.
 

SharkyUK

ClioSport Club Member
Ah, got you mate. I don't really know much about the Cycles render engine to be honest so I'm not sure what's going on under the hood. In terms of light bounces I am limiting to 4 bounces in the images I've posted to date. This seems a good trade-off for accuracy vs. time at the moment (in terms of my engine that is). Obviously this can soon get expensive though depending on the complexity of the scene primitives and the materials they use!

Also, my apologies for forgetting! I now recall you mentioning earlier that you were working on an animation in Blender. It just took a moment for the penny to drop. Old age you see... ;) Looking forward to seeing your results mate!
 

SharkyUK

ClioSport Club Member
That looks great, mate! Very clean and stylish. Thanks for posting up. Is there any chance we'll be able to see the whole finished animation at some point? I wouldn't mind seeing it to be fair. Great work! :D
 
  265
Cheers mate :eek:. I should have a decent version online this Friday so ill post it up here. Still plenty of rough edges to iron out though as its my first 3D animation.
 

SharkyUK

ClioSport Club Member
I look forward to seeing it! I wouldn't worry about the rough edges; you're probably the only person who is aware of them. :) Anyway, that's what antialising is for... (bad joke, I know). I've not had much chance to work on my renderer recently but I'll try and get a few more progress shots up soon.
 

SharkyUK

ClioSport Club Member
LOL! Mate, that is very, very well done! :D I didn't see many rough edges at all. Congratulations on what is an excellent piece of animation (and story, too). *thumbs up* :cool:
 
  265
Ah cheers lads its nice to have people like something you've spent an age on :eek:

Im happy with how its turned out so i think ill continue on with this 3D malark
 


Top