Planning the Spontaneous

It's more than just a blueprint.

Posts Tagged ‘Graphics’

To London And Back

Posted by Robert Chow on 09/12/2009

To those who read my last post, no, I did not drive to London and back. Although it would’ve been quite an experience to tell having only had so few driving lessons.  No, this is a different experience to tell.

Instead, I’ve been to London over the past two days to visit a conference, PSI Graphics (PSI – Statisticians in Pharmaceutical Industry).  The conference is about displaying data, and also highlights how to do this using multiple ways and techniques between differing software packages.

The first talk was about how (not) to display data.  Most of it was common sense, but in particular, i was probably the one I found most useful because it highlighted, on paper, what a user should and shouldn’t do when creating a graph.  One of my personal favourites of how not to display data was rule #5: Make sure the numbers don’t add up.

And along came, yet another, Fox news fail.

Fox News GOP Candidates. This image has been taken from

Second up was about a program a developer had created to help statisticians understand the effects a drug/placebo may or may not have on several patients.  The program, developed within AstraZeneca, was especially useful and introduced many methods that helped statisticians to do their jobs more effectively.  The entire talk was essentially focused on how program interactivity meant allowing less time interpreting the data, thus creating more time for productivity.  I guess I should try to focusing on the Grapher component to do similar.

Last of the morning talks introduced why there should always be a control data set, and how to display this effectively so an interpreter can easily see the difference between the control and the sample sets.  It also included calculating regression to the mean, and to be completely honest, a fair bit of this talk went over, not just my head, but many others too.  But I think I got the gist of it.

The afternoon presented many approaches to the “Graphics Challenge” proposed by PSI – the challenges were to display and evaluate many data cases using a software package.  Of the software packages on show, MATLAB was the only one I’d heard of, having used it in my AI course last year.  Unfortunately, the MATLAB speaker was unable to turn up.  So I had to sit through a good few hours of talks about SAS, STATA, R/S+ and GenStat approaches.  All of this was new to me, and because of why I was at the conference and knowing why (to investigate how to display data, to find other methods of display data efficiently, how do others display their data, any other graphs that need to be considered, how can we better other packages, etc), I think I was probably one of the least bored of the many that attended.

Before going to this conference, I was a bit skeptical at first.  I knew the conference was going to be useful,  but didn’t quite know how much.  I guess, a lot of the things said, I’d considered, but that’s as far is went. It was very useful for it allowed me to put pen to paper, and actually have things written down instead of thinking about them, or at least thought I’d been thinking about them, when in fact I hadn’t.  I was a little skeptical of the people too – I didn’t know what to expect.  But I met a fair few characters, from an electrical engineer turned SAS programmer, to many statisticians, one who is a placement student like myself.  And lastly, because it was London.

Funnily enough though, I didn’t find myself outside of my comfort zone at all – which surprised me the most.  As tiring as it is to go to London and back from Bideford, it’s definitely an experience I’ll want to do again, and I urge many others to go to conferences too, skeptical or not.

On one last note, I have to say, over the past couple of days, I should have just shut my mouth when I’m in a car.  On Monday I was given that lecture about not being so hard on myself when driving.  Yesterday, I was in the taxi with a born and bred country man.  I simply remarked at how in Manchester I’d rarely have to get a taxi because of public transport, and then he goes and gives me a full-blown account of how being in the country isn’t so “slow-paced”, and how you have to just plan ahead.

Shutting up.


Posted in Computing, Placement | Tagged: , , , , , | 1 Comment »

Renderer: Picking

Posted by Robert Chow on 03/12/2009

Remember that decorator pattern I used for writing to textures?  Also particularly useful for picking too.

Decorate the main drawer class with a picking class.  This allows for the picking class to start off by setting up the render-mode to select mode, and to set the X and Y co-ordinates of the mouse.  Render the image as normal, but because of the render-mode switch, the image is rendered using the select buffer instead of the device context.  After this, the picking class is also able to interpret the picking buffer, and then return the results.

Sounds fairly easy.  But I did run into a problem near the start.

First off was the mouse wasn’t picking where I wanted – it was interpreting the mouse as always in the bottom-left hand corner.  Why so?

