Skip to content

Instantly share code, notes, and snippets.

@sclark39
Created October 8, 2024 18:32
Show Gist options
  • Save sclark39/55d9d6cd5b1dd13087fa310e3c0d0189 to your computer and use it in GitHub Desktop.
Save sclark39/55d9d6cd5b1dd13087fa310e3c0d0189 to your computer and use it in GitHub Desktop.
Custom Material node to fix improper noise bounding. This will return a normalized 0..1 value out of the noise function in UE5.3.
float Out = MaterialExpressionNoise(
DERIV_BASE_VALUE(Position), // Position
Scale, // Scale
1.00000000, // Quality
0.00000000, // Function
bTurbulence, // bTurbulence
Levels, // Levels
0.00000000, // OutputMin
1.00000000, // OutputMax
LevelScale, // LevelScale
0.00000000, // FilterWidth
0.00000000, // bTiling
512.00000000); // RepeatSize
float MinOut = 0.0;
float MaxOut = LevelScale * ( 1.0 - pow(LevelScale, -Levels)) / ( LevelScale - 1.0 );
if ( !bTurbulence)
{
MinOut = MaxOut * -1.0f;
MinOut = MinOut * 0.5f + 0.5f;
MaxOut = MaxOut * 0.5f + 0.5f;
}
return (Out - MinOut) / (MaxOut - MinOut);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment