# ATTENUATION_LogReverse implementation is reversed

The implementation is backwards, as you get farther from the source the source gets louder and as you get closer it goes to 0.

This is the original implementation:

``````case ATTENUATION_LogReverse:
return FMath::Max( 0.5f * FMath::Loge( 1.0f / ( 1.0f - ( Distance / Falloff ) ) ), 0.0f );
``````

Assume Distance = 1000 and Falloff = 20000 then this will evaluate to 0.5 * log(1 / (1 - 0.05)) = 0.5 * log(1.05) = 0.01
Assume Distance = 10000 and Falloff = 20000 then this will evaluate to 0.5 * log(1 / (1 - 0.5)) = 0.5 * log(2.00) = 0.15
Assume Distance = 19000 and Falloff = 20000 then this will evaluate to 0.5 * log(1 / (1 - 0.95)) = 0.5 * log(20) = 0.65

As you can see here, this is not the same as it is here:
Wolfram Alpha plot of the above function:
Wolfram Alpha
UE4 Documentation:
Epic/UE4 Documentation

I think this was the intended implementation: 0.5*log(1-x) + 1

``````case ATTENUATION_LogReverse:
return FMath::Min( 0.5f * FMath::Loge( 1.0f - ( Distance / Falloff ) ) + 1.0f, 1.0f );
``````

Assume Distance = 1000 and Falloff = 20000 then this will evaluate to 0.5 * log(1 - 0.05) + 1 = 0.5 * log(0.95) + 1 = 0.99
Assume Distance = 10000 and Falloff = 20000 then this will evaluate to 0.5 * log(1 - 0.5) + 1 = 0.5 * log(0.5) + 1 = 0.85
Assume Distance = 19000 and Falloff = 20000 then this will evaluate to 0.5 * log(1 - 0.95) + 1 = 0.5 * log(0.05) + 1 = 0.35

This is much better: Corrected version on Wolfram Alpha

I had to retype that twice and submit it 3 times… That sucked that it never saved its state in Chrome. It is best from now on to write these outside of the browser and then copy them over.

It seems that I cannot add another pull request as I currently have one pending. I tried to create another branch with only this change in it but I’m still seeing all of the previous commits. Do I need to fork another repo or do I wait or what? I would prefer to just submit a patch file if possible.
Thanks ,

Hi ,

Thank you for bringing this to our attention. I was able to verify that it does look like we mixed this one up. I can submit a ticket to report this, but I wanted to check first to see if you preferred to submit a pull request on GitHub.

You should be able to create multiple pull requests by creating a separate branch for each one. You would create a branch from the Master branch and make the changes for your pull request, then repeat that process for your next pull request. Once a pull request is closed, you can delete the branch for that pull request.

Thanks , I messed up earlier by committing to my master on my fork. So it seems that I may have to fork once again. It is a learning process that I guess everyone has to go through once. I just wish it was a higher priority for me to take the time to learn it properly, but I have more important tasks to perform. Thanks for your help!

Submitted as new pull request #748