little fun with gaming physic, written using Three.js, the 3D library built ontop of HTML5 and WebGL. Physics engines like ODE or PhysX support a wide range of simulation: rigid body, soft body objects… While those engines are powerful, they are somewhat weak in scalability, e.g: to simulate the flag below, we need to create an array of hundreds of objects, which may not really feasible on small devices.
This demo tries its own physical calculation called Verlet integration: numerical method to apply Newton’s second law of motion to a system of point masses. Verlet integration, despite its complicated formal description, is simple enough to be calculated and executed in real time on the low end mobile devices.
The demo works best on Chrome but it should work on any browser that supports <canvas> (try dragging the flag to add some motion).
little technique to create terrains for use in game. Sometimes, we need to create game spaces with: mountain, plain, valley, river… the environment where our game scenes take place. It could be a labour – intensive task unless we can make use of the existing geographic data. Some games like Flight Simulator have the scenes modelled exactly after the real world.
First, we would need a topographic map, typically the height – contour map used in artillery. Nowadays, the SRTM and ASTER GDEM projects provide these data for free in digital format. They are satellite (radar) images of the earth surface with resolution upto 90m for SRTM and 30m for ASTER GDEM. I would recommend the ASTER GDEM for its higher resolution. Go to the site, follow its complicated registration process to download the data via NASA’s ftp server.
The downloaded data would be Zip packages with height info in GeoTIFF format. Next, we would use this MicroDem utility to convert it into PGM, an intermediate format that can be read by Photoshop (or GIMP). Then we save it as heightmap (PNG or TIFF format) which can be imported into most game editors. By now, the terrains are recreated exactly as they appear in our real geographical world. Just apply textures, lighting, water and other stuffs then to make it look good!
Images on the left: 1. topographic data as rendered by MicroDem, 2. heightmap (grayscale image) as viewed by Photoshop, 3. the terrain created and roughly decorated (a low – poly version), here is the Sơn Trà peninsula (or
les vallées de mon coeur 😀), the shape, the silhuette that’s long been in my heart!
Chuyện nó cũng tương tự như với
Bám theo lề trái, lề phải là việc của con cừu của giáo sư Ngô Bảo Châu. Người ta cố tình muốn ghép ông vào một bên nào đó, nhưng ông không chọn bên nào cả, cả hai bên đều giống nhau, cùng một kiểu tư duy logic nhị phân cũ rích: không “địch” tức là “ta”, không phải “nhân dân” tức “phản cách mạng”, không tốt tức là xấu, không ngay tức là cong, blahblah… một kiểu trá hình cho cái thật sự là: không giống như tôi (nghĩ) tức là tầm bậy…
Cách suy nghĩ nông dân thiển cận và bần tiện như vậy và những hậu quả trực tiếp của nó tưởng như dễ dàng nhìn thấy, song có rất nhiều người “ngây ngô không hiểu” hoặc không muốn hiểu.
A metaphor for VN software engineering’s status quo, IMHO 😬
Below: Liliputian egg and the metaphor for endianness.
ột ví dụ kinh điển trong làng Tân nhạc để minh họa cho cái tư duy hình thức sơ đẳng và thô thiển phổ biến với người Việt. Cách đây đã lâu, một nhạc sĩ rất có tiếng và có tài sau một thời gian du học ở Liên Xô về đã nói:
Văn Cao viết nhạc lẻ nhiều quá!. Thế là bắt đầu một trào lưu âm ỉ và kéo dài nhiều thập kỷ với tư tưởng chủ đạo: phê phán các nhạc sĩ “tiền chiến” sáng tác thiếu chuyên nghiệp, thiếu bài bản, tác phẩm viết ra sao toàn lẻ nhịp. Một thực tế đúng là đến 90% các sáng tác âm nhạc “tiền chiến” là lẻ nhịp.
Và có lẽ cũng đến 90% các tác giả “tiền chiến” là sáng tác ngẫu hứng, tài tử mà nên, chứ ít người thật sự có được huấn luyện trường lớp bài bản (nếu nói về bằng cấp, trường lớp thì e rằng không nước nào bằng Việt nam như hiện tại). Và cũng đúng theo nhạc lý cổ điển (Tây phương) thì nhạc viết ra nên theo luật cân phương, không nên lẻ: để hát nghêu ngao một mình thì không sao, chứ đưa vào ban nhạc, hòa âm, trình diễn lớn sẽ rất khó khăn. “Cái sự lẻ” ở các tác phẩm “tiền chiến” thể hiện những điểm sau:
Tác giả đa số là sáng tác ngẫu hứng, ít người có cơ hội tiếp xúc đầy đủ với trường lớp theo kiểu Tây phương.
Tuy không bài bản theo kiểu Tây phương nhưng đa số đều mang ảnh hưởng không ít thì nhiều của nền cổ nhạc VN.
Sự lẻ nhịp thể hiện tính chất bất ổn của thời đại, một giai đoạn có thể nói là biến động nhất trong lịch sử VN.
Bẵng đi một thời gian, tiếp xúc với âm nhạc thế giới bổng phát hiện ra rằng: âm nhạc Tây phương đương đại cũng lẻ nhịp rất nhiều, rồi quay lại nghiên cứu cổ nhạc VN thì phát hiện ra nó cũng lẻ không kém. Thế là chính những kẻ ngày xưa phê phán người khác “lẻ nhịp” giờ quay sang hô hào:
Ah, tui cũng lẻ nhịp, tui đi kịp với thời đại. Đến đây thì mọi người sẽ hiểu ra cái thói tranh luận, cái cách suy nghĩ hình thức VN là như thế nào. Nói chuyện nhạc có vẻ trừu tượng xa vời, quay sang những chuyện cuộc sống hàng ngày, đâu đâu cũng thấy nhan nhản những kiểu tư duy “hình thức” như thế.
Ngay như trong ngành IT mà tôi làm việc, cả ở những dự án lớn nhất, những công ty to nhất, mọi người cũng dành đến 90% thời gian để tranh luận những thứ vô bổ: C hay C++, C++ hay Java, Java hay .Net, nào là Design Pattern hay không, nào là Waterfall model hay Iteration model, nào là Design trước hay Code trước, v.v. Những tranh luận chỉ có thể gặp trong Gulliver du ký: một quốc gia chia thành hai phe uýnh nhau vì một phe ăn trứng từ phía đầu to, phe kia ăn trứng từ phía đầu nhỏ!
Những ai hiểu vấn đề ngay từ đầu chỉ có thể cười mỉm mà thôi, và họ đã đi tới những đâu rồi, code thì vẫn tràn lan những lỗi sơ đẳng kiểu như: mảng (array) bắt đầu từ 0 hay 1 (cũng lại chẵn hay lẻ, có thể các bạn không tin nhưng những lỗi như vậy không ít). Đó là chưa kể một số người không muốn làm việc, ngồi một chỗ bàn chuyện chẵn lẻ, dậm chân cho bụi bay mù rồi tưởng tượng là mình đang chạy! Nói chuyện kỹ thuật sợ mọi người bảo là nó chuyên biệt quá, vấn đề tự lặp lại chính nó trong tất cả những chuyện khác: nhân sự, quản lý, sale… đâu cũng thấy kiểu tư duy như thế.
Có lẻ là do sức lực chỉ vừa đủ dành cho việc nắm bắt một số kỹ năng ngôn ngữ, nên sau khi có được một số danh từ, khái niệm cơ bản… thì họ mắc luôn vào trong đó, không tự vượt lên được. Nó cũng phản ánh một điều, người Việt chúng ta rất háo suy nghĩ hình thức, rất háo những chuyện: tôi là như thế này, người khác là như thế kia, ít người có suy nghĩ độc lập (“độc lập” chứ chưa nói “sáng tạo”), hoàn toàn cảm tính và “bầy đàn”, ít người muốn làm việc, ít người thật sự muốn theo đuổi kiến thức!
The book title reminds me of the same stupid question: how to put an elephant into a refrigerator. I still insist that you can not put a normal elephant into a normal refrigerator, no matter how people is arguing about that! The question: how to eat an elephant (answer: one bite at a time) actually makes more sense to me!
Friedman is right that there have been dramatic changes in the global economy, in the global landscape; in some directions, the world is much flatter than it has ever been, with those in various parts of the world being more connected than they have ever been, but the world is not flat… Not only is the world not flat: in many ways it has been getting less flat. (Nobel Prize – winning economist Joseph Stiglitz)
The popular expression that a capitalist will even sell you the rope you need to hang him with seems to be becoming increasingly true. Aronica and Ramdoo’s book is an important addition to the literature of globalization and a necessary therapy for all those whose minds have been in touch with Friedman’s glib phrases. (blogcritics.org)
After reading the book, I got the feeling that Friedman would even sell you the rope to hang yourself (not him) and I’ve thought there’s quite a lot of people who would willingly buy the rope!
would tell you how I usually encounter a dialogue taken place in Vietnamese, a pattern that repeats over and over again, and people never learns a thing, neither do they actually have a little sense about real things behind it. Here’s how the dialogue would go on, taken an example to describe the pattern: A (a certain person):
I’ve recently read the book “The world is flat”, and really love it! Ah ha, the world is truly flat! Me:
No, the world is not flat! A:
I would suppose you don’t mean it geographically, think about it like a metaphor to get the philosophy of the book, man! Me:
No, the world is not flat! A:
You never get a thing, you crazy!
By now, anyone with a second thought should recognise my meaning either geographically or metaphorically. After that I asked him something into the content of the book. It turned out he knows almost nothing of the book except its name, and parrots the name as if he had found a “holy truth”! Yes I would certainly understand, while everyone was reading and everyone was saying the world is flat, he wouldn’t dare saying (or even thinking) the opposite. My opinion about the book could be right, or it could be wrong, but actually I won’t argue on the surface of phrases, flat or not flat is just a matter of words, what important is the book’s content.
I’d read through the more than 300 pages of the book which takes its examples, facts… exclusively in the Information Technology contexts, either in India, China or other Asian, Latin countries. It is full of details of only the IT industries, details about out – sourcing, internet, software work flow, email, network phone… the things usually seen in outsourcing service. Obviously the author meant a similarity for other fields, other industries, which seems to be a too restrictive point of view, we all know that IT in fact is only a very small fraction of the economy (taken the VN textile industry alone for an example, its estimated yearly revenue is roughly 12 ~ 15 times bigger than the IT counterpart).
The book concentrates on globalisation: the trends of out – sourcing, the way people communicates, the way firms process information… The author propagates it as “a way to be”, a trend, a life style that is absolutely irreversible. Also Friedman considers open source software
the most disruptive force of all of the trends since it allows knowledge to be freely distributed and decentralised efforts could be cooperated. Friedman also encourages young American to become scientists, engineers, mathematicians… leaving low – level labour jobs to other countries. The author also tried to relate those vast details with other profound social and political problems.
I have never read anything so “colonial” like that book. It takes a lot of facts, truths… in a small sector of the economy and tries to provide a biased and exaggerated point of view. To exactly quote the author:
When the walls came down, and the windows came up, windows can not come from thin air, there’re always “invisible” walls somewhere, and most of the times, those invisibles are much more overwhelming than the visible ones. In fact the book only receives “warm appreciations” in the field it’s related with, and aiming to, that is IT, it does tremendously receive negative reviews right in the country of its author (you can easily check out the web for that).
The world has never been flat, anywhere, anytime. It’s not flat in the sense of people about their living conditions and standards. It’s not flat in everyone’s mental and psychological status. It’s not flat in different life styles, in people’s hugely diverse definitions and pursuits for happiness. It’s not flat even in the American (or any Western) societies, whose tradition has always been the supporting for personal values, think and do differently. It’s not flat as human as a physical and mental objects are bounded to geological and social constraints, and human is more a complex creature rather than, over copper wires, a piece of (possibly cleverly falsified) transmitted information.
Screenshots of the new Unity desktop. There’s certainly a harsh non – exclusive competing between Unity and GNOME Shell. A proxy war between Ubuntu and Fedora Core, which is in turn a proxy war between Canonical and Red Hat.
Eventually, it’s user experiences that would decide which desktop is best (and best for what), and that’s still a long way to come. But technically, Unity is the first huge bold break from tradition, whose real goal deep inside is replacing completely the age – old heritage of X window system by an OpenGL – based one, a problem partially addressed in my previous post.
am trying Ubuntu’s new desktop introduced lately with Natty Narwhal (11.04). After heavy development phases, Unity has reached its alpha stage, a massive move replacing the GNOME desktop environment by a completely new one written from scratch. I’ve read too many negative reviews about Unity already, but personally I think this is a good move. Developed from Ubuntu’s Netbook Remix (which I didn’t like much, you don’t have to maximize windows like that all the time), switched from Clutter to Compiz 3D windows compositing system (my last experiment with Clutter also hinted potential performance problems), the new Unity shows a huge shift toward Mac’s style desktop. Though there’s still lots of bugs and missing features, a few things can be said about this new Unity.
First, people complains about the break from the norms, some hates Unity because it stops their accustomed habits. The GNOME community (with its long development history) can feel like being betrayed. But for all I knew after some years in graphics, UI design is the job of personality, it’s the task of a small group who decides what is “nice and beautiful”, and which is the way (for other users) to follow, it’s not the task of a committee (that is “People’s Committee” I mean 😬). As a developer, I’m often in the self – conflicting state of wondering what is “nice and beautiful”, modify over and over again some simple UI widgets. It’s no strange that UI always becomes a huge diversity (and problems) for community – driven projects. Key requirements for a UI system in my opinion are: simplicity, consistency and elegance.
For consistency and simplicity, Unity is a big step forward, reasons given that GNOME has become too complex and inconsistent (then how about the much more complex KDE?). Maximized windows have the caption and menu bars all incorporated into the system bar on top, a feature clearly borrowed from Mac, yet further varied and developed. A simple dock bar is positioned on the left, and system menu button doesn’t bring up menu but a searching panel with which you can launch programs, open files… with a few key strokes. I like this much cause it offers a form of GNOME – Do: it’s harder to launch rarely – used items (especially if you don’t remember the names) but it’s more convenient for frequently – used ones. After all, lexical memory is much faster than spatial memory, if one has been trained to that.
One more apparent physical factor is that the vertical screen space is more scarce compared to horizontal space, and 16:9 screens has become quite popular. To conserve useful screen space, UI must make constraints to the caption, menu bars, especially tool bars, there’s even recommendations on eliminating the status bar and minimizing scroll bar at Mark Shuttleworth’s (Canonical’s founder) blog. For scroll bar, that’s quite sure a mimic and modified version taken from iOS. Actually with my recent experiences with Mac and iOS, there’s still a lot of lessons to be learned from these two OSes on how to use space efficiently: remove heavy windows decorations and borders, use lighter UI fonts, smaller and more symbolic icons, design simpler widgets… and in cases even sacrifice some less – used UI features.
The trend of UI becoming simpler and more consistent is quite obvious. Efficient uses of space is the key, but spatial is not all for user experiences: keyboard and mnemonic are also important parts of the learning path (UI effects can be fancy, but over time, people get to love the simplest keystrokes that do the job). The third factor: elegance is even more a topic of debate, people can largely agree to what is simplicity and consistency, but what is aesthetics remains mysterious! Unity claims that it would directly compete Mac on UI designs and user experiences, but my opinion is that its aesthetic aspect is still far behind that of Mac, e.g: Compiz’s effects are numerous, but actually not very fine – tuned compared to the smaller set of animations Mac offers… And even Mac still doesn’t satisfy my eyes in quite many cases…
The classical SVG example rendered using a thin OpenVG layer on top of OpenGL (or Quartz) on a Mac. This is also to say goodbye to the old Lunar year (year of the tiger) that is ending!
inished with my survey on vectorial graphics, in details, about rendering SVG using Quartz, OpenGL (ES) on Mac, iOS and some Android flatforms. I’d had the chances to systematize more my knowledge on vectorial: path, stroke, anti – aliasing, solid, gradient and pattern fill, etc… Todays, people’s all talking about 3D, OpenGL, DirectX, etc… While few mentions much about 2D stuffs, I’ve traced back some historical evolution paths, since I believe that it’s through history would we understand technologies.
In the beginning, there was… PostScript
It was John Warnock who kindled the idea, he joined Xerox in 1978 and an early version of PostScript (named InterPress) became the language to drive a laser printer. Laser printer was then a revolutionary device, which offers extraordinary graphics compared to the capability of dot or matrix printers. Warnock left and founded Adobe in 1982, the company that produced well – known graphics softwares including Illustrator, king of the vectorial editors.
Then there was DPS, PDF and Quartz
But it was Steve Job who realized the superiority of PostScript and urged John Warnock to popularize it. When Steve Jobs left Apple and started NeXT, he co – developed with Adobe DPS – Display PostScript, a derivative of PostScript – the language that drives the NeXT computer’s graphics system. When Steve has got back to Apple, DPS then evolved into what is now known as PDF, and Quartz is the C binding that bridges traditional Unix programmers to the Mac graphics world.
The X window system
The X’s designers also started with a PostScript RedBook in hand. But due to various reasons including the lack of in – depth consensus about vectorial, X maintains until now low level of PostScript support. The X server can only handle basic PostScript commands (it can’t even draw splines). X took a hybrid approach using both vectorial and raster – based solutions to the problem. Also the Unix root has an impact: X is the only true client/server windowing system to the current day.
Until now, the NeXT computer remains an idealistic symbol, pure vectorial remains a pursuit, perhaps for higher – standard devices, such as with this Backbone:
Backbone is an attempt (our attempt) at creating a Really Good Desktop. The metric we use for “Really Good” is our own. In short, to us, to carry on the NeXTSTEP® and OPENSTEP® spirit!
The Windows’ GDI
Born to be the youngest of all graphics systems, GDI learns nothing from it predecessors. Neither it is device and resolution independent (like Macs) nor a true client/server system (like X). GDI sticks to screen and the pixel unit with quite a lot implementation flaws. These flaws won’t become obvious until we come to serious editing, publishing and printing: text documents and graphics designs would never has the on – screen – display and printing qualities we would expect, though various 3rd party softwares would come to rescue somewhat the situations.
Then, things change with time
The 2D graphics systems on Mac, Windows, Unix… all has different origins, and all targets different real – world problem domains. All has hardware acceleration to various levels and qualities, and it’s hard to compare them in some cases. To the present day, no system is known to keep the original idealistic model that uses pure PostScript: X has been mixed from the beginning, Mac & iOS have switched to raster to some extent, GDI is essentially pixel – based. Then come the wind of change! It would be another story, another evolution path, but today, 3D hardwares has become quite popular with reasonable prices. It’s counter – intuitive to treat 2D as a separate part from 3D, and the trend is merging 2D to become a subset of 3D rendering. However, the process hasn’t been very easy, it would take some more time to reach maturity:
WPF (Windows Presentation Foundation): first came with Windows Vista, GDI now runs as part of DirectX 3D rendering environment. Vista was not a success indeed!
QuartzGL: Quartz2D runs on top of OpenGL since OS X 10.2 (Jaguar). However, QuartzGL is not enabled by default even in the current version (10.6 – Snow Leopard) since it’s still quite buggy.
GLX & AIGLX: both has some implementation problems and is competing to each other to become the official 3D extension for X.
Taken an arbitrary GDI’s API (such as MoveTo, LineTo…) we can see the parameters’ type is integer, which is in reality the pixel unit. The Quartz’s counterparts are always in float, a virtual unit so that the APIs can be device and resolution independent.
The so called “GDI printer” is actually a bitmap device, it lacks a PostScript interpreter and hence need to be attached to a computer to do the actual computing. Reason is obvious: cheapness, adding a PostScript interpreter would significantly raise the cost!
First, it’s Jabber, then the open standard XMPP, then libjingle (the thing behind GTalk and several other VoIP applications). An essential part of VoIP, VPN, P2P technologies is ICE (Interactive Connectivity Establishment), techniques that help computers behind routers connect to each other…
ow it’s Christmas time, but this has nothing to do with Xmas except the name: LIBJINGLE. For a long time, I’ve been trying to expose one of my home servers to the Internet. Normally, you’d just need to setup dynamic DNS to update the router IP address and NAT (Network Address Translation) to forward one port onto the server. Unfortunately, my ADSL router is a special (hardware / firmware) version OEM-ed by Comtrend to FPT (the local ISP), and no matter how I configure, NAT is simply forbidden. I’ve tried various techniques to punch holes (TCP, UDP) through NAT, such as this pwnat, a trick to fool the router using ICMP echo packet. However, due to different router implementation & configuration, no technique is known to work in 100% of the cases, as pointed out in this paper.
The NAT traversal problem repeats itself in various applications: VoIP, P2P network, VPN (Virtual Private Network), networking for games… Current technologies take a dual approach in solving this: a certain kind of ICE (Interactive Connectivity Establishment) when two peers can directly connect to each other, or a central server in between in case the routers forbid it all. Such as with libjingle, Google Talk servers are used in case a direct connection can not be made. Remember the Skype’s global disconnect problem lately? It’s the same sort of problem with ‘central servers’. With these knowledge in hands, it’s turned out that setting up a VPN to access my home servers from anywhere is quite easy as follow.
Build libjingle and fwd (a simple wrapper around libjingle). Building libjingle on Debian is a nightmare (yes, it’s a real nightmare, libjingle 0.4 has a nasty code base). It took me a whole day, and after changing several dozens of places in libjingle’s code, I got it compiled and run correctly (please refer to this post for some initial building instructions). Once the transportation channel has been established with libjingle, a SSH tunnel is setup to forward a port on your roaming laptop to the SSHD port (22) on the home server:
# port 2222 to port 22 of another machine (‘buffalo’)
./fwd -u firstname.lastname@example.org -p password 2222:buffalo:22
# on your laptop from anywhere on the Internet, almost
# the same command, but the -L option for client mode
./fwd -u email@example.com -p password -L 2222:buffalo:22
# then connecting to the ‘buffalo’ box is just setting up
# a SSH session, thus a SSH tunnel inside another SSH tunnel
ssh root@localhost -p 2222
The technique works flawlessly, I can now access my home VPN from anywhere. Basically you’re inside a VPN now, so various setups at home would transparently work (strictly speaking, this is still not real VPN as TCP, UDP broadcasting may not work, but most regular connections would). Next, I proceed to exposing some of my home services onto the outside world. Again SSH proves to be such a very very powerful tool as you can build SSH tunnel inside another tunnel, which can be nested for several layers (ssh is actually means ssshhh! – sign used to signal lowering one’s voice I think):
SFTP (Secured File Transfer Protocol) is built on top of SSH, and SFTP is native to any Linux (for Windows, we could use WinSCP, and for Mac is Cyberduck). Just connect to one end of the tunnel like with SSH (localhost:2222) and on the other end of the (nested) tunnels, we get access to the whole file system.
SSH is built-in into SVN (I often use SVN by command line rather than WebDAV). Something like: svn co svn+ssh2222://user@localhost/svn/project would do the job, where ssh2222 is defined in your subversion’s configuration file (under the [tunnels] section) as: ssh -p 2222, this instructs the secured shell to connect to the host, then call the ad-hoc svnserve instead of a real web server.
This is very useful since if helps surfing the Internet securely while you’re in public. After setting up Squid web proxy on the same server, the command: ssh -N -L 8080:localhost:8888 root@localhost -p 2222 tells SSH to forward the local port 8080 to the proxy port 8888, then pointing Firefox at localhost:8080 would secure our traffic more than enough (2 levels of nested tunnels and 2 levels of port-forwarding).
I use this to casually enjoy my music collections while not at home. Install FireFly (formerly mt-daapd) music streaming server and forward the default port 3689, then I can listen my favorites songs anywhere using Rhythmbox (Linux). And since the protocol (daap) is originated from Apple, listening is also natively available on any Mac machines using iTunes.
The C-Media usb board adds a cheap (~ $5) sound solution to the Debian box, sound quality is fair enough for “ad-hoc” listening (comparable to that of AC97 on-board chip, and for serious music, there’s already the home media player).
uite a long time it takes me to finish and “stabilize” all these “home servers”… and finally here it is… On the left, you can see: #1: the 650 Watt UPS that provides about 3 hours of un – interrupted electricity for the whole system, #2: the WAP54G Access Point (hacked with OpenWRT), #3: the Comtrend ADSL router, #4: the LinkStation CHL (Debian Lenny: print server, 1T disk space for samba share, bittorrent server), #5: the LinkStation Duo (Debian Lenny: 1T of RAID-1 disk space for important data, SVN, Web, VPN servers (for remote access) and MPD music servers), #6: speakers.
All these miniature machines help streaming lossless music and HD video to the media player (LT-H90LAN – another Linux box resides in the living room). Except for the router (which is specialized hardware & firmware OEM-ed by Comtrend to FPT – the local ISP), all others devices runs Debian or another Linux variant. The total power consumption of the whole system is less than 50 Watt. Future computers would consume less than 1/10th of power compared to today’s ones… Power is the key, less power means less heat, less noise, more stable and more durable… the factors that make successful home services!
The “specimen”, an oil painting of Bửu Chỉ, the prestigious Vietnamese painter.
The lighting vector (u, v, z) in the (x, y, z) coordination system as showed in the image above (the “right hand rule”): origin at center of the picture, x points to the right, y points upward and z points toward the camera.
Result: the (medical) infrared light source turned out to be a very bad choice
f you’re into computer graphics, you probably could have learned about normal mapping, bump mapping… Last week, a colleague told me about Polynomial Texture Mapping, then the experiment below was what I was doing as an exercise to learn about this PTM. In essence, PTM could produce extraordinary effects due to the fact that it makes use of many lighting data collected in real – world condition (check out some examples on the HP’s PTM page).
To make a PTM (using tools from HP Lab), you would need to photograph the “specimen” under many light directions, then combine all together in one “texture” (using PTMfitter) in which pixel values are computed from the collected data (polynomial function).
Input to the PTMfitter is a file listing images and their lighting vector (u, v, z). Note that (u, v, z) must be a normalized vector although PTMfitter only uses (u, v) at the moment. (Getting PTMfitter to run under Linux is quite tricky since it’s linked against an very out – dated version of libstdc++).
~/ptm/ptm_11a.jpg -0.894427191 0 0.447213595
~/ptm/ptm_12a.jpg -0.707106781 0 0.707106781
~/ptm/ptm_13a.jpg -0.447213595 0 0.894427191
~/ptm/ptm_14a.jpg 0.447213595 0 0.894427191
Output is the .ptm file that can be viewed with PTMviewer. The effect is really impressive, much more realistic than the normal, bump mapping usually seen. Let verify the difference, here is the .ptm and the .pl files, you would need to download PTMviewer from HP Lab (there’re versions for Wins, Linux and Mac).
We can also use PTM to create the DOF (Depth of Field) effect. The vector (u, v, z) in this case is not lighting direction anymore but the focus point the camera is shooting at. This technique is quite useful since DOF is very expensive to compute in graphics application, and this gonna be my next experiment!