LGTM
This commit is contained in:
parent
b1acdff594
commit
4e92913925
8 changed files with 734 additions and 115 deletions
|
|
@ -1,39 +1,56 @@
|
|||
struct Settings {
|
||||
brushColor: vec3<f32>,
|
||||
evenGenerationColor: vec3<f32>,
|
||||
oddGenerationColor: vec3<f32>,
|
||||
colorA: vec3<f32>,
|
||||
backgroundColorPadding0: f32,
|
||||
colorB: vec3<f32>,
|
||||
backgroundColorPadding1: f32,
|
||||
colorC: vec3<f32>,
|
||||
backgroundColorPadding2: f32,
|
||||
backgroundColor: vec3<f32>,
|
||||
clarity: f32,
|
||||
cameraCenter: vec2<f32>,
|
||||
cameraZoom: f32,
|
||||
padding0: f32,
|
||||
};
|
||||
|
||||
@group(1) @binding(0) var<uniform> settings: Settings;
|
||||
@group(1) @binding(1) var Sampler: sampler;
|
||||
@group(1) @binding(2) var trailMap: texture_2d<f32>;
|
||||
@group(1) @binding(3) var sourceMap: texture_2d<f32>;
|
||||
|
||||
@fragment
|
||||
fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||
let traces = textureSample(trailMap, Sampler, uv);
|
||||
let random = textureSample(noise, noiseSampler, uv);
|
||||
let cameraUv = settings.cameraCenter / state.size;
|
||||
let viewUv = (uv - vec2(0.5)) / settings.cameraZoom + cameraUv;
|
||||
let traces = textureSample(trailMap, Sampler, viewUv);
|
||||
let sources = textureSample(sourceMap, Sampler, viewUv);
|
||||
|
||||
let backgroundColor = vec3(0.9) + 0.075 * random.r;
|
||||
|
||||
let evenGenerationStrength = clarity(traces.r);
|
||||
let oddGenerationStrength = clarity(traces.g);
|
||||
let brushStrength = traces.a;
|
||||
|
||||
let color = max(
|
||||
mix(
|
||||
evenGenerationStrength * settings.evenGenerationColor,
|
||||
oddGenerationStrength * settings.oddGenerationColor,
|
||||
oddGenerationStrength / (evenGenerationStrength + oddGenerationStrength + 0.000001)
|
||||
),
|
||||
brushStrength * settings.brushColor
|
||||
let traceStrengths = vec3(
|
||||
clarity(traces.r),
|
||||
clarity(traces.g),
|
||||
clarity(traces.b)
|
||||
);
|
||||
let sourceStrengths = vec3(
|
||||
clarity(sources.r),
|
||||
clarity(sources.g),
|
||||
clarity(sources.b)
|
||||
);
|
||||
let strengths = max(traceStrengths, sourceStrengths);
|
||||
let traceColor =
|
||||
strengths.r * settings.colorA
|
||||
+ strengths.g * settings.colorB
|
||||
+ strengths.b * settings.colorC;
|
||||
let brushColor =
|
||||
sourceStrengths.r * settings.colorA
|
||||
+ sourceStrengths.g * settings.colorB
|
||||
+ sourceStrengths.b * settings.colorC;
|
||||
let brushStrength = clamp(max(max(sourceStrengths.r, sourceStrengths.g), sourceStrengths.b), 0, 1);
|
||||
let color = max(traceColor, brushColor * (1.2 + brushStrength * 1.6));
|
||||
|
||||
let strength = max(evenGenerationStrength, max(oddGenerationStrength, brushStrength));
|
||||
let strength = clamp(max(max(max(strengths.r, strengths.g), strengths.b), brushStrength), 0, 1);
|
||||
|
||||
return vec4(mix(backgroundColor, color, strength), 1);
|
||||
return vec4(mix(settings.backgroundColor, clamp(color, vec3(0), vec3(1)), strength), 1);
|
||||
}
|
||||
|
||||
fn clarity(strength: f32) -> f32 {
|
||||
return pow(strength, settings.clarity);
|
||||
return pow(clamp(strength, 0, 1), settings.clarity);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue