Skip to content

Haruka-Hua/Pixel-Render

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Pixel Render

不依赖三方库和框架,直接操纵像素在 CPU 上跑 Shader | Tsoding

I watched this video on bilibili which used CPU to render pixel shaders without any third-party libraries or frameworks. I found it very interesting and decided to implement it myself.

Sadly, although I followed the video step by step, I couldn't get the same result as shown in the video. However, I did manage to create a beautiful animation with the help of AI, who helped me to do some math calculations to fix some problems.

If you want to see the final result, you can go to the asset page where I uploaded the output video.

Build & Run

Compile and run C++ code

You need to have a C++ compiler installed on your system.

For example, you can use g++.

You can compile and run the code using the following commands:

g++ render.cpp -o render -lm
# if you are a Linux user, make sure to add execute permission:
# chmod +x render
./render

Concatenate pictures into a vedio

You also need to have FFmpeg installed on your system to convert the output raw file to a video file.

To install FFmpeg:

  • For Ubuntu/Debian:
sudo apt-get install ffmpeg
  • For macOS (using Homebrew):
brew install ffmpeg
  • For Windows users, you can download the FFmpeg executable from the official website and follow the installation instructions. It is important to add bin directory to your system PATH. (You can search online for how to do this.)

Now you can use the following command to convert the raw output to a video:

ffmpeg -i output-%02d.ppm -r 60 output.mp4

Play the vedio!

Finally, you need a video player that can play the output video file. Any video player that supports .mp4 format should work. (You know how to play a .mp4 vedio on your computer, right?)

For example, you can use mpv:

mpv output.mp4

About

A pixel render based on .ppm files and implemented by cpp.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages