This commit is contained in:
Tleety
2016-01-18 17:57:45 +01:00
parent 601ce85c05
commit 4b29d48f27
4 changed files with 11 additions and 22 deletions
@@ -15,7 +15,7 @@ struct DirectionalLightJob : RenderJob
DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightComponent, World* m_World)
: RenderJob()
{
Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 1.f);
Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 0.f);
Color = (glm::vec4)directionalLightComponent["Color"];
Intensity = (double)directionalLightComponent["Intensity"];
};
+1 -1
View File
@@ -63,7 +63,7 @@ private:
float Radius = 5.f;
float Intensity = 0.8f;
float Falloff = 0.3f;
enum Type_t { Point, Directional, Spot } Type;
enum Type_t { Zero, Point, Directional, Spot } Type;
};
std::vector<LightSource> m_LightSources;
+2 -2
View File
@@ -120,7 +120,7 @@ void main ()
//if pointlight
//Pos i view antagligen
if(light.Type == 0) {
if(light.Type == 1) {
if(SphereInsideFrustrum( vec3(V * light.Position), light.Radius, GroupFrustum)) {
//TODO: Fix transparent and opaque list, and depth test.
AppendLight( i );
@@ -131,7 +131,7 @@ void main ()
//if conelight
//if directional
if(light.Type == 1) {
if(light.Type == 2) {
AppendLight( i );
}
+7 -18
View File
@@ -88,7 +88,7 @@ LightResult CalcPointLightSource(vec4 lightPos, float lightRadius, vec4 lightCol
LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensity, vec4 viewVec, vec4 vertPosition, vec4 vertNormal)
{
vec4 L = normalize( -direction );
vec4 L = normalize( vec4(direction.xyz, 1) );
LightResult result;
result.Diffuse = CalcDiffuse(color, L, vertNormal) * intensity;
@@ -119,9 +119,9 @@ void main()
int l = int(LightIndex[i]);
LightResult result;
if(LightSources.List[i].Type == 0) { // point
//result = CalcPointLightSource(V * LightSources.List[l].Position, LightSources.List[l].Radius, LightSources.List[l].Color, LightSources.List[l].Intensity, viewVec, position, normal, LightSources.List[i].Falloff);
} else if (LightSources.List[i].Type == 1) { //Directional
if(LightSources.List[i].Type == 1) { // point
result = CalcPointLightSource(V * LightSources.List[l].Position, LightSources.List[l].Radius, LightSources.List[l].Color, LightSources.List[l].Intensity, viewVec, position, normal, LightSources.List[i].Falloff);
} else if (LightSources.List[i].Type == 2) { //Directional
result = CalcDirectionalLightSource(V * LightSources.List[l].Direction, LightSources.List[i].Color, LightSources.List[i].Intensity, viewVec, position, normal);
}
totalLighting.Diffuse += result.Diffuse;
@@ -129,26 +129,15 @@ void main()
}
fragmentColor += Input.DiffuseColor;
//fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
//fragmentColor += Input.DiffuseColor;
fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
//fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse) * texel * Color;
//fragmentColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3.0, 0, 1);
if(LightSources.List[0].Type == 0) {
fragmentColor += vec4(1,0,0,1);
}
if(LightSources.List[0].Type == 1) {
fragmentColor += vec4(0,1,0,1);
}
if(LightSources.List[0].Type == 2) {
fragmentColor += vec4(0,0,1,1);
}
//fragmentColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Start/.0, 0, 1);
//fragmentColor = texel * Input.DiffuseColor * Color;
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
//fragmentColor += vec4(0.5, 0, 0, 0);
} else {
//fragmentColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/3.0, 0, 0, 1);
}
}