diff --git a/punyverse/assets/textures.txt b/punyverse/assets/textures.txt index 92765c9..5b915b5 100644 --- a/punyverse/assets/textures.txt +++ b/punyverse/assets/textures.txt @@ -3,6 +3,8 @@ mercury.jpg earth.jpg +earth_normal.jpg +earth_emission.jpg cloudmap.jpg moon.jpg mars.jpg diff --git a/punyverse/assets/textures/earth_emission.jpg b/punyverse/assets/textures/earth_emission.jpg new file mode 100644 index 0000000..e353016 Binary files /dev/null and b/punyverse/assets/textures/earth_emission.jpg differ diff --git a/punyverse/entity.py b/punyverse/entity.py index 73df6a2..9339590 100644 --- a/punyverse/entity.py +++ b/punyverse/entity.py @@ -293,6 +293,7 @@ class SphericalBody(Body): self.texture = get_best_texture(info['texture']) self.normal_texture = None + self.emission_texture = None self.sphere = self._get_sphere(division, tangent=self.type == 'planet') self.atmosphere = None @@ -302,6 +303,9 @@ class SphericalBody(Body): if 'normal_map' in info: self.normal_texture = get_best_texture(info['normal_map']) + if 'emission_map' in info: + self.emission_texture = get_best_texture(info['emission_map']) + if 'atmosphere' in info: atmosphere_data = info['atmosphere'] atm_size = world.evaluate(atmosphere_data.get('diffuse_size', None)) @@ -346,12 +350,20 @@ class SphericalBody(Body): shader.uniform_texture('u_planet.normalMap', 1) shader.uniform_bool('u_planet.hasSpecular', False) - shader.uniform_bool('u_planet.hasEmission', False) - shader.uniform_vec3('u_planet.ambient', 1, 1, 1) + shader.uniform_bool('u_planet.hasEmission', self.emission_texture) + if self.emission_texture: + glActiveTexture(GL_TEXTURE3) + glBindTexture(GL_TEXTURE_2D, self.emission_texture) + shader.uniform_texture('u_planet.emissionMap', 3) + shader.uniform_vec3('u_planet.ambient', 0, 0, 0) + shader.uniform_vec3('u_planet.emission', 1, 1, 1) + else: + shader.uniform_vec3('u_planet.ambient', 1, 1, 1) + shader.uniform_vec3('u_planet.emission', 0, 0, 0) + shader.uniform_vec3('u_planet.diffuse', 1, 1, 1) shader.uniform_vec3('u_planet.specular', 0, 0, 0) - shader.uniform_vec3('u_planet.emission', 0, 0, 0) shader.uniform_float('u_planet.shininess', 0) diff --git a/punyverse/world.json b/punyverse/world.json index 0ccdee4..cb9936f 100644 --- a/punyverse/world.json +++ b/punyverse/world.json @@ -57,6 +57,7 @@ "rotation": 86400, "division": 90, "normal_map": ["earth_normal.jpg", "earth_normal_small.jpg"], + "emission_map": ["earth_emission.jpg", "earth_emission_medium.jpg", "earth_emission_small.jpg"], "atmosphere": { "cloud_texture": ["cloudmap.jpg", "cloudmap_small.jpg"], "diffuse_texture": "atmosphere_earth.png",