Giter VIP home page Giter VIP logo

aurora's Introduction

Aurora - 极光

一个软件光栅化渲染器。寒假在家自学计算机图形学时利用所学知识写的一个渲染器。

特性

  • 支持使用json格式定义场景、相机、灯光等参数。
  • 支持obj格式模型,支持ppm格式图片贴图,采用双线性过滤,使用平铺纹理坐标寻址。
  • 渲染结果输出为ppm图片格式
  • 支持方向光和点光源两种光源
  • 采用Z-Buffer保证渲染正确的顺序,支持背面消影和三角形剔除(未实现三角形裁剪)

渲染结果

不同贴图

斯坦福兔子

不同光源 (平行光和点光源

彩色光源叠加 (左边黄色平行光,右边蓝色点光源

怎么构建

请确认您已经安装了make和支持C++11的C++编译器(默认使用g++,可以在Makefile修改)

  1. 下载.zip或是git clone把代码下载下来。
  2. 进入Src目录,使用make命令进行构建,构建成功后可以使用make clean把编译过程中的.o文件删除。

怎么使用

./Aurora [json场景文件]
Example:
    ./Aurora ../Example/bunny/bunny.json

配置文件格式

{
    "width" : 1920,                                         
    "height" : 1080,                                        
    "camera" :{                                             相机参数
        "position" : [0.800000, 0.800000, 0.800000],        位置
        "u" : [0.707106, -0.707106, 0],                     右向量
        "v" : [-0.408248, -0.408248, 0.816496],             上向量
        "n" : [-0.577349, -0.577349, -0.577349],            前向量
        "fov" : 80,                                         视角
        "near" : 0.1,                                       近裁剪面
        "far" : 1000                                        远裁剪面
    },
    "object" :[                                             模型参数
        {
            "path" : "cube.obj",                            obj文件目录
            "position" : [0.000000, 0.000000, 0.000000],    位置
            "u" : [1, 0, 0],                                同相机
            "v" : [0, 1, 0],
            "n" : [0, 0, 1]
        }
    ],
    "light" :[                                              光源参数
        {
            "type" : "DirectLight",                         方向光
            "direction" : [-0.267261, -0.534522, -0.801784],方向
            "color" : [1, 1, 1]                             颜色
        },
        {
            "type" : "PointLight",                          点光源
            "position" : [1, 1, 1],                         位置
            "color" : [0.5, 0.5, 0.5]                       颜色
        }
    ]
}

感谢

nlohmann/json的json库提供json解析功能

参考

《3D游戏编程大师技巧》

aurora's People

Contributors

shuaitq avatar bokjan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.