Skip to content
Extraits de code Groupes Projets
Valider 01fa9344 rédigé par Lénaïc DURAND's avatar Lénaïc DURAND
Parcourir les fichiers

intensité

parent 3a0553f8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
0.png

4,91 ko | W: | H:

0.png

31 ko | W: | H:

0.png
0.png
0.png
0.png
  • 2-up
  • Swipe
  • Onion skin
1.png

13,4 ko

Fichier ajouté
#include "scene.h" #include "scene.h"
#include <png.h> #include <png.h>
#include <math.h> //fmin
...@@ -135,11 +136,13 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in ...@@ -135,11 +136,13 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in
} }
} }
float intensity = 60/dist(reflected.origin(), source_.origin()); //pour atténuer la lumière selon la distance
if (shadow) if (shadow)
{ {
row[3*(nb_pixel_row-1-j)] = 50; row[3*(nb_pixel_row-1-j)] = fmin(50, 50*intensity);
row[3*(nb_pixel_row-1-j) + 1] = 50; row[3*(nb_pixel_row-1-j) + 1] = fmin(50, 50*intensity);
row[3*(nb_pixel_row-1-j) + 2] = 50; row[3*(nb_pixel_row-1-j) + 2] = fmin(50, 50*intensity);
} }
else else
...@@ -149,16 +152,16 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in ...@@ -149,16 +152,16 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in
if ( dist(reflect_to_source.origin() , shapes_[k]->reflect(source_to_reflect).origin()) > 0.5 ) //self_shadow if ( dist(reflect_to_source.origin() , shapes_[k]->reflect(source_to_reflect).origin()) > 0.5 ) //self_shadow
{ {
row[3*(nb_pixel_row-1-j)] = shapes_[k]->matter().r() / 2; row[3*(nb_pixel_row-1-j)] = fmin(shapes_[k]->matter().r()/2 * intensity, shapes_[k]->matter().r()/2);
row[3*(nb_pixel_row-1-j) + 1] = shapes_[k]->matter().g() / 2; row[3*(nb_pixel_row-1-j) + 1] = fmin(shapes_[k]->matter().g()/2 * intensity, shapes_[k]->matter().g()/2);
row[3*(nb_pixel_row-1-j) + 2] = shapes_[k]->matter().b() / 2; row[3*(nb_pixel_row-1-j) + 2] = fmin(shapes_[k]->matter().b()/2 * intensity, shapes_[k]->matter().b()/2);
} }
else else //il faut rajouter la réflexion
{ {
row[3*(nb_pixel_row-1-j)] = shapes_[k]->matter().r(); row[3*(nb_pixel_row-1-j)] = fmin(shapes_[k]->matter().r() * intensity, 255.);
row[3*(nb_pixel_row-1-j) + 1] = shapes_[k]->matter().g(); row[3*(nb_pixel_row-1-j) + 1] = fmin(shapes_[k]->matter().g() * intensity, 255.);
row[3*(nb_pixel_row-1-j) + 2] = shapes_[k]->matter().b(); row[3*(nb_pixel_row-1-j) + 2] = fmin(shapes_[k]->matter().b() * intensity, 255.);
} }
} }
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter