ft: refactor materials/texture decoupling

made it so all materials can use a texture for colour source. this
should be extendable if we want to do e.g. coded patterns in future
This commit is contained in:
2026-09-13 14:53:28 +02:00
parent 968c232388
commit eddde10023
12 changed files with 89 additions and 69 deletions

View File

@@ -1,10 +1,10 @@
{
"filename": "textured.png",
"filename": "textured2.png",
"image_width": 1920,
"image_height": 1080,
"max_depth": 50,
"camera": {
"anti_alias_rate": 2,
"anti_alias_rate": 5,
"fov": 50.0,
"look_from": [-3, 4, 10],
"look_at": [-3, 0.0, -10.0],
@@ -13,13 +13,15 @@
"focus_dist": 15.68
},
"materials": [
{ "type": "lambertian", "albedo": [0.2, 0.2, 0.2], "prob": 0.8 },
{ "type": "lambertian", "albedo": { "source": "./textures/earthmap1k.png" }, "prob": 1.0 },
{ "type": "lambertian", "albedo": { "source": "./textures/bluegrid.png" }, "prob": 0.5 }
{ "type": "lambertian", "colour": [0.2, 0.2, 0.2], "prob": 0.8 },
{ "type": "dielectric", "refraction_index": 1.5, "colour": [0.9, 0.1, 0.4]},
{ "type": "metal", "colour": "./textures/ballnold.png", "prob": 1.0, "fuzz": 0.1 },
{ "type": "dielectric", "refraction_index": 1.5}
],
"objects": [
{ "type": "sphere", "center": [0.0, 0.0, -1.2], "radius": 0.9, "material": 2},
{ "type": "sphere", "center": [-2, 0, -1], "radius": 0.8, "material": 1},
{ "type": "sphere", "center": [-2, 4, -1], "radius": 0.9, "material": 3},
{ "type": "triangle", "p1": [0, 0, -4], "p2": [4, 0, -4], "p3": [2, 2, -4], "material": 2},
{ "type": "triangle", "p1": [-2, 2, -4], "p2": [2, 2, -4], "p3": [0, 4, -4], "material": 1},
{ "type": "quad", "p1": [-20, -1, -20], "p2": [20, -1, -20], "p3": [20, 20, -20], "p4": [-20, 20, -20], "material": 0},