|
|
@ -6,6 +6,7 @@ |
|
|
|
#include "Object.h"
|
|
|
|
#include "Vector3.h"
|
|
|
|
#include "Sphere.h"
|
|
|
|
#include "Texture.h"
|
|
|
|
#pragma comment(lib, "winmm.lib")
|
|
|
|
static int sTotalPixelCount = 0; |
|
|
|
static int sViewportWidth = 0, sViewportHeight = 0; |
|
|
@ -13,8 +14,8 @@ static Camera* sCamera = nullptr; |
|
|
|
Sphere sphere(Vector3(0.0f, 0.5f, 0.0f), 0.5f); |
|
|
|
static Object* sRootObject = nullptr; |
|
|
|
static Material* lambert = nullptr; |
|
|
|
static int sSampleCount = 6; |
|
|
|
static int sMaxBounceTime = 30; |
|
|
|
static int sSampleCount = 256; |
|
|
|
static int sMaxBounceTime = 2; |
|
|
|
void AddObject(Object* object) { |
|
|
|
if (sRootObject == nullptr) { |
|
|
|
sRootObject = object; |
|
|
@ -30,11 +31,18 @@ void Init(int width, int height) |
|
|
|
sViewportHeight = height; |
|
|
|
sCamera = new Camera(45.0f, float(width) / float(height)); |
|
|
|
sCamera->LookAt(Vector3(3.0f, 1.0f, 3.0f), Vector3(0.0f, 0.0f, 0.0f), Vector3(0.0f, 1.0f, 0.0f)); |
|
|
|
Material* earth_material = new LamberMaterial(Vector3(0.5f, 0.3f, 0.1f)); |
|
|
|
Material* metal_material = new MetalMaterial(Vector3(0.9f,0.9f,0.9f)); |
|
|
|
Texture2D* solid_color1 = new TextureSolidColor(Vector3(0.1f, 0.4f, 0.7f)); |
|
|
|
Texture2D* solid_color2 = new TextureSolidColor(Vector3(0.5f, 0.3f, 0.1f)); |
|
|
|
Texture2D* solid_color3 = new TextureSolidColor(Vector3(0.9f, 0.9f, 0.9f)); |
|
|
|
|
|
|
|
Material* earth_material = new LamberMaterial(solid_color2); |
|
|
|
Material* metal_material = new MetalMaterial(solid_color3); |
|
|
|
AddObject(new Object(new Sphere(Vector3(0.0f, -1000.0f, 0.0), 1000.0f), earth_material)); |
|
|
|
AddObject(new Object(new Sphere(Vector3(-1.0f, 0.5f, 0.3), 0.5f), metal_material)); |
|
|
|
lambert = new LamberMaterial(Vector3(0.1f, 0.4f, 0.7f)); |
|
|
|
|
|
|
|
TextureRGB* rgb = new TextureRGB(); |
|
|
|
rgb->Set("earth.bmp"); |
|
|
|
lambert = new LamberMaterial(rgb); |
|
|
|
AddObject(new Object(&sphere, lambert)); |
|
|
|
} |
|
|
|
|
|
|
|