diff --git a/res/shaders/BasePass.slang b/res/shaders/BasePass.slang index 2d7e894..3c7d1b1 100644 --- a/res/shaders/BasePass.slang +++ b/res/shaders/BasePass.slang @@ -31,6 +31,5 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf); } result += brdf.evaluateAmbient(); - // gamma correction return float4(result, brdf.getAlpha()); } \ No newline at end of file diff --git a/res/shaders/Skybox.slang b/res/shaders/Skybox.slang index f0e2aea..def3e3a 100644 --- a/res/shaders/Skybox.slang +++ b/res/shaders/Skybox.slang @@ -101,5 +101,5 @@ float4 fragmentMain( float factor = (output.texCoords.y - lowerLimit) / (upperLimit - lowerLimit); factor = clamp(factor, 0.0, 1.0); - return lerp(float4(pSkyboxData.fogBlend.xyz, 1), finalColor, factor); + return lerp(float4(pSkyboxData.fogBlend.xyz, 1), finalColor, factor) * 100; } \ No newline at end of file diff --git a/res/shaders/ToneMapping.slang b/res/shaders/ToneMapping.slang index 40fd547..3608110 100644 --- a/res/shaders/ToneMapping.slang +++ b/res/shaders/ToneMapping.slang @@ -84,14 +84,14 @@ float3 agxEotf(float3 val) { val = mul(agx_mat_inv, val); // sRGB IEC 61966-2-1 2.2 Exponent Reference EOTF Display - //val = pow(val, float3(2.2)); + val = pow(val, float3(2.2)); return val; } -float3 agxLook(float3 val, float avgLum) { +float3 agxLook(float3 val) { const float3 lw = float3(0.2126, 0.7152, 0.0722); - float luma = dot(val, lw) / (9.6 * avgLum + 0.00001); + float luma = dot(val, lw); // Default float3 offset = pToneMappingParams.offset.xyz; @@ -108,10 +108,9 @@ float3 agxLook(float3 val, float avgLum) { float4 toneMapping(float2 uv : UV) : SV_Target { float3 hdrValue = pToneMappingParams.hdrInputTexture.Sample(pToneMappingParams.hdrSampler, uv).rgb; - float avgLum = pToneMappingParams.averageLuminance[0]; - - float3 value = agx(hdrValue); - value = agxLook(value, avgLum); + + float3 value = agx(hdrValue / 1000); + value = agxLook(value); value = agxEotf(value); return float4(value, 1); diff --git a/res/shaders/lib/LightEnv.slang b/res/shaders/lib/LightEnv.slang index 58e3770..393987c 100644 --- a/res/shaders/lib/LightEnv.slang +++ b/res/shaders/lib/LightEnv.slang @@ -15,7 +15,7 @@ struct DirectionalLight : ILightEnv float3 illuminate(LightingParameter params, B brdf) { float3 dir_WS = -normalize(direction.xyz); - return brdf.evaluate(params.viewDir_WS, dir_WS, color.xyz); + return brdf.evaluate(params.viewDir_WS, dir_WS, color.xyz * color.w); } }; @@ -29,7 +29,7 @@ struct PointLight : ILightEnv float3 lightDir_WS = position_WS.xyz - params.position_WS; float d = length(lightDir_WS); float illuminance = max(1 - d / colorRange.w, 0); - return illuminance * brdf.evaluate(params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz); + return illuminance * brdf.evaluate(params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz * position_WS.w); } bool insidePlane(Plane plane, float3 position) diff --git a/src/Engine/Actor/DirectionalLightActor.cpp b/src/Engine/Actor/DirectionalLightActor.cpp index 27a88c9..c3936a5 100644 --- a/src/Engine/Actor/DirectionalLightActor.cpp +++ b/src/Engine/Actor/DirectionalLightActor.cpp @@ -4,8 +4,8 @@ using namespace Seele; DirectionalLightActor::DirectionalLightActor(PScene scene) : Actor(scene) { attachComponent(); } -DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, Vector direction) : Actor(scene) { - attachComponent(Vector4(color, 0), Vector4(direction, 0)); +DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, float intensity, Vector direction) : Actor(scene) { + attachComponent(Vector4(color, intensity), Vector4(direction, 0)); } DirectionalLightActor::~DirectionalLightActor() {} diff --git a/src/Engine/Actor/DirectionalLightActor.h b/src/Engine/Actor/DirectionalLightActor.h index e09444e..c3b52dc 100644 --- a/src/Engine/Actor/DirectionalLightActor.h +++ b/src/Engine/Actor/DirectionalLightActor.h @@ -6,7 +6,7 @@ namespace Seele { class DirectionalLightActor : public Actor { public: DirectionalLightActor(PScene scene); - DirectionalLightActor(PScene scene, Vector color, Vector direction); + DirectionalLightActor(PScene scene, Vector color, float intensity, Vector direction); virtual ~DirectionalLightActor(); Component::DirectionalLight& getDirectionalLightComponent(); const Component::DirectionalLight& getDirectionalLightComponent() const; diff --git a/src/Engine/Actor/PointLightActor.cpp b/src/Engine/Actor/PointLightActor.cpp index c873eac..f286bf7 100644 --- a/src/Engine/Actor/PointLightActor.cpp +++ b/src/Engine/Actor/PointLightActor.cpp @@ -4,8 +4,8 @@ using namespace Seele; PointLightActor::PointLightActor(PScene scene) : Actor(scene) { attachComponent(); } -PointLightActor::PointLightActor(PScene scene, Vector position, Vector color, float attenuation) : Actor(scene) { - attachComponent(Vector4(position, 1), Vector4(color, attenuation)); +PointLightActor::PointLightActor(PScene scene, Vector position, float intensity, Vector color, float attenuation) : Actor(scene) { + attachComponent(Vector4(position, intensity), Vector4(color, attenuation)); } PointLightActor::~PointLightActor() {} diff --git a/src/Engine/Actor/PointLightActor.h b/src/Engine/Actor/PointLightActor.h index 9e19a4a..c1b756b 100644 --- a/src/Engine/Actor/PointLightActor.h +++ b/src/Engine/Actor/PointLightActor.h @@ -6,7 +6,7 @@ namespace Seele { class PointLightActor : public Actor { public: PointLightActor(PScene scene); - PointLightActor(PScene scene, Vector position, Vector color, float attenuation); + PointLightActor(PScene scene, Vector position, float intensity, Vector color, float attenuation); virtual ~PointLightActor(); Component::PointLight& getPointLightComponent(); const Component::PointLight& getPointLightComponent() const; diff --git a/src/Engine/Asset/Asset.h b/src/Engine/Asset/Asset.h index 81688ae..fe4d0d1 100644 --- a/src/Engine/Asset/Asset.h +++ b/src/Engine/Asset/Asset.h @@ -34,7 +34,7 @@ class Asset { std::string name; std::string assetId; Status status; - uint64 byteSize; + uint64 byteSize = 0; }; DEFINE_REF(Asset) } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Component/DirectionalLight.h b/src/Engine/Component/DirectionalLight.h index 4cc40b4..a934a87 100644 --- a/src/Engine/Component/DirectionalLight.h +++ b/src/Engine/Component/DirectionalLight.h @@ -3,7 +3,7 @@ namespace Seele { namespace Component { struct DirectionalLight { - Vector4 color; + Vector4 colorIntensity; Vector4 direction; }; } // namespace Component diff --git a/src/Engine/Component/PointLight.h b/src/Engine/Component/PointLight.h index b6a3396..4862a98 100644 --- a/src/Engine/Component/PointLight.h +++ b/src/Engine/Component/PointLight.h @@ -5,7 +5,7 @@ namespace Seele { namespace Component { struct PointLight { // give the lights a radius so that they are not actual points - Vector4 positionWSRadius; + Vector4 positionWS; Vector4 colorRange; }; } // namespace Component