Minor improvements xd
This commit is contained in:
parent
f3f2547724
commit
0e97e54ffe
21 changed files with 189 additions and 184 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { generateFbmNoise } from '../../utils/graphics/fbm-noise/fbm-noise';
|
||||
import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad/full-screen-quad';
|
||||
import { smartCompile } from '../../utils/graphics/smart-compile';
|
||||
import { CommonState } from '../common-state/common-state';
|
||||
import { RenderSettings } from './render-settings';
|
||||
import shader from './render.wgsl';
|
||||
|
||||
import { vec3 } from 'gl-matrix';
|
||||
|
||||
export class RenderPipeline {
|
||||
private static readonly UNIFORM_COUNT = 13;
|
||||
|
||||
|
|
@ -56,7 +57,11 @@ export class RenderPipeline {
|
|||
evenGenerationColor,
|
||||
oddGenerationColor,
|
||||
clarity,
|
||||
}: RenderSettings) {
|
||||
}: RenderSettings & {
|
||||
brushColor: vec3;
|
||||
evenGenerationColor: vec3;
|
||||
oddGenerationColor: vec3;
|
||||
}) {
|
||||
this.device.queue.writeBuffer(
|
||||
this.uniforms,
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
import { vec3 } from 'gl-matrix';
|
||||
|
||||
export interface RenderSettings {
|
||||
brushColor: vec3;
|
||||
evenGenerationColor: vec3;
|
||||
oddGenerationColor: vec3;
|
||||
clarity: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,19 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|||
|
||||
let backgroundColor = vec3(0.9) + 0.075 * random.r;
|
||||
|
||||
let evenGenerationStrength = clamp(pow(traces.r, settings.clarity), 0, 1);
|
||||
let oddGenerationStrength = clamp(pow(traces.g, settings.clarity), 0, 1);
|
||||
let evenGenerationStrength = pow(traces.r, settings.clarity);
|
||||
let oddGenerationStrength = pow(traces.g, settings.clarity);
|
||||
let brushStrength = traces.a;
|
||||
|
||||
let agentColor = step(evenGenerationStrength, oddGenerationStrength) * settings.oddGenerationColor * oddGenerationStrength + step(oddGenerationStrength, evenGenerationStrength) * settings.evenGenerationColor * evenGenerationStrength;
|
||||
let agentStrength = evenGenerationStrength + oddGenerationStrength;
|
||||
let color = max(
|
||||
mix(
|
||||
evenGenerationStrength * settings.evenGenerationColor,
|
||||
oddGenerationStrength * settings.oddGenerationColor,
|
||||
oddGenerationStrength / (evenGenerationStrength + oddGenerationStrength + 0.000001)
|
||||
),
|
||||
brushStrength * settings.brushColor);
|
||||
|
||||
let rgbColor = sqrt(
|
||||
mix(agentColor, settings.brushColor * brushStrength, clamp(brushStrength - agentStrength, 0, 1))
|
||||
);
|
||||
return vec4(backgroundColor - rgbColor, 1);
|
||||
let strength = max(evenGenerationStrength, max(oddGenerationStrength, brushStrength));
|
||||
|
||||
return vec4(mix(backgroundColor, color, strength), 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue