Using the color of the lights for the flame color.

This commit is contained in:
Faerbit 2015-03-01 18:45:31 +01:00
parent bb090fcf91
commit 7ecb76dffa
5 changed files with 27 additions and 10 deletions

View File

@ -72,8 +72,8 @@
<yOffset>2</yOffset> <yOffset>2</yOffset>
<zOffset>0.0</zOffset> <zOffset>0.0</zOffset>
<rColour>1.0</rColour> <rColour>1.0</rColour>
<gColour>1.0</gColour> <gColour>0.9</gColour>
<bColour>1.0</bColour> <bColour>0.3</bColour>
<intensity>4.0</intensity> <intensity>4.0</intensity>
<flameOffset>-1.5</flameOffset> <flameOffset>-1.5</flameOffset>
</light> </light>

View File

@ -1,7 +1,10 @@
#version 150 #version 150
in vec3 fColor;
out vec4 oColor; out vec4 oColor;
void main() { void main() {
oColor = vec4(1.0, 0.0, 0.0, 0.5); oColor = vec4(fColor, 0.5);
} }

View File

@ -6,7 +6,10 @@ uniform bool bottom;
uniform bool left; uniform bool left;
layout(points) in; 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 PI = 3.1415926;
const float transition_point = 1.178097; const float transition_point = 1.178097;
@ -27,6 +30,8 @@ float radiusFunction(float x) {
} }
void main() { void main() {
fColor = Color[0];
float resolution = 8.0; float resolution = 8.0;
float step = abs(end-begin)/resolution/2.0; float step = abs(end-begin)/resolution/2.0;
float i = 0.0; float i = 0.0;

View File

@ -3,7 +3,11 @@
uniform mat4 viewProjectionMatrix; uniform mat4 viewProjectionMatrix;
in vec3 aPosition; in vec3 aPosition;
in vec3 aColor;
out vec3 Color;
void main () { void main () {
Color = aColor;
gl_Position = viewProjectionMatrix * vec4(aPosition, 1.0); gl_Position = viewProjectionMatrix * vec4(aPosition, 1.0);
} }

View File

@ -59,6 +59,7 @@ void Graphics::init(Level* level) {
flame_positions_ab = SharedArrayBuffer(new ArrayBuffer()); flame_positions_ab = SharedArrayBuffer(new ArrayBuffer());
flame_positions_ab->defineAttribute("aPosition", GL_FLOAT, 3); flame_positions_ab->defineAttribute("aPosition", GL_FLOAT, 3);
flame_positions_ab->defineAttribute("aColor", GL_FLOAT, 3);
flame_positions = SharedVertexArrayObject(new VertexArrayObject()); flame_positions = SharedVertexArrayObject(new VertexArrayObject());
flame_positions->setMode(GL_POINTS); flame_positions->setMode(GL_POINTS);
flame_positions->attachAllAttributes(flame_positions_ab); flame_positions->attachAllAttributes(flame_positions_ab);
@ -314,17 +315,21 @@ void Graphics::updateLights() {
lightingShader->setUniform("directionalIntensity", lightingShader->setUniform("directionalIntensity",
level->getDirectionalLight()->getIntensity()); level->getDirectionalLight()->getIntensity());
} }
float flamePositionsData[closestLights.size() * 3] = {}; float flameData[closestLights.size() * 6] = {};
int flameIndex = 0; int flameIndex = 0;
for (unsigned int i = 0; i<closestLights.size(); i++) { for (unsigned int i = 0; i<closestLights.size(); i++) {
if (closestLights.at(i).getFlameYOffset() != 0.0f) { if (closestLights.at(i).getFlameYOffset() != 0.0f) {
flamePositionsData[flameIndex + 0] = closestLights.at(i).getPosition().x; flameData[flameIndex + 0] = closestLights.at(i).getPosition().x;
flamePositionsData[flameIndex + 1] = closestLights.at(i).getPosition().y + closestLights.at(i).getFlameYOffset(); flameData[flameIndex + 1] = closestLights.at(i).getPosition().y + closestLights.at(i).getFlameYOffset();
flamePositionsData[flameIndex + 2] = closestLights.at(i).getPosition().z; flameData[flameIndex + 2] = closestLights.at(i).getPosition().z;
flameIndex+=3; flameData[flameIndex + 3] = closestLights.at(i).getColour().r;
flameData[flameIndex + 3] = closestLights.at(i).getColour().r;
flameData[flameIndex + 4] = closestLights.at(i).getColour().g;
flameData[flameIndex + 5] = closestLights.at(i).getColour().b;
flameIndex+=6;
} }
} }
flame_positions_ab->setDataElements(flameIndex, flamePositionsData); flame_positions_ab->setDataElements(flameIndex, flameData);
} }
void Graphics::resize(glm::uvec2 windowSize) { void Graphics::resize(glm::uvec2 windowSize) {