More lighting changes

This commit is contained in:
Dynamitos
2025-03-13 08:23:00 +01:00
parent 80f86ca95c
commit 51d759639e
11 changed files with 18 additions and 20 deletions
-1
View File
@@ -31,6 +31,5 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf); result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf);
} }
result += brdf.evaluateAmbient(); result += brdf.evaluateAmbient();
// gamma correction
return float4(result, brdf.getAlpha()); return float4(result, brdf.getAlpha());
} }
+1 -1
View File
@@ -101,5 +101,5 @@ float4 fragmentMain(
float factor = (output.texCoords.y - lowerLimit) / (upperLimit - lowerLimit); float factor = (output.texCoords.y - lowerLimit) / (upperLimit - lowerLimit);
factor = clamp(factor, 0.0, 1.0); 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;
} }
+6 -7
View File
@@ -84,14 +84,14 @@ float3 agxEotf(float3 val) {
val = mul(agx_mat_inv, val); val = mul(agx_mat_inv, val);
// sRGB IEC 61966-2-1 2.2 Exponent Reference EOTF Display // 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; return val;
} }
float3 agxLook(float3 val, float avgLum) { float3 agxLook(float3 val) {
const float3 lw = float3(0.2126, 0.7152, 0.0722); 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 // Default
float3 offset = pToneMappingParams.offset.xyz; float3 offset = pToneMappingParams.offset.xyz;
@@ -108,10 +108,9 @@ float3 agxLook(float3 val, float avgLum) {
float4 toneMapping(float2 uv : UV) : SV_Target float4 toneMapping(float2 uv : UV) : SV_Target
{ {
float3 hdrValue = pToneMappingParams.hdrInputTexture.Sample(pToneMappingParams.hdrSampler, uv).rgb; float3 hdrValue = pToneMappingParams.hdrInputTexture.Sample(pToneMappingParams.hdrSampler, uv).rgb;
float avgLum = pToneMappingParams.averageLuminance[0];
float3 value = agx(hdrValue / 1000);
float3 value = agx(hdrValue); value = agxLook(value);
value = agxLook(value, avgLum);
value = agxEotf(value); value = agxEotf(value);
return float4(value, 1); return float4(value, 1);
+2 -2
View File
@@ -15,7 +15,7 @@ struct DirectionalLight : ILightEnv
float3 illuminate<B:IBRDF>(LightingParameter params, B brdf) float3 illuminate<B:IBRDF>(LightingParameter params, B brdf)
{ {
float3 dir_WS = -normalize(direction.xyz); 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; float3 lightDir_WS = position_WS.xyz - params.position_WS;
float d = length(lightDir_WS); float d = length(lightDir_WS);
float illuminance = max(1 - d / colorRange.w, 0); 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) bool insidePlane(Plane plane, float3 position)
+2 -2
View File
@@ -4,8 +4,8 @@ using namespace Seele;
DirectionalLightActor::DirectionalLightActor(PScene scene) : Actor(scene) { attachComponent<Component::DirectionalLight>(); } DirectionalLightActor::DirectionalLightActor(PScene scene) : Actor(scene) { attachComponent<Component::DirectionalLight>(); }
DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, Vector direction) : Actor(scene) { DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, float intensity, Vector direction) : Actor(scene) {
attachComponent<Component::DirectionalLight>(Vector4(color, 0), Vector4(direction, 0)); attachComponent<Component::DirectionalLight>(Vector4(color, intensity), Vector4(direction, 0));
} }
DirectionalLightActor::~DirectionalLightActor() {} DirectionalLightActor::~DirectionalLightActor() {}
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Seele {
class DirectionalLightActor : public Actor { class DirectionalLightActor : public Actor {
public: public:
DirectionalLightActor(PScene scene); DirectionalLightActor(PScene scene);
DirectionalLightActor(PScene scene, Vector color, Vector direction); DirectionalLightActor(PScene scene, Vector color, float intensity, Vector direction);
virtual ~DirectionalLightActor(); virtual ~DirectionalLightActor();
Component::DirectionalLight& getDirectionalLightComponent(); Component::DirectionalLight& getDirectionalLightComponent();
const Component::DirectionalLight& getDirectionalLightComponent() const; const Component::DirectionalLight& getDirectionalLightComponent() const;
+2 -2
View File
@@ -4,8 +4,8 @@ using namespace Seele;
PointLightActor::PointLightActor(PScene scene) : Actor(scene) { attachComponent<Component::PointLight>(); } PointLightActor::PointLightActor(PScene scene) : Actor(scene) { attachComponent<Component::PointLight>(); }
PointLightActor::PointLightActor(PScene scene, Vector position, Vector color, float attenuation) : Actor(scene) { PointLightActor::PointLightActor(PScene scene, Vector position, float intensity, Vector color, float attenuation) : Actor(scene) {
attachComponent<Component::PointLight>(Vector4(position, 1), Vector4(color, attenuation)); attachComponent<Component::PointLight>(Vector4(position, intensity), Vector4(color, attenuation));
} }
PointLightActor::~PointLightActor() {} PointLightActor::~PointLightActor() {}
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Seele {
class PointLightActor : public Actor { class PointLightActor : public Actor {
public: public:
PointLightActor(PScene scene); 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(); virtual ~PointLightActor();
Component::PointLight& getPointLightComponent(); Component::PointLight& getPointLightComponent();
const Component::PointLight& getPointLightComponent() const; const Component::PointLight& getPointLightComponent() const;
+1 -1
View File
@@ -34,7 +34,7 @@ class Asset {
std::string name; std::string name;
std::string assetId; std::string assetId;
Status status; Status status;
uint64 byteSize; uint64 byteSize = 0;
}; };
DEFINE_REF(Asset) DEFINE_REF(Asset)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Seele { namespace Seele {
namespace Component { namespace Component {
struct DirectionalLight { struct DirectionalLight {
Vector4 color; Vector4 colorIntensity;
Vector4 direction; Vector4 direction;
}; };
} // namespace Component } // namespace Component
+1 -1
View File
@@ -5,7 +5,7 @@ namespace Seele {
namespace Component { namespace Component {
struct PointLight { struct PointLight {
// give the lights a radius so that they are not actual points // give the lights a radius so that they are not actual points
Vector4 positionWSRadius; Vector4 positionWS;
Vector4 colorRange; Vector4 colorRange;
}; };
} // namespace Component } // namespace Component