Frame of 42yeah
Read a shader a day, (kinda) keeps the doctor away

Days Until Postgrad Examination (CN)

Posted in 2020-05-14 00:00:00 +0000
2020 考研是什么?2020 考研相信大家都很熟悉,但 2020 考研到底还有多久呢,2020 考研对我们有什么影响?接下来就让小编带着大家了解一下 2020 考研还有多久吧。2020 考研还有多少天?相信大家都很惊讶,小编也觉得十分惊讶。那么 2020 考研到底还有多久呢?我们以 2020 年 12 月 21 日作为 ddl, 这里是剩余的天数: 距离考研开始还有 ??? 天 以上就是 2020 考研还有多久的天数了,欢迎大家在评论区留言与小编一起讨论 2020 考研还有多久。 continue reading

Raymarching Cheap Subsurface Scattering

Posted in 2020-05-13 00:00:00 +0000
It’s been a while, school’s been busy, yada yada yada. I’ve got a new phone! I am considering about migrating this site to 42yeah.me or 42yeah.com, which miraculously isn’t occupied by anyone! Long story short, I’m back! At least for a while. And as I am back, let’s do some Subsurface Scattering! Introduction Subsurface Scattering (SSS) itself in nature is a very complex aspect, as light photons shoots through surface and bounce inside it for a little bit, before shooting out again. This ca... continue reading

Raymarching Depth of Field

Posted in 2020-05-02 00:00:00 +0000
Depth of field is usually used in cinematic scenes. Or when you are looking at things very, very small. It blurs the things the camera is not focusing. And I like things when they are small! And blurred! So this time, let’s take a look at this neat stuff, dof. First, let’s appreciate this masterpiece by P_Malin: Introduction DoF certainly adds a sense of depth, and it directs viewer’s attention onto certain stuffs. From what I’ve understand after reading P_Malin’s source code & his re... continue reading

Raymarching Refraction

Posted in 2020-05-01 00:00:00 +0000
Happy International Except America Labor Day! I will save the rest for September :P. Well, back to the magnificent world of raymarching. We’ve come this far, and now it’s time for us to do the surface refraction too, right? Introduction Refraction is like a twin sister to reflection (mostly), because ice, water, glass, and other stuffs I can’t think of usually consists of both. GLSL has a refract function just like reflect, which is convenient, however it also accepts a parameter eta, which... continue reading

Raymarching Reflection

Posted in 2020-04-30 00:00:00 +0000
Reflection is quite important when you are projecting your ray onto shiny stuffs. Mirror, metal, loads of things that start with an m… You get the gist. So today, let’s take a look at reflection! If you want to get pass my words and just go to shader, you can visit shane’s shader. He writes perfect comments! Introduction Reflection in raymarching is easy, if not a little bit expensive. If you’ve learned ray tracing before, it will make a lot of sense to you. It is roughly divided in 3 parts... continue reading

Raymarching Water Body - Part II

Posted in 2020-04-29 00:00:00 +0000
WARNING: WebGL2 required! So if you are not using a PC with a better-than-below-average GPU, stuffs below might not work. Also, you might want to read part I first. Resumé So first, a resumé about what we’ve done last time: mat2 rot2d(float deg) { float rad = radians(deg); float a = sin(rad), b = cos(rad); return mat2(b, a, -a, b); } vec3 getSkyColor(vec3 rd) { vec3 sky = vec3(0.58, 0.77, 1.0); return mix(sky, vec3(1.0), clamp(rd.y * 1.5, 0.0, 1.0)); } // === WAVE C... continue reading

Raymarching Water Body - Part I

