Uncategorized

  • All Developments Halted

    My primary development platform is a notebook of my father. A few days ago, his another notebook broke down, and he needs a replacement to comtinue to work. Naturally, my working station is retracted by its owner.

    Now, falling back to the original 10-year-old notebook, limited by computational power and supported standard, there isn’t much that I can do. Mesa with software rendering brings me OpenGL 2.1. Fair, but it does not allow non-power-of-2 or rectangle texture. Very bad for tone mapping and HDRR, which a screen-size texture woulde be the best option.

    HDRR algorithm should be picked and implemented before any lighting is done. Otherwise lots of parameters will need to be reviewed and adjusted after HDRR is applied. Furthermore, I don’t want to remove a fully functioning part from tthe project now just to make it run on an inferior system.

    That’s why all developments are halted.

    Since a friend of mine is learning Java at the moment, let me join him before I get a new computer (whick must support at least OpenGL 3.3, and preferably 4.0+).

  • Develog: Early August, 2011

    Project G:

    Changes are highlighted.

    • Renderer:
      • Programming interface: reimplementing
      • Documentation: ongoing
      • Camera function: done, for now
      • Gamma Correction: done, for now
      • Update rotation algorithm: to-do
      • Lighting: ongoing, Blinn-Phong model, Gaussian model done
      • Texturing: to-do, basic functionality due 25/8
      • HDRR: to-do, due 15/8
      • Shadowing: to-do, due 20/8
    • Game Logic:
      • Main loop: done, for now
      • Mouse movement and key detection: done, for now
      • Key mapper: to-do, due 23/8
    • Network:
      • Everything: currently not on schedule
    • Modelling:
      • Simple Wavefront .obj loader: done, for now
      • Simple material property loader: to-do
      • Everything else: to-do
    • Physics:
      • Everything: currently not on schedule
    • Sound:
      • Everything: currently not on schedule
    • Optimisation:
      • Migrating: reimplementing everything in C
    • Debug:
      • For all components: never ends

    Details:

    Performance is not the main reason for porting to C. Using the Python implementation, frame per second is still above 200 when there are more than 1000 triangles, and even with a simple yet expensive shader. That is, Python is not the bottleneck.

    What forces me to migrate is the limitation of PyOpenGL. With it, things like VAO, framebuffer need to come by extension. For the current version PyOpenGL 3.0.1, that means importing one more file for each functionality. Yes it is a one-liner, yet it is still very annoying (and uncertain. Why should I use ARB extensions if that those are core functionality of 3.0+?). Another thing, PyOpenGL officially supports OpenGL only up to 3.2, I want 3.3 (much easier to programme).

    With PyOpenGL 3.0.2 up, the problem of extensions seems to disappear, but 3.0.2 is still in early development stage, and I can find no easy way to install it. In fact, I cannot even find the source. The problem will go away if I can find some OpenGL extension loader, like GLEW and GLEE. Sadly, GLEE has OpenGL support up to only 3.0 (and there  is no Python binding), and PyGLEW has not been updated since 2007 (even before OpenGL 3.0 is out).

    Combine the hope of OpenGL 3.3 functionality, I turn to C. Waiting SDL 1.3 to be finalized, now I use freeglut as a temporary solution for manage OpenGL context window creation and simple mouse / keyboard detection.

    But… Using freeglut, which is capable of creating at least a 4.0 context, I am still only getting 3.1. After updating the NVIDIA driver from Fujitsu website, I finally see a 3.3 context. Going back to Python with Pygame and PyOpenGL, I see 3.3 too…

    Anyway, we are in the middle of the way to Canaan now. When SDL 1.3 turns gold, I do not want to wait for Pygame to catch up, so we will migrate to C by this year nevertheless, it is just a matter of time. Hope we will not be stuck for 40 years.

    When the C version of renderer first ran, I thought there would be a huge increase in FPS, as the window (running pretty much the same code) on OpenGLBook.com runs at about 3000 FPS. My own calculation suggests that my window (at the same 800x 600 resolution) is only running at 500 FPS at most. The difference is so huge that I immediately suspected either the (still-empty) rendering pipeline or the FPS-counting algorithm went wrong. Inspection failed to support the suspicion. It is hard to believe that it is hardware limitation. Before I move the programme to other computer, this remains a mystery.

    As of why it is C and not C++, it is because C++, from the core of the specification, is just a mess.

    The previous Develog.

  • Develog: Late July, 2011

    Changes are highlighted.

    • Renderer:
      • Programming interface: updated
      • Documentation: ongoing
      • Camera function (formerly perspective projection and zoom): done
      • Gamma Correction: done
      • Update rotation algorithm: to-do
      • Lighting: ongoing, Blinn-Phong model, Gaussian model done, adding more algorithms
      • Texturing: to-do, basic functionality due 25/8
      • HDRR: to-do, due 15/8
      • Shadow: to-do, due 20/8
    • Game Logic:
      • Main loop: done, for now
      • Mouse movement and key detection: done, for now
      • Key mapper: to-do, due 23/8
    • Network:
      • Everything: currently not on schedule
    • Modelling:
      • Simple Wavefront .obj loader: updated
      • Simple material property loader: to-do
      • Everything else: to-do
    • Physics:
      • Everything: currently not on schedule
    • Sound:
      • Everything: currently not on schedule
    • Optimisation:
      • Everything: currently not on schedule
    • Debug:
      • For all components: never ends

    Details:

    Lighting did not work properly. It turns out, when I import normals from the Wavefront .obj file, I forgot to append a 0.0 (the w component) to the normals. So, complying with the GLSL specification, the compiler appends a 1.0 to the normals, turning them into positions instead of directions. That’s why the computations all go wrong. After updating the Wavefront .obj file loading code, the normals turn back to directions, and the resulting rendering is pretty.

    Vire_test_20110730

    In the above screen shot, Gaussian specular model (a quite expensive one) is in action. Shading for the capsule is not good (look at the abrupt brightness changes and rough edges), not because the shading algorithm is bad, but because the mesh data is badly constructed. The cylinder on the left looks perfect. That is the power of more than 500 triangles.

    Texturing has been postponed, again. As I don’t have any texture by now, there is no incentive. Even if I have done it, there is no way to debug and ensure functionalities. Anyway, with shaders, we can achieve lots of wanders, even without textures. So I will focus on lighting computation in the not-so-distant future.

    For HDRR to work, frame buffer, which is what I’m studying, is required. Once the mechanics is clear, implementing it should not be very hard. Moreover, with frame buffer, many post-rendering effect and in-engine (I won’t call it in-game for now) screen shot could be achieved.

    IELTS is coming; therefore working progress of early August will be very slow, if not totally halted.

    The previous Develog.

  • 聯招放榜

    今日,聯招放榜。有人能進心儀的大學,有人空手而回。

    三萬七千人,一萬二千個學士學位;三個人爭一個位。另外有半個人有學士以下的學位。

    我就是那半個人。

    包括聯招在內,我現在有兩個高級文憑、一個副學士學位。

    可以的話,我想一個也不要。明日會去報讀澳洲的大學附屬學院。

    不行的話,再考慮副學位亦已太遲。到時,重考吧。

  • Develog: Mid July, 2011

    Changes are highlighted.

    • Renderer:
      • Programming interface: updated
      • Documentation: ongoing
      • Perspective projection: done
      • Zoom ability: done
      • Update rotation algorithm: to-do
      • Lighting: ongoing, bug-free basic functionality due 23/7
      • Texturing: to-do, basic functionality due 31/7
    • Game Logic:
      • Main loop (formerly the exit function): done, for now
      • Mouse movement and key detection: done, for now
      • Key mapper: to-do
    • Network:
      • Everything: currently not on schedule
    • Modelling:
      • Simple Wavefront .obj loader: done, for now
      • Everything else: to-do
    • Physics:
      • Everything: currently not on schedule
    • Sound:
      • Everything: currently not on schedule
    • Optimisation:
      • Everything: currently not on schedule
    • Debug:
      • For all components: never ends

    Details:

    Perspective projection is just matrix multiplication. After setting up the matrix and importing the code that actually does the maths, it’s basically done (no, I’m not going to reinvent the wheel here). All left is the tweaking. One of the outcome of tweaking the numbers that go in the matrix is that, you get different zoom effect; so the zoom functionality is a by-product. Nonetheless, this functionality is crucial for navigating in the vast space that I’m going to make.

    Currently, the rotation algorithm is based on matrix. Yet, due to how floating point numbers work in computers, errors will accumulate, and rotations will eventually become something more than just rotations. Unwanted transformation and scaling is expected when the programme runs for a long time. Planing to move to quaternion-based algorithm.

    Lighting works, if totally flawed:
    Vire test screen
    Not particularly convincing. In fact, it looks awful. Both the per-vertex (directional) and per-fragment [or per-pixel, in Direct3D parlance] (point light) lighting are enabled. Apparently, neither of them function properly. I’m still investigating whether it is the surface normals or the algorithms, or both, that get wrong.

    The previous Develog.

  • Develog: Early July, 2011

    • Renderer:
      • Programming interface: done, for now
      • Error handling: done, for now
      • Documentation: ongoing
      • Perspective projection: to-do, due 14/7
      • Lighting: to-do, basic functionality due 20/7
      • Texturing: to-do
    • Game Logic:
      • Exit: done, for now
      • Everything else: to-do
    • Network:
      • Everything: to-do
    • Modelling:
      • Everything: to-do
    • Physics:
      • Everything: to-do
    • Sound:
      • Everything: currently not on schedule
    • Optimisation:
      • Everything: currently not on schedule
    • Debug:
      • For all components: never ends
  • 六七月記

    讀者,久違。

    今日七一遊行,不能出席,抱歉。

    我開始懷疑,高考在六月三十 (七一前夕) 放榜,到底是否只是巧合。這個放榜,代表一班青少年初踏入社會;或者,他們會拿到一張社會的入場卷;或者,他們今日拿到手的已經是他們的入場卷。今日,他們需要為自己的前路著想、計劃;今日,他們或要走遍港、九、新界,只希望找到一個容身之所;今日,他們要為自身利害而放棄追尋公義。

    慚愧。

    放榜,有人歡喜有人愁。今年,我校愁人居多。學習風氣?或者關事,但我仍然覺得我們今年運氣欠佳。數統班居然連一個 C 都無,全班都無,實在難以置信。

    我考得怎樣?

    科目 等級 分部等級
    化學 D  
    物理 D  
    英文 D
    聆聽 D
    寫作 D
    閱讀 C
    說話 F
    綜合能力 D
    中文 E
    實用文 C
    閱讀 D
    聆聽 A
    說話 E
    文化題 UNCL
    數統 E  

    拿到成績單時,有點錯愕。雖然比想像中差,但也不敢太多怨言。怎樣也好,也算是 full cert。

    英文柯佬 F。考試時偷看到考官寫字,九分給兩分,都估到九成。不過,以我的英語能力都只能得 F,除了「頂你個肺」,我都無第二句可以講。我是作家,不是演說家或詭辯者。

    文化題嘛……不是沒有預計過,不過看到時還是「屌」了一聲。同兩年前一樣:我有寫字,你怎能給予我「不予評級」?那可是我花廢個多小時寫成的文章!不過,怎樣也好,兩科語文各炒一份卷還能平安無事,實在萬幸。

    話說,我高考真是會考的翻版。中文合格,英文比中文高分;中文有一份卷未獲評級;數剛合格 (我認我數學差);其他科目基本同分。前人說,會考成績降兩等便是高考成績;想不到我兩科高級程度科目就此驗證且延續預言。

    以現在的成績,Jupas 還有派位的機會;不過幾乎整個排序要翻轉。當初估計 CC 會是自己考到的中等水平,實在天真得撚。

    這兩天嘗試找其他「大路」的出路:副學士、高級文憑。不過,一來懶惰,二來手腳慢,三來眼角高,最後一科都無報名。有一個有興趣讀的 IVE 學位在手,又看不到其他課程的特別之處 (加上銜接好的課程都已額滿),實在沒有動力去報名。且看聯招公佈結果後有何發展吧。

    最近多次自問:「大學學位是否必須?」對不起,我們在香港。對不起,我們將在維護一己私利之時,令這個惡性循環持續下去。

  • 近況

    久違了。最近比較忙,令計畫都一拖再拖;連網誌都荒廢掉。

    遊戲計畫。卡在 OpenGL 渲染程序的 VBO 之中一個星期有多,最近終於有所突破,畫出第一個三角形。希望短期內不會再「卡關」。

    另外,原來 Pygame 與 PyOpenGL 均未完全支援 Python 3.x。好在不同版本的 Python 能並存於同一系統下,於是我順利回流到 2.7 及 2.6。

    原本打算,寫完 Project alpha 第六章後,就着手建立新網站,並在上載第七章前完成過渡。可惜,工程比想像中大,令第七章延遲甚久。過檔暫時無限期押後。

  • 無題

    凡係人,總須決擇;凡決擇,總有後果。

    我這個決定,對嗎?錯嗎?無論如何,從今以後,我就要帶着後果活下去。後悔?奢望矣。

    如果這世界有快速儲存及載入,你說多好。偏偏就是沒有。我們,只能夠揹起名為後果的重擔,繼續走下去,直到遊戲終結。

    這幾日,天色灰暗;這幾日,看什麼也暗淡無色。仰望,一片灰暗;閉目,灰暗一片。

    天空,有雨;臉上,也有雨。我開始討厭這不易哭的性格。天空,由你來替我流下眼淚,可以嗎?

    但願這是最後一篇《無題》。