diff --git a/engine/scene.py b/engine/scene.py index a139a66..e67ad94 100644 --- a/engine/scene.py +++ b/engine/scene.py @@ -74,13 +74,14 @@ def blue(self): class Material(LoadableObject): - def __init__(self, color: Color, roughness: float, scene_loader, transparent: bool = False, optical_density: float = 1, dispersion_coefficient: float = 0.01): + def __init__(self, color: Color, roughness: float, scene_loader, transparent: bool = False, optical_density: float = 1, dispersion_coefficient: float = 0.01, is_light: bool = False): super().__init__() self.color = color self.roughness = roughness self.transparent = transparent self.optical_density = optical_density self.dispersion_coefficient = dispersion_coefficient + self.is_light = is_light self.index = scene_loader.new_material_index() @typing.override @@ -91,7 +92,7 @@ def as_array(self): self.optical_density, self.transparent, self.dispersion_coefficient, - None + self.is_light, ] return res diff --git a/shaders/render.frag b/shaders/render.frag index 526a650..7a7961c 100644 --- a/shaders/render.frag +++ b/shaders/render.frag @@ -33,6 +33,7 @@ struct Material { float opticalDensity; bool transparent; float dispersionCoefficient; + bool is_light; }; struct Sphere { @@ -316,9 +317,14 @@ float castRay(Ray ray) { return res * castRayWithSky(ray); } + res *= materials[material].color[ray.color]; + + if (materials[material].is_light) { + return res; + } + vec3 refvector = reflectOrRefract(ray, materials[material], refl.normal); ray = Ray(refl.intersection, refvector, ray.color, ray.opticalDensity, ray.isInside); - res *= materials[material].color[ray.color]; } return res;