I later learnt that when changing the render-mode, it automatically multiplies the projection matrix by some pre-configured matrix so it can do the picking appropriately.  In the original drawer class, I was resetting the projection matrix by loading the identity, and thus wiping what the picker class had set up.  Kind of like defeating itself.  So I had to change this by taking the matrix resets out of the main drawing method, and place them outside – these would have to be called elsewhere – likely to be through the Renderer facade (another GoF pattern), before calling the draw.

So with the matrix set up properly, I did encounter another problem.  And this time it was hardware based.  It would pick appropiately on my supervisor’s computer, yet not on mine.

An example scenario:  there are several images overlapping each other, each with their own pick Id.

My supervisors computer: picks appropriately – returns the object with the nearest Z value (most positive), under mouse (X,Y) .

My computer: picks unappropriately – returns the object with the nearest Z value, under mouse(X,Y) – providing the object has not moved in modelview space in terms of the Z value.  This accounts for transformations, rotations and scales.  So therefore it will sometimes return the correct object, but most of the time, it won’t.  Particularly annoying if you have a scene that is constantly rotating, and you want to pick the nearest item – it will always pick the same item every single time, simply because it was rendered at the front first before it was rotated.

Simple fix:  enable culling.  This means that anything that is not in view won’t be rendered, so technically there is nothing behind the frontmost object – it can be the only one that is picked!

But that’s also particularly annoying when you want to use 2-face rendering.  This is the ability to render shapes clockwise, and counter-clockwise.  Enabling culling in OpenGL will result in all shapes that would originally be drawn clockwise to the screen, not drawn at all.  Not so useful in rotating scenes!


Combining textures and picking, this demo allows the user to pick a quadrant, and that will change accordingly – to texture if off, or to non-texture if on.

Renderer Picking Demo. From top-left, clockwise:  empty canvas; bottom-left quadrant click to turn texture on; top-right quadrant click to turn texture on; top-left quadrant click to turn texture on; bottom-left quadrant click to turn texture off; top-right quadrant click to turn texture off; bottom-right quadrant click to turn texture on; top-left quadrant click to turn texture off.  To achieve the original image from the last step, the user would click bottom-right quadrant, turning the texture off.

Posted in Computing, Placement | Tagged: , , , , , , , | 1 Comment »

Work || Academic

Posted by Robert Chow on 16/11/2009

So I went into university today, just to say hi to all my friends, and what not, and I managed to get dragged into the Advanced Graphics lecture they had.  And I have to say, I did find it all very interesting.

Although I’m pretty much doing just OpenGL at IGI for now on the graphics side, there is no theory based around the work I am doing.  We (I say that, as if I’m taking the course, but I’m blatently not) learnt about surface reflectance, and 3 different models used to calculate how light interact with a particular object.

Without going into too much detail (because I can’t):

Bidirectional Reflectance Distribution Funtcion: simple reflection from a surface

Bidirectional Surface Scattering Reflectance Distribution Function: subsurface scattering for translucent materials

Bidirectional Texture Function: to simulate self-shadowing/scattering

Very interesting, and very theoretical.

But that’s the problem.

The majority of academic material learnt during university, college, or school, doesn’t become relevant in the working world, unless you are doing, for example, a job such as research.  You don’t need to know the theory, you just need to know how to apply and use it, and the majority of the time, it’s already done for you.

Take OpenGL for example.  I can’t say I’m an expert at OpenGL, and I don’t think I ever will be.  But in this context of theories, OpenGL takes in parameters to describe the light model.  All the theory I learnt during university,  I don’t need to know, for OpenGL does all of it for me – all I need to know is how to use the interface to create the model.  And this annoys me sometimes.

A lot of stuff I learn at university will be very irrelevant when I come to work in a job.  Of what I learn, a lot will be interesting.  Also, a lot, not so.

And I’ve been battling with myself on whether or not to take a PhD after I graduate.  The University of Manchester, School of Computer Science offer very good scholarships for PhDs, and at this current climate in the economic situation, it might definately be something worth considering.  And maybe doing some research into graphics might be rather ideal for myself.  Okay, I can use that research to create a graphical program that uses the theories of my research, but then where does it go from there?  It may be taught in other universities, but the students don’t actually need to know how it’s done – it’s already been done for them.  Like every argument, there’s always a for and an against.

There’s a PhD open day a week next Wednesday – although it’s for entry in September 2010, I guess it wouldn’t hurt to keep my options open.

Posted in Computing, Placement | Tagged: , , , | 1 Comment »