summaryrefslogtreecommitdiffstats
path: root/src/Runtime/res/effectlib/perlinNoise.glsllib
diff options
context:
space:
mode:
authorMäättä Antti <antti.maatta@qt.io>2017-11-30 12:41:44 +0200
committerAntti Määttä <antti.maatta@qt.io>2018-01-10 12:41:04 +0000
commita15e4a54f78e330c613a2e63d8004169c05d94be (patch)
tree5f3f58b9a0cc2a1dd547ccc3276f28c49fa7c9cf /src/Runtime/res/effectlib/perlinNoise.glsllib
parent16185339fc737bfabb415265cdc9beef7146407e (diff)
Improve custom material GLES2 support
Implement light shader property setting for custom materials when constant buffers are not supported. Remove floating point .f from glsllib. Task-number: QT3DS-36 Change-Id: I30df0ef8841daaa166910c2384613a1c9f4e6b46 Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Runtime/res/effectlib/perlinNoise.glsllib')
-rw-r--r--src/Runtime/res/effectlib/perlinNoise.glsllib68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/Runtime/res/effectlib/perlinNoise.glsllib b/src/Runtime/res/effectlib/perlinNoise.glsllib
index 1fef880d..347386c4 100644
--- a/src/Runtime/res/effectlib/perlinNoise.glsllib
+++ b/src/Runtime/res/effectlib/perlinNoise.glsllib
@@ -45,13 +45,13 @@ vec2 fade( in vec2 x )
vec3 fade( in vec3 x )
{
return( x * x * x * ( x * ( x * 6.0 - 15.0 ) + 10.0 ));
- //return( x * x * ( 3.0f - 2.0f * x ) );
+ //return( x * x * ( 3.0 - 2.0 * x ) );
}
vec4 fade( in vec4 x )
{
return( x * x * x * ( x * ( x * 6.0 - 15.0 ) + 10.0 ));
- //return( x * x * ( 3.0f - 2.0f * x ) );
+ //return( x * x * ( 3.0 - 2.0 * x ) );
}
float influence( in int hash, in float x )
@@ -80,7 +80,7 @@ float perlinNoise( in float pos )
int intPos = int( floorPos );
float fracPos = pos - floorPos;
- return( mix( influence( random255X( intPos ), fracPos ), influence( random255X( intPos+1 ), fracPos - 1.0f ), fade( fracPos ) ) );
+ return( mix( influence( random255X( intPos ), fracPos ), influence( random255X( intPos+1 ), fracPos - 1.0 ), fade( fracPos ) ) );
}
float perlinNoise( in vec2 pos )
@@ -95,9 +95,9 @@ float perlinNoise( in vec2 pos )
int by = random255Y( int(floorPos.y) + 1 );
return( mix( mix( influence( ax^ay, fracPos.x, fracPos.y )
- , influence( bx^ay, fracPos.x - 1.0f, fracPos.y ), fadedPos.x )
- , mix( influence( ax^by, fracPos.x, fracPos.y - 1.0f )
- , influence( bx^by, fracPos.x - 1.0f, fracPos.y - 1.0f ), fadedPos.x ), fadedPos.y ) );
+ , influence( bx^ay, fracPos.x - 1.0, fracPos.y ), fadedPos.x )
+ , mix( influence( ax^by, fracPos.x, fracPos.y - 1.0 )
+ , influence( bx^by, fracPos.x - 1.0, fracPos.y - 1.0 ), fadedPos.x ), fadedPos.y ) );
}
float perlinNoise( in vec3 pos )
@@ -119,13 +119,13 @@ float perlinNoise( in vec3 pos )
int bxby = bx ^ by;
return( mix( mix( mix( influence( axay^az, fracPos.x, fracPos.y, fracPos.z )
- , influence( bxay^az, fracPos.x - 1.0f, fracPos.y, fracPos.z ), fadedPos.x )
- , mix( influence( axby^az, fracPos.x, fracPos.y - 1.0f, fracPos.z )
- , influence( bxby^az, fracPos.x - 1.0f, fracPos.y - 1.0f, fracPos.z ), fadedPos.x ), fadedPos.y )
- , mix( mix( influence( axay^bz, fracPos.x, fracPos.y , fracPos.z - 1.0f )
- , influence( bxay^bz, fracPos.x - 1.0f, fracPos.y , fracPos.z - 1.0f ), fadedPos.x )
- , mix( influence( axby^bz, fracPos.x, fracPos.y - 1.0f, fracPos.z - 1.0f )
- , influence( bxby^bz, fracPos.x - 1.0f, fracPos.y - 1.0f, fracPos.z - 1.0f ), fadedPos.x ), fadedPos.y ), fadedPos.z ) );
+ , influence( bxay^az, fracPos.x - 1.0, fracPos.y, fracPos.z ), fadedPos.x )
+ , mix( influence( axby^az, fracPos.x, fracPos.y - 1.0, fracPos.z )
+ , influence( bxby^az, fracPos.x - 1.0, fracPos.y - 1.0, fracPos.z ), fadedPos.x ), fadedPos.y )
+ , mix( mix( influence( axay^bz, fracPos.x, fracPos.y , fracPos.z - 1.0 )
+ , influence( bxay^bz, fracPos.x - 1.0, fracPos.y , fracPos.z - 1.0 ), fadedPos.x )
+ , mix( influence( axby^bz, fracPos.x, fracPos.y - 1.0, fracPos.z - 1.0 )
+ , influence( bxby^bz, fracPos.x - 1.0, fracPos.y - 1.0, fracPos.z - 1.0 ), fadedPos.x ), fadedPos.y ), fadedPos.z ) );
}
float perlinNoise( in vec4 pos )
@@ -154,45 +154,45 @@ float perlinNoise( in vec4 pos )
int bzaw = bz ^ aw;
result[i] = mix( mix( mix( influence( axay^azaw, fracPos.x, fracPos.y, fracPos.z, fracPos.w )
- , influence( bxay^azaw, fracPos.x - 1.0f, fracPos.y, fracPos.z, fracPos.w ), fadedPos.x )
- , mix( influence( axby^azaw, fracPos.x, fracPos.y - 1.0f, fracPos.z, fracPos.w )
- , influence( bxby^azaw, fracPos.x - 1.0f, fracPos.y - 1.0f, fracPos.z, fracPos.w ), fadedPos.x ), fadedPos.y )
- , mix( mix( influence( axay^bzaw, fracPos.x, fracPos.y, fracPos.z - 1.0f, fracPos.w )
- , influence( bxay^bzaw, fracPos.x - 1.0f, fracPos.y, fracPos.z - 1.0f, fracPos.w ), fadedPos.x )
- , mix( influence( axby^bzaw, fracPos.x, fracPos.y - 1.0f, fracPos.z - 1.0f, fracPos.w )
- , influence( bxby^bzaw, fracPos.x - 1.0f, fracPos.y - 1.0f, fracPos.z - 1.0f, fracPos.w ), fadedPos.x ), fadedPos.y ), fadedPos.z );
+ , influence( bxay^azaw, fracPos.x - 1.0, fracPos.y, fracPos.z, fracPos.w ), fadedPos.x )
+ , mix( influence( axby^azaw, fracPos.x, fracPos.y - 1.0, fracPos.z, fracPos.w )
+ , influence( bxby^azaw, fracPos.x - 1.0, fracPos.y - 1.0, fracPos.z, fracPos.w ), fadedPos.x ), fadedPos.y )
+ , mix( mix( influence( axay^bzaw, fracPos.x, fracPos.y, fracPos.z - 1.0, fracPos.w )
+ , influence( bxay^bzaw, fracPos.x - 1.0, fracPos.y, fracPos.z - 1.0, fracPos.w ), fadedPos.x )
+ , mix( influence( axby^bzaw, fracPos.x, fracPos.y - 1.0, fracPos.z - 1.0, fracPos.w )
+ , influence( bxby^bzaw, fracPos.x - 1.0, fracPos.y - 1.0, fracPos.z - 1.0, fracPos.w ), fadedPos.x ), fadedPos.y ), fadedPos.z );
aw = random255W( int(floorPos.w) + 1 );
- fracPos.w -= 1.0f;
+ fracPos.w -= 1.0;
}
return( mix( result[0], result[1], fadedPos.w ) );
}
float summedPerlinNoise( in vec3 pos, in int terms, in bool absNoise )
{
- float sum = 0.0f;
- float weight = 1.0f;
+ float sum = 0.0;
+ float weight = 1.0;
vec3 p = pos;
while ( terms-- != 0 )
{
float noise = perlinNoise( p );
sum += weight * ( absNoise ? abs(noise) : noise );
p += p;
- weight *= 0.5f;
+ weight *= 0.5;
}
return( sum );
}
float summedPerlinNoise( in vec4 pos, in int terms, in bool absNoise )
{
- float sum = 0.0f;
- float weight = 1.0f;
+ float sum = 0.0;
+ float weight = 1.0;
vec4 p = pos;
while ( terms-- != 0 )
{
float noise = perlinNoise( p );
sum += weight * ( absNoise ? abs(noise) : noise );
p += p;
- weight *= 0.5f;
+ weight *= 0.5;
}
return( sum );
}
@@ -200,34 +200,34 @@ float summedPerlinNoise( in vec4 pos, in int terms, in bool absNoise )
float perlinNoise( in vec3 pos, in float time, in int terms, in vec3 turbulenceWeight, in bool absoluteNoise, in bool applyMarble
, in bool applyDent, in float noiseBands, in float noiseThresholdHigh, in float noiseThresholdLow )
{
- float noise = ( time == 0.0f ) ? summedPerlinNoise( pos, terms, absoluteNoise ) : summedPerlinNoise( vec4( pos, time ), terms, absoluteNoise );
- if ( turbulenceWeight != vec3( 0.0f, 0.0f, 0.0f ) )
+ float noise = ( time == 0.0 ) ? summedPerlinNoise( pos, terms, absoluteNoise ) : summedPerlinNoise( vec4( pos, time ), terms, absoluteNoise );
+ if ( turbulenceWeight != vec3( 0.0, 0.0, 0.0 ) )
{
noise = sin( dot( pos, turbulenceWeight ) + noise );
}
if ( ! absoluteNoise )
{
- noise = 0.5f * noise + 0.5f; // scale [-1,1] to [0,1]
+ noise = 0.5 * noise + 0.5; // scale [-1,1] to [0,1]
}
if ( applyMarble )
{
- noise = cos( pos.x + 5.0f * noise ); // classic Perlin marble function, with magic 5.0f
+ noise = cos( pos.x + 5.0 * noise ); // classic Perlin marble function, with magic 5.0
}
if ( applyDent )
{
noise = cube( noise );
}
- if ( noiseBands != 1.0f )
+ if ( noiseBands != 1.0 )
{
// Create banding/stripes by using the fraction component only
noise *= noiseBands;
noise -= floor( noise );
- noise += pow( 1.0f - noise, 20.0f );
+ noise += pow( 1.0 - noise, 20.0 );
}
if ( noiseThresholdLow < noiseThresholdHigh )
{
// clamp the noise
- noise = clamp( ( noise - noiseThresholdLow ) / ( noiseThresholdHigh - noiseThresholdLow ), 0.0f, 1.0f );
+ noise = clamp( ( noise - noiseThresholdLow ) / ( noiseThresholdHigh - noiseThresholdLow ), 0.0, 1.0 );
}
return( noise );
}