Author Topic: Specular being added in shadows  (Read 291 times)

Frozenempire

  • Full Member
  • ***
  • Posts: 200
    • View Profile
    • The Frozen Empire
Specular being added in shadows
« on: June 18, 2019, 10:43:12 PM »
Hi,

It seems specular lighting is being calculated and added for areas in shadow.

Can specular lighting be zeroed in those areas?

Regards

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4994
    • View Profile
Re: Specular being added in shadows
« Reply #1 on: June 19, 2019, 07:45:01 AM »
Does it occur regardless of the camera event setting? (ie. BeforeReflections vs BeforeLighiting)

Frozenempire

  • Full Member
  • ***
  • Posts: 200
    • View Profile
    • The Frozen Empire
Re: Specular being added in shadows
« Reply #2 on: June 19, 2019, 01:01:35 PM »
Quick test shows that the specular is being added in both event settings...

Frozenempire

  • Full Member
  • ***
  • Posts: 200
    • View Profile
    • The Frozen Empire
Re: Specular being added in shadows
« Reply #3 on: June 19, 2019, 01:10:52 PM »
It's as if _GS_SnowData3.x (Sun occlusion) is not zeroing out the specular when in shadow (assuming thats what it should do ?!?)

Code
// Specular
float gloss = saturate(0.65 + _GS_SunDir.y);
half4 newSpecular =  half4(snowAlbedo * gloss, _GS_SnowData6.y) * _GS_SnowData3.x;

Frozenempire

  • Full Member
  • ***
  • Posts: 200
    • View Profile
    • The Frozen Empire
Re: Specular being added in shadows
« Reply #4 on: June 19, 2019, 01:18:17 PM »
Sun occlusion test seems to be a basic test that the sun is above the horizon... ?

Code
void CheckSunOcclusion() {
if (cameraEffect == null || _sun == null)
     return;
if (_sun.transform.rotation != lastSunRotation) {
     lastSunRotation = _sun.transform.rotation;
     sunOccluded = _sun.transform.forward.y > 0;
     UpdateSnowData3();
}
}

Frozenempire

  • Full Member
  • ***
  • Posts: 200
    • View Profile
    • The Frozen Empire
Re: Specular being added in shadows
« Reply #5 on: June 19, 2019, 01:20:20 PM »
Or should the specular get zeroed automatically via built in deferred lighting when in shadow... I'm not sure.

Frozenempire

  • Full Member
  • ***
  • Posts: 200
    • View Profile
    • The Frozen Empire
Re: Specular being added in shadows
« Reply #6 on: June 19, 2019, 02:17:07 PM »
Solved after going round the houses checking various settings!

It turns out that the shadow intensity was 0.9 on the light, which allows some specular highlight to show through.

Nothing to do with GS. Doh!

A case of parameter overload :)

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4994
    • View Profile
Re: Specular being added in shadows
« Reply #7 on: June 19, 2019, 02:26:19 PM »
That's correct, shadows take care of speculars as well: