From 982837052a2816eda655a55db3b9272ed0cd5d4b Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 19 Jan 2016 14:44:17 +0100 Subject: [PATCH] DirectionalLight now correctly getting directions --- .../Engine/Rendering/DirectionalLightJob.h | 2 +- .../Schema/Components/DirectionalLight.xml | 5 +- .../Schema/Components/DirectionalLight.xsd | 2 - resources/Schema/Entities/EditorTestWorld.xml | 54 ++++++++++++++++++- resources/Schema/Types/Entity.xsd | 1 + resources/Shaders/ForwardPlus.frag.glsl | 2 +- resources/Shaders/ForwardPlus.vert.glsl | 2 +- 7 files changed, 59 insertions(+), 9 deletions(-) diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index f6942112..5f104ca5 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -16,7 +16,7 @@ struct DirectionalLightJob : RenderJob : RenderJob() { - Direction = glm::vec4(0,0,-1,0) * Transform::AbsoluteOrientation(m_World, transformComponent.EntityID); + Direction = glm::vec4(0,0,-1,0) * glm::inverse(Transform::AbsoluteOrientation(m_World, transformComponent.EntityID)); //Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 0.f); Color = (glm::vec4)directionalLightComponent["Color"]; Intensity = (double)directionalLightComponent["Intensity"]; diff --git a/resources/Schema/Components/DirectionalLight.xml b/resources/Schema/Components/DirectionalLight.xml index f66605c0..7f777ef8 100644 --- a/resources/Schema/Components/DirectionalLight.xml +++ b/resources/Schema/Components/DirectionalLight.xml @@ -1,5 +1,6 @@ - + + 0.8 true - \ No newline at end of file + \ No newline at end of file diff --git a/resources/Schema/Components/DirectionalLight.xsd b/resources/Schema/Components/DirectionalLight.xsd index dbfee38c..a14248a8 100644 --- a/resources/Schema/Components/DirectionalLight.xsd +++ b/resources/Schema/Components/DirectionalLight.xsd @@ -1,8 +1,6 @@ - - A directional light that shines bright like the future. diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index e44d238e..a482cf1b 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -13,6 +13,7 @@ + @@ -45,9 +46,58 @@ + - - + + + + + + + + + + + Models/DirectionalLightWidget.obj + + + + + + + + + + + + Models/Assault.obj + + + + + + + + + + Models/SecondaryWeapon4.fbx + + + + + + + + + + + + + + Models/Core/UnitSphere.obj + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 1aaa8497..14e3c5a4 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -27,6 +27,7 @@ + diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 0298c969..e67a4d5d 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -88,7 +88,7 @@ LightResult CalcPointLightSource(vec4 lightPos, float lightRadius, vec4 lightCol LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensity, vec4 viewVec, vec4 vertNormal) { - vec4 L = normalize( -direction ); + vec4 L = normalize( -vec4(direction.xyz, 0) ); LightResult result; result.Diffuse = CalcDiffuse(color, L, vertNormal) * intensity; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 20ab9051..d3b8ba16 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -29,6 +29,6 @@ void main() Output.Position = Position; Output.TextureCoordinate = TextureCoords; - Output.Normal = Normal; + Output.Normal = vec3(M * vec4(Normal, 0.0)); Output.DiffuseColor = DiffuseVertexColor; } \ No newline at end of file