Skip to content

Commit

Permalink
automation error fix, and style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcanakbay committed Jan 1, 2025
1 parent f206316 commit ce70e94
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@
"require": "./lib/simple-lightmap/index.js",
"types": "./lib/simple-lightmap/index.d.ts"
},
"./simplex-noise": {
"import": "./lib/simplex-noise/index.mjs",
"require": "./lib/simplex-noise/index.js",
"types": "./lib/simplex-noise/index.d.ts"
},
"./tilt-shift": {
"import": "./lib/tilt-shift/index.mjs",
"require": "./lib/tilt-shift/index.js",
Expand Down
8 changes: 8 additions & 0 deletions scripts/screenshots/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,14 @@
"arguments": {
"strength": 4
}
},
{
"name": "SimplexNoiseFilter",
"filename": "simplex-noise",
"arguments": {
"strength": 0.5,
"noiseScale": 10
}
}
]
}
58 changes: 41 additions & 17 deletions src/simplex-noise/SimplexNoiseFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,48 @@ import { vertex, wgslVertex } from '../defaults';
import fragment from './simplex.frag';
import source from './simplex.wgsl';


/** Options for the SimplexNoiseFilter constructor. */
export interface SimplexNoiseFilterOptions
{
/**
* Noise map strength.
* @default 0.5
*/
strength?: 0.5;
strength?: number;
/**
* Noise map scale.
* @default 10
* @default 10.0
*/
noiseScale?: 10;
noiseScale?: number;
/**
* Horizontal offset for the noise map.
* Horizontal offset for the noise map.
* @default 0
*/
offsetX?: 0;
offsetX?: number;
/**
* Vertical offset for the noise map.
* @default 0
*/
offsetY?: 0;
offsetY?: number;
/**
* Depth offset for the noise map.
* @default 0
*/
offsetZ?: 0;
offsetZ?: number;
/**
* The threshold used with the step function to create a blocky effect in the noise pattern.
* When this is greater than 0, the step function is used to compare the noise value to this threshold.
* When this is greater than 0, the step function is used to compare the noise value to this threshold.
* @default -1
*/
step?: -1;
step?: number;
}

/**
* The SimplexNoiseFilter multiplies simplex noise with the current texture data. <br>
*

Check warning on line 44 in src/simplex-noise/SimplexNoiseFilter.ts

View workflow job for this annotation

GitHub Actions / Build

Trailing spaces not allowed
*
* @class
* @extends Filter
* @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters}
*/
export class SimplexNoiseFilter extends Filter
{
Expand Down Expand Up @@ -88,32 +87,57 @@ export class SimplexNoiseFilter extends Filter
glProgram,
resources: {
simplexUniforms: {
uStrength: { value: options.strength ?? 0, type: 'f32' },
uNoiseScale: { value: options.noiseScale ?? 0, type: 'f32' },
uOffsetX: { value: options.offsetX ?? 0, type: 'f32' },
uOffsetY: { value: options.offsetY ?? 0, type: 'f32' },
uOffsetZ: { value: options.offsetZ ?? 0, type: 'f32' },
uStep: { value: options.step ?? 0, type: 'f32' },
uStrength: { value: options?.strength ?? 0, type: 'f32' },
uNoiseScale: { value: options?.noiseScale ?? 0, type: 'f32' },
uOffsetX: { value: options?.offsetX ?? 0, type: 'f32' },
uOffsetY: { value: options?.offsetY ?? 0, type: 'f32' },
uOffsetZ: { value: options?.offsetZ ?? 0, type: 'f32' },
uStep: { value: options?.step ?? 0, type: 'f32' },
}
}
});
}

/**
* Strength of the noise (color = (noiseMap + strength) * texture)
* @default 0.5
*/
get strength(): number { return this.resources.simplexUniforms.uniforms.uStrength; }
set strength(value: number) { this.resources.simplexUniforms.uniforms.uStrength = value; }

/**
* Noise map scale.
* @default 10
*/
get noiseScale(): number { return this.resources.simplexUniforms.uniforms.uNoiseScale; }
set noiseScale(value: number) { this.resources.simplexUniforms.uniforms.uNoiseScale = value; }

/**
* Horizontal offset for the noise map.
* @default 0
*/
get offsetX(): number { return this.resources.simplexUniforms.uniforms.uOffsetX; }
set offsetX(value: number) { this.resources.simplexUniforms.uniforms.uOffsetX = value; }

/**
* Vertical offset for the noise map.
* @default 0
*/
get offsetY(): number { return this.resources.simplexUniforms.uniforms.uOffsetY; }
set offsetY(value: number) { this.resources.simplexUniforms.uniforms.uOffsetY = value; }

/**
* Depth offset for the noise map.
* @default 0
*/
get offsetZ(): number { return this.resources.simplexUniforms.uniforms.uOffsetZ; }
set offsetZ(value: number) { this.resources.simplexUniforms.uniforms.uOffsetZ = value; }

/**
* The threshold used with the step function to create a blocky effect in the noise pattern.
* When this is greater than 0, the step function is used to compare the noise value to this threshold.
* @default -1
*/
get step(): number { return this.resources.simplexUniforms.uniforms.uStep; }
set step(value: number) { this.resources.simplexUniforms.uniforms.uStep = value; }
}

0 comments on commit ce70e94

Please sign in to comment.