From 7ecb76dffa106a9f72687272548c1c2adb2daf90 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sun, 1 Mar 2015 18:45:31 +0100 Subject: [PATCH] Using the color of the lights for the flame color. --- data/levels/Compositions.xml | 4 ++-- data/shader/flame.fsh | 5 ++++- data/shader/flame.gsh | 7 ++++++- data/shader/flame.vsh | 4 ++++ graphics.cc | 17 +++++++++++------ 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/data/levels/Compositions.xml b/data/levels/Compositions.xml index 83ac463..5ad3603 100644 --- a/data/levels/Compositions.xml +++ b/data/levels/Compositions.xml @@ -72,8 +72,8 @@ 2 0.0 1.0 - 1.0 - 1.0 + 0.9 + 0.3 4.0 -1.5 diff --git a/data/shader/flame.fsh b/data/shader/flame.fsh index 6f8ab8c..ee34d2c 100644 --- a/data/shader/flame.fsh +++ b/data/shader/flame.fsh @@ -1,7 +1,10 @@ #version 150 +in vec3 fColor; + out vec4 oColor; + void main() { - oColor = vec4(1.0, 0.0, 0.0, 0.5); + oColor = vec4(fColor, 0.5); } diff --git a/data/shader/flame.gsh b/data/shader/flame.gsh index 53a61ce..8854180 100644 --- a/data/shader/flame.gsh +++ b/data/shader/flame.gsh @@ -6,7 +6,10 @@ uniform bool bottom; uniform bool left; layout(points) in; -layout(triangle_strip, max_vertices = 256) out; +layout(triangle_strip, max_vertices = 146) out; + +in vec3 Color[]; +out vec3 fColor; const float PI = 3.1415926; const float transition_point = 1.178097; @@ -27,6 +30,8 @@ float radiusFunction(float x) { } void main() { + fColor = Color[0]; + float resolution = 8.0; float step = abs(end-begin)/resolution/2.0; float i = 0.0; diff --git a/data/shader/flame.vsh b/data/shader/flame.vsh index 09df02a..7f730c9 100644 --- a/data/shader/flame.vsh +++ b/data/shader/flame.vsh @@ -3,7 +3,11 @@ uniform mat4 viewProjectionMatrix; in vec3 aPosition; +in vec3 aColor; + +out vec3 Color; void main () { + Color = aColor; gl_Position = viewProjectionMatrix * vec4(aPosition, 1.0); } diff --git a/graphics.cc b/graphics.cc index 1183c11..cda444f 100644 --- a/graphics.cc +++ b/graphics.cc @@ -59,6 +59,7 @@ void Graphics::init(Level* level) { flame_positions_ab = SharedArrayBuffer(new ArrayBuffer()); flame_positions_ab->defineAttribute("aPosition", GL_FLOAT, 3); + flame_positions_ab->defineAttribute("aColor", GL_FLOAT, 3); flame_positions = SharedVertexArrayObject(new VertexArrayObject()); flame_positions->setMode(GL_POINTS); flame_positions->attachAllAttributes(flame_positions_ab); @@ -314,17 +315,21 @@ void Graphics::updateLights() { lightingShader->setUniform("directionalIntensity", level->getDirectionalLight()->getIntensity()); } - float flamePositionsData[closestLights.size() * 3] = {}; + float flameData[closestLights.size() * 6] = {}; int flameIndex = 0; for (unsigned int i = 0; isetDataElements(flameIndex, flamePositionsData); + flame_positions_ab->setDataElements(flameIndex, flameData); } void Graphics::resize(glm::uvec2 windowSize) {