Generate agents with compute shader
This commit is contained in:
parent
6351a67703
commit
6b17a8e023
15 changed files with 206 additions and 154 deletions
|
|
@ -2,6 +2,7 @@ struct Settings {
|
|||
brushColor: vec3<f32>,
|
||||
speciesColorA: vec3<f32>,
|
||||
speciesColorB: vec3<f32>,
|
||||
clarity: f32,
|
||||
};
|
||||
|
||||
@group(1) @binding(0) var<uniform> settings: Settings;
|
||||
|
|
@ -13,19 +14,17 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|||
let traces = textureSample(trailMap, Sampler, uv);
|
||||
let random = textureSample(noise, noiseSampler, uv);
|
||||
|
||||
let backgroundColor = vec3(0.9) + 0.075 * random.r;
|
||||
|
||||
let speciesAStrength = traces.r;
|
||||
let speciesBStrength = traces.g;
|
||||
let brushStrength = traces.a;
|
||||
|
||||
let rgbColor = sqrt(vec3(
|
||||
settings.speciesColorA * clamp(speciesAStrength, 0, 1) +
|
||||
settings.speciesColorB * clamp(speciesBStrength, 0, 1) +
|
||||
settings.speciesColorA * clamp(pow(speciesAStrength, settings.clarity), 0, 1) +
|
||||
settings.speciesColorB * clamp(pow(speciesBStrength, settings.clarity), 0, 1) +
|
||||
settings.brushColor * brushStrength
|
||||
));
|
||||
|
||||
|
||||
let bg = vec3(0.9) + 0.075 * random.r;
|
||||
|
||||
|
||||
return vec4(bg - rgbColor, 1);
|
||||
return vec4(backgroundColor - rgbColor, 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue