Minor modifications to the scene

This commit is contained in:
Peder Bergebakken Sundt 2019-03-19 20:24:59 +01:00
parent da4d088d9d
commit 1d7c297257
2 changed files with 13 additions and 5 deletions

View File

@ -44,7 +44,7 @@ struct Light { // point lights, coordinates in MV space
float spot_cuttof_cos; float spot_cuttof_cos;
}; };
#define N_LIGHTS 1 #define N_LIGHTS 2
uniform Light light[N_LIGHTS]; uniform Light light[N_LIGHTS];
@ -99,8 +99,6 @@ vec3 phong(vec3 basecolor) {
vec3 diffuse_component = vec3(0.0); vec3 diffuse_component = vec3(0.0);
vec3 specular_component = vec3(0.0); vec3 specular_component = vec3(0.0);
float diffuse_i_sum = 0.0;
//vec3 emissive_component = vec3(0.0);
for (int i = 0; i<N_LIGHTS; i++) { for (int i = 0; i<N_LIGHTS; i++) {
vec3 L = light[i].position - vertex; vec3 L = light[i].position - vertex;
@ -127,7 +125,6 @@ vec3 phong(vec3 basecolor) {
specular_component += specular_color * light[i].color * specular_i * attenuation; specular_component += specular_color * light[i].color * specular_i * attenuation;
if (diffuse_i>0) diffuse_component += diffuse_color * light[i].color * diffuse_i * attenuation; if (diffuse_i>0) diffuse_component += diffuse_color * light[i].color * diffuse_i * attenuation;
//emissive_component += emissive_color*light[i].color*attenuation;
} }
basecolor *= (emissive_color + diffuse_component); basecolor *= (emissive_color + diffuse_component);

View File

@ -36,12 +36,13 @@ uint previousKeyFrame = 0;
SceneNode* rootNode; SceneNode* rootNode;
SceneNode* plainNode; SceneNode* plainNode;
SceneNode* carNode; SceneNode* carNode;
SceneNode* treeNode;
SceneNode* boxNode; SceneNode* boxNode;
SceneNode* sphereNode; SceneNode* sphereNode;
SceneNode* hudNode; SceneNode* hudNode;
SceneNode* textNode; SceneNode* textNode;
const uint N_LIGHTS = 1; const uint N_LIGHTS = 2;
SceneNode* lightNode[N_LIGHTS]; SceneNode* lightNode[N_LIGHTS];
// These are heap allocated, because they should not be initialised at the start of the program // These are heap allocated, because they should not be initialised at the start of the program
@ -134,6 +135,10 @@ void initGame(GLFWwindow* window, CommandLineOptions gameOptions) {
} }
//treeNode = loadModelScene("../res/models/fur_tree/scene.gltf");
//treeNode->position = {300, 800, 10};
//rootNode->children.push_back(treeNode);
carNode = loadModelScene("../res/models/beetle/scene.gltf", { carNode = loadModelScene("../res/models/beetle/scene.gltf", {
{ 0, Material().diffuse({0.0, 0.0, 1.0}).diffuse_only().reflection_mapped(&t_reflection, 0.15)},// Blue_Metal { 0, Material().diffuse({0.0, 0.0, 1.0}).diffuse_only().reflection_mapped(&t_reflection, 0.15)},// Blue_Metal
{ 1, Material().diffuse(vec3(0.85)).emissive(vec3(0.1)).reflection_mapped(&t_reflection, -1.0)},// Metal (decals) { 1, Material().diffuse(vec3(0.85)).emissive(vec3(0.1)).reflection_mapped(&t_reflection, -1.0)},// Metal (decals)
@ -190,6 +195,12 @@ void initGame(GLFWwindow* window, CommandLineOptions gameOptions) {
lightNode[0]->position = {-600, 1400, 800}; lightNode[0]->position = {-600, 1400, 800};
lightNode[0]->attenuation = vec3(1.8, 0.0, 0.0); lightNode[0]->attenuation = vec3(1.8, 0.0, 0.0);
lightNode[1]->position = {500, 0, 80};
lightNode[1]->referencePoint = {0, 500, 0};
lightNode[1]->scale *= 0.8;
lightNode[1]->light_color = vec3(0.0);
lightNode[1]->attenuation = vec3(1.0, 0.0, 0.000005);
textNode = createSceneNode(); textNode = createSceneNode();
textNode->setTexture(&t_charmap); textNode->setTexture(&t_charmap);