Posted in 2020-04-28 00:00:00 +0000
WARNING: WebGL2 required! So if you are not using a PC with a better-than-below-average GPU, stuffs below might not work. Introduction Water is beloved by all humankind (I think). And who doesn’t like water generated by pure math? Well, not me! So today, I am going to break down Seascape (finally not fruxis anymore!), and let’s see how that works out! Anyway first, a really basic scene: vec3 getSkyColor(vec3 rd) { vec3 sky = vec3(0.58, 0.77, 1.0); return mix(sky, vec3(1.0), clamp... continue reading

Ambient Occlusion in Raymarching

Posted in 2020-04-27 00:00:00 +0000
Ambient Occlusion (AO) is another key to photorealism, and it adds another great deal to the scene. It mimicks diffuse reflection. I used to implement it in OpenGL, but I was less familiar back then. Well, am I any better now? We will see! Introduction Let’s take a look, again, at my recent raymarching lab rat, Fruxis: See the darkened corers near the walls? Now that’s ambient occlusion. Removing it will make the scene looks a tad more artificial: Even though it’s not too bad without ... continue reading

Soft Shadow in Raymarching

Posted in 2020-04-26 00:00:00 +0000
Shadow. The stuff that adds a great deal of realism to the scene. Thanks to the great people in Shadertoy’s Discord server, I am finally able to understand how soft shadow works! So I am writing this down today. Introduction Well, let’s implement a basic scene first: vec3 sunDir = normalize(vec3(0.0, 1.0, 1.0)); float ball(vec3 p, vec3 off) { p -= off; return length(p) - 0.5; } float sol(vec3 p) { return p.y; } vec2 map(vec3 p) { float closest = 1000.0; float id = ... continue reading

Fractal Brownian Motion (fBm)

Posted in 2020-04-24 00:00:00 +0000
Warning: There are a large amount of stuffs here using pretty modern JS and WebGL2. You might want to use a newer computer and a nice browser (say Chrome?) to view this. If you already do, never mind! Controlling randomness is an important part in computer graphics. So let’s take a look at fractal brownian motion today, which is great at generating hills (more than perlin noise), clouds, valleys and such! Introduction Fractal Brownian motion, or fractional Brownian motion, is a kind of Bro... continue reading

Identifying The Direction Of Cross Product

Posted in 2020-04-23 00:00:00 +0000
When you are doing math, you might come up with a question: what’s the general direction of a cross product, you know, without boring calculation? Well, we use the right hand law! It’s pretty much like the right hand law in electromagnetic or whatever, excuse my physics. Anyway, when happens, you can draw a graph like this: And put your right hand parallel to the , like this: Now make your hand into a fist. Fistify your hand! And finally, the thumb direction is the general cross ... continue reading

Implementing the Fortune Wheel In JavaScript

Posted in 2020-04-21 00:00:00 +0000
Have you ever stay up at night, feeling hungry, and decides to leave whether you should have a hot, satiating meal or not up to fate? Have you thought that if you roll more than 3, you could just go but this happens? Then you feel like the random system they have is crappy and dammit, I am going to implement a physics-based spinning wheel so I can guarantee its unfairness? Well fear no more my friend, for you’ve come to the right place! Today I present: the Spinning Wheel of FATE! Introdu... continue reading

Finding You And Friend's Common Games In Steam

Posted in 2020-04-18 00:00:00 +0000
(Featured image by Aleks Dorohovich on Unsplash.) Sometimes, the games are many, and the time is little. How can you quickly find the common games between you and your friend? Well, I am going to implement it here, and then tell you how to implement (It’s pretty easy)! Also, I definitely won’t track you (this site has analytics though. Please keep it on because I only have ~2 visitors every day!). Try It Out First, you need to get your Web Steam API Key here: https://steamcommunity.com/dev... continue reading

Cycles Inside Yada Yada Yada, Building Could Produce Unreliable Results

Posted in 2020-04-15 00:00:00 +0000
I don’t know if anyone else has this issue, but lately (2~3 months maybe?) when I was using Xcode, I am getting this error, and it has been very, very annoying. It has become such a PITA now, that I actually have to find a way to solve it! Can you believe it? Introduction Cycle inside blah; . This usually can be resolved by moving the target's Headers build phase before Compile Sources. Cycle details: → Target 'blah' has copy command from 'yada' to 'ugh' ○ Target 'blah' has link comma... continue reading

In Memory Of John Conway: Implementing Game Of Life

Posted in 2020-04-12 00:00:00 +0000
John Conway, an extraordinary mathematician, passed away today due to covid-19. He is a great man and he inspired me to program. When I was small and I just got a phone, I found this game of life and I played with it a lot. It’s quite fun, as there are loads of results coming from such simple rules. And in memory of this great man, today we will implement this great algorithm made by John Conway himself: The Game of Life! Introduction Game of Life comes with extremely simple rules. There ar... continue reading

Writing an Evaders Game In OCaml With TSDL

Posted in 2020-04-11 00:00:00 +0000
So, writing an Evaders game in OCaml. Whenever I learn a new language, I will try to write a really basic game, which looks a little bit like Space Invaders, and I will implement it from scratch (apart from graphics libraries). So let’s get started! Introduction You know, Evaders isn’t that like Space Invaders: you cannot shoot. Blocks simply comes from another direction, and you need to dodge them. And as game progresses, more and more enemies will appear, and you will need to dodge more... continue reading

UDP Hole Punching With STUN

Posted in 2020-04-06 00:00:00 +0000
Photo by Iswanto Arif on Unsplash! Let’s get started! Introduction STUN is a neat NAT (Network Address Translation) traversal technique. It is also very, very useful when it comes to P2P connections (even though it has its limitations). But why do we need them anyway? Well first, we gotta see what NAT is. So, back in the good old days, when IPs are still abundant, everybody has an IP on the Internet, and all of them are directly routable: Nobody has a problem, and everyone was happy. B... continue reading

Stop Belittling Myself

Posted in 2020-02-29 00:00:00 +0000
Because of parental education, and a bit of myself, I often belittle myself when others compliment me. Also I am quite afraid that what I make is usually garbage and other’s aren’t. But you know what? No. None of these makes sense. Why should I do that anyway? Truth is, there’s a huge difference between belittling oneself and being modest. “Man are you great, “ I say. “I am a piece of trash though.” I say. There’s absolutely no benefits from this whatsoever. There is also an additional chanc... continue reading

Using Travis CI to Build C++ Code On Windows Using CMake and NMake Then Releasing Them

Posted in 2020-02-27 00:00:00 +0000
Man, I can’t believe I had fun with this all day. (Actually it wasn’t fun at all.) Introduction As I am only using a macOS at home, and I don’t really have a Windows to compile my stuffs into Windows executable, I am starting to look for a CI service to help me do that. And there it is: Travis CI. Nice documents, free for open source projects, GitHub Student Packs goodies, etc. I am so using it! Building First of all, of course, is to register an account at Travis CI. Now that’s easy! Aft... continue reading

Object Selection With Ray Marching

Posted in 2020-02-24 00:00:00 +0000
There are loads of objection selection algorithms out there… I guess? I didn’t check! Anyway, I am making this game, and I need objection selection. So I said to myself, why not use ray marching? Because they fit! So I implemented it. This methods might not be the best method out there (trust me, it will not be), and it might be the worst. But it works! Introduction I don’t know, I might be the first guy to use such a method. I mean there are ray tracing object pickings out there, but I am ... continue reading

Shaders For Beginners (Me) - Part 2

Posted in 2020-02-15 00:00:00 +0000
Well, I said there’s going to be a part 2, right? I fullfilled my promise! Introduction Shaders are good stuffs. You and I both know that. So today, I think “why don’t I go over those shaders and learn something new in the process?”, and then began reviewing those old shader knowledges. Well, so this time we are going to talk about all sorts of shaders, most of which are from here. Go check it out! If you didn’t read part 1, go here. I’ve updated the scene and now a diffuse texture is inclu... continue reading

Shaders For Beginners (Me) - Part 1

Posted in 2020-02-13 00:00:00 +0000
Shaders are good stuffs. You and I both know that. So today, I think “why don’t I go over those shaders and learn something new in the process?”, and then began reviewing those old shader knowledges. Well, so this time we are going to talk about all sorts of shaders, most of which are from here. Go check it out! Preparations Well, for gaming shaders to work, a scene is needed. That is why I built one using blender. You can get it here if you want. It looks just like the featured image: a fe... continue reading

Mandelbrot Set

Posted in 2020-02-12 00:00:00 +0000
Mandelbrot! The “Hello world” of GFX programming. I don’t know why I am not learning it until now. And as the tutorials are a little bit scarce, this actually took more time than I thought, and it is also easier than I thought! Featured image by myself (yay!). Introduction As we all know, Mandelbrot Set belongs to a category named “fractal”; and as Grant from 3Blue1Brown explained, Fractals are typically not self similar. A fractal is just a shape with non-integer dimension, and it won’t be... continue reading

Worley and His Noise

Posted in 2020-02-11 00:00:00 +0000
Now, today I am gonna present the famous Worley Noise, which I had absolutely no idea before. I learned it from here. Go check it out, it has interactive playground and all! Featured image by myself (finally!). Introduction Now, you must be wondering why you should read my blog post if there are so many far better tutorials out there. And you are right, boi. I have absolutely no confidence in what I write, and that’s why I leave all those references. So, Worley Noise! If you didn’t hear abo... continue reading

When Nostalgia Hits, It Hits Hard

Posted in 2020-02-11 00:00:00 +0000
Nostalgia is some sort of emotion you don’t think you have during ordinary life. Today in my dreamscape, I was hit by this really strong wave of nostalgia, and now nearly all my memories of high school is covered in this old school, and comfortable, safe filters. It’s already 3 years! I can’t believe it. Highschool is arguably the happiest duration of my life (until now, at least): friends all around, and I only need to study then, my parents won’t let me use a mobile phone during the last y... continue reading

All Sorts of Sorts

Posted in 2020-02-01 00:00:00 +0000
Yeah sorry, but I have to post this: I mean, “All Sorts of Sorts”. How brilliant is that? Alright! Because of this novel coronavirus thing, I am still getting cooped up in the house having nothing better to do, so today let’s review what’s going to test me in the future: sorting algorithms! Also do you guys know “sort” means “spell” in French? Just sayin’. Featured image by Markus Spiske on Unsplash. Introduction You must’ve watched those YouTube videos, in which you can hear those sort... continue reading

Perlin Noise

Posted in 2020-01-31 00:00:00 +0000
In the world of shaders & procgen, Perlin Noise is very serious stuff. Its ability to generate nonsense, however continuous image has been really useful in texture synthesis & that kind of stuffs. This featured image is clouds, made famous by Inigo Quilez, using only a noise texture. Introduction Perlin Noise might not seem straightforward at the very start. I mean, what was that? It’s just some continuous grayscale pixels. However, if we assign thresholds for the grayness, and th... continue reading

Overlapping Wave Function Collapse

Posted in 2020-01-30 00:00:00 +0000
Wave Function Collapse is quite a nice algorithm invented by Maxim Gumin. However, Gumin’s source file could be really obscure and hard to understand, so I am writing what I’ve learned so far here, so that I could remember it when it is needed. Also, we are talking about the overlapping model here, not the tiled model (as it is what I am interested in). Sorry! All Wave Function Collapse below refers to Wave Function Collapse, the overlapping model. Introduction What the hell is Wave Functio... continue reading

macOS Signing Problem

Posted in 2020-01-07 00:00:00 +0000
not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. You develop using Xcode? Well, you’ve seen that, right? Xcode, being part of macos, could be a PITA at times. But here comes the solution! (And it’s relatively easy!) Let’s take OpenCV for an example: cd /usr/local/lib # Just go to wherever the library you wanna sign codesign -fs <identity> libopencv* Replace <identity> with whatev... continue reading

Uninstalling Steam

Posted in 2020-01-03 00:00:00 +0000
I am uninstalling Steam (and announcing it here). It’s a necessary preparation for the grad entrance exam. Am I crazy? Well no! I am using my slipping-away self-control to do the right thing (maybe). Hopefully by the time of next year, I am successful and is bragging to everybody around me. But right now I really don’t have that much right to do sucha thing. Uninstalling Steam means I myself will no longer play any games on Steam, thus the ones playing on Steam will only be my father & ... continue reading

Hello, 2020

Posted in 2019-12-31 00:00:00 +0000
Hello 2020! I am not going to write much here. It’s 31/12/19, aaand I am still reviewing my embedded. I suck at it. Seriously. I hate this thing. You will still hate it ten years in future, trust me, man. It’s a new decade, & I still get my big ambition. Stuff might be going great, but I am fucking lazy lately, and I don’t know why. I can’t really tell. Why man? Snap out of it! In the next decade, I am gonna turn 30. I feel so old. But it’s OK man! Ten years ahead of me! And stuffs a... continue reading

Let's Ray March!

Posted in 2019-12-26 00:00:00 +0000
Title done by flopine, she’s awesome! Warning: This post might be shittily written. If you just want the code, dive right to the Code! section. Sorry for the inexplicable explanation. Sometimes I just fail to explain stuffs. You might be able to understand the code more easily than the shitty stuff I write. I accidentally (did I?) bumped into Shader Showdown and now I really crave for some awesome shader coding. However I know nothing about it & I just started to understand stuffs r... continue reading

What Is SQL Auditing?

Posted in 2019-12-25 00:00:00 +0000
Well, the end of the semester is drawing near, and I’ve got MS SQL homework to do. So let’s turn this post into a… Homework? Note! Sorry but this post will not contain any code. First, let’s take a look at the definition of auditing from docs.microsoft.com (that is, like, so official!): Auditing an instance of the SQL Server Database Engine or an individual database involves tracking and logging events that occur on the Database Engine. SQL Server audit lets you create server audits, whi... continue reading

Solving -lssl Not Found Problem Under macOS Catalina

Posted in 2019-12-23 00:00:00 +0000
Catalina sucks. macOS sucks. It updates and updates and makes things obselete almost everyday. Yet we love it and we use it. So here we are, trying to figure out the mysterious disappearance of -lssl! Before Catalina If you are still using Mojave or something, the solution is straightforward. Just xcode-select --install And you are done! Of course, you need to have Xcode installed first. Or do you? Just joking! Haha! xcode-select doesn’t require xcode installed. macOS is that fun. Afte... continue reading

Model Loading Using TinyOBJLoader

Posted in 2019-12-10 00:00:00 +0000
Model loading is a very important aspect in Computer Graphics. Sometimes you really need something with a good-looking pattern, you know. Then we got assimp, which is great for model loading and also bulges in size. So what’s the best substitution? tinyobjloader, I wager. Tiny but powerful single file wavefront obj loader written in C++03. No dependency except for C++ STL. It can parse over 10M polygons with moderate memory and time. tinyobjloader is good for embedding .obj loader to your... continue reading

Matrix: What The Hell?

Posted in 2019-12-08 00:00:00 +0000
Let’s take a look at Linear Algebra. Too hard. Goodbye. Just joking! Hahaha! Of course there is no detour. You have to learn it. So today let’s review a few most basic matrix operations, in case I lost my memories. Addition Matrix addition is straightforward and stupid: Subtraction Subtraction works the same way. Multiplication Here’s where things begin to get funny (or annoying). However, according to 3b1b, this could be very much interpreted in a very intuitive way. First, let’s... continue reading

WebSocket Echo Server

Posted in 2019-12-07 00:00:00 +0000
42yeah: Alright, what should I write today? Well let’s learn WebSocket! Anonymous: You never learned ws before? What the hell? F: Yeah, bite me A: You suck, man F: Yeah whatever And that takes us to today’s topic: WebSocket! I might not know a lot of this, but I knew about socket! And I guess we all agree that a most basic socket application should be the echo server, right? You might or might not know what a “echo server” is, but I will try to explain, nevertheless. Echo server is like ... continue reading

No Phone Monday!

Posted in 2019-12-05 00:00:00 +0000
No Phone Monday is just as its name intended, that you play no phone on Monday! It’s gonna be a little challenge set by myself. I dunno why I am setting this challenge for myself. Maybe I am pursuing a greater goal or something, I don’t care. Mais, here’s the rule: No phone on Monday. I can use computer & other stuffs, as long as it is not that of iOS or Android or any system based on a RISC command set. If I fail, I am gonna post my failure date here. The No Phone Monday starts... continue reading

Random Thoughts About Conciousness

Posted in 2019-12-02 00:00:00 +0000
In my opinion, conciousness is a human’s reason of existence. According to René Descartes: Cogito Ergo Sum, which roughly translates to I think therefore I am, humans are only considered to be human if this human could think. Maybe that’s also why a human is partially consider dead when he’s brain dead(also that brain-cell-not-able-to-respawn stuff, yeah). So I am going to post my thoughts about conciousness below, and it might seem a tad hilarious, but I don’t care because nobody knows what ... continue reading

Kerbal Space Program 2 Will Be Out Soon!

Posted in 2019-12-01 00:00:00 +0000
You know KSP2 is coming, right? Damn right I am excited! Come on, let’s see some new features I ripped off from the official homepage of KSP2! First, let’s see what the official guy says: With the original Kerbal Space Program having become one of the most beloved games of all time and now bigger than ever, Kerbal Space Program 2 has been fully redesigned from the ground up to meet the demands of modern and next-generation space exploration, all while maintaining the monumental foundatio... continue reading

Postgrad Prep - UPDATING! (CN)

Posted in 2019-10-19 00:00:00 +0000
考研对于我来说,大概可以省去整个英语,做做题就可以了。但是数学和政治以及数据结构仍然不容小觑。所以以下就是我的准备: 考研专业:专硕 广州大学 – 电子信息 302 数学二 视频:张宇的 高等数学 习题:基础数学 660 101 思想政治理论 肖秀荣,通常在考试临近前放出押题,很准 914 数据结构(自命题) 历代广州大学 914 真题和答案 复试:C 程序设计 这个我也不知道要看啥。。。到时候和数据结构一起看吧。。。 梦幻指导老师 高鹰!高鹰的计算机图形学!课程目标如下: 培养学生掌握计算机图形生成与处理的基本原理和基本算法、特别是对直线生成算法, 图形变换方法,图形交互技术,几何造型技术和真实感图形生成技术等基本原理和技术应有较深入的了解。通过课程学习使学生掌握直线生成算法,图形变换方法,图形交互技术,几何造型技术和真实感图形生成技术等基本算法的实现,使学生具有设计图形程序的能力和虚拟现实技术的应用能力。 课时: 第1章 计算机图形学概述(2 学时) 第2章 交互式图形系统(2 学时) 第3章 基本... continue reading

I Am Gonna Start From Right Here

Posted in 2019-09-13 00:00:00 +0000
I am gonna migrate the contents in my original blog. It’s mostly Chinese. Well all of them Chinese. Since I’ve been looking for a better blogging platform recently, this is the best one I’ve seen. I guess someone’s actually going to see what I post here! Everything is so hopeful! At the mean time, let’s talk a bit about myself. I am an undergrad studying in Dongguan University of Technology. I major in Computer Science, but somehow I didn’t really wanna learn that. Now my thought is to take... continue reading