Fix colons
This commit is contained in:
parent
99e1923066
commit
15836f2876
5 changed files with 49 additions and 49 deletions
|
|
@ -7,23 +7,23 @@ struct Agent {
|
|||
|
||||
struct Settings {
|
||||
size: vec2<f32>,
|
||||
deltaTime : f32,
|
||||
time : f32,
|
||||
deltaTime: f32,
|
||||
time: f32,
|
||||
|
||||
trailWeight : f32,
|
||||
moveRate : f32,
|
||||
turnRate : f32,
|
||||
sensorAngle : f32,
|
||||
sensorOffsetDst : f32,
|
||||
trailWeight: f32,
|
||||
moveRate: f32,
|
||||
turnRate: f32,
|
||||
sensorAngle: f32,
|
||||
sensorOffsetDst: f32,
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> settings : Settings;
|
||||
@group(0) @binding(1) var<storage, read_write> agents : array<Agent>;
|
||||
@group(0) @binding(2) var TrailMapIn : texture_2d<f32>;
|
||||
@group(0) @binding(3) var TrailMapOut : texture_storage_2d<rgba16float, write>;
|
||||
@group(0) @binding(0) var<uniform> settings: Settings;
|
||||
@group(0) @binding(1) var<storage, read_write> agents: array<Agent>;
|
||||
@group(0) @binding(2) var TrailMapIn: texture_2d<f32>;
|
||||
@group(0) @binding(3) var TrailMapOut: texture_storage_2d<rgba16float, write>;
|
||||
|
||||
@compute @workgroup_size(8, 8)
|
||||
fn main(@builtin(global_invocation_id) global_id : vec3<u32>) {
|
||||
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
||||
let id = global_id.x;
|
||||
|
||||
if (id >= arrayLength(&agents)) {
|
||||
|
|
@ -34,9 +34,9 @@ fn main(@builtin(global_invocation_id) global_id : vec3<u32>) {
|
|||
|
||||
let random = random(id + u32(settings.time * 10000 + agent.position.y * 10 + agent.position.x));
|
||||
|
||||
let weightForward : f32 = sense(agent, 0.);
|
||||
let weightLeft : f32 = sense(agent, settings.sensorAngle);
|
||||
let weightRight : f32 = sense(agent, -settings.sensorAngle);
|
||||
let weightForward: f32 = sense(agent, 0.);
|
||||
let weightLeft: f32 = sense(agent, settings.sensorAngle);
|
||||
let weightRight: f32 = sense(agent, -settings.sensorAngle);
|
||||
|
||||
if (weightForward < weightLeft && weightForward < weightRight) {
|
||||
agent.angle += (random - 0.5) * 2. * settings.turnRate;
|
||||
|
|
@ -63,15 +63,15 @@ fn main(@builtin(global_invocation_id) global_id : vec3<u32>) {
|
|||
agents[id] = agent;
|
||||
}
|
||||
|
||||
fn sense(agent : Agent, sensorAngleOffset : f32) -> f32 {
|
||||
let sensorAngle : f32 = agent.angle + sensorAngleOffset;
|
||||
let sensorDir : vec2<f32> = vec2(cos(sensorAngle), sin(sensorAngle)) / normalize(settings.size);
|
||||
let sensorPos : vec2<f32> = agent.position + sensorDir * settings.sensorOffsetDst;
|
||||
fn sense(agent: Agent, sensorAngleOffset: f32) -> f32 {
|
||||
let sensorAngle: f32 = agent.angle + sensorAngleOffset;
|
||||
let sensorDir: vec2<f32> = vec2(cos(sensorAngle), sin(sensorAngle)) / normalize(settings.size);
|
||||
let sensorPos: vec2<f32> = agent.position + sensorDir * settings.sensorOffsetDst;
|
||||
return textureLoad(TrailMapIn, vec2<i32>(sensorPos * settings.size), 0).x;
|
||||
}
|
||||
|
||||
fn random(state0 : u32) -> f32 {
|
||||
var state : u32 = state0;
|
||||
fn random(state0: u32) -> f32 {
|
||||
var state: u32 = state0;
|
||||
state = state ^ 2747636419u;
|
||||
state = state * 2654435769u;
|
||||
state = state ^ (state >> 16u);
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
struct Settings {
|
||||
size : vec2<f32>,
|
||||
deltaTime : f32,
|
||||
time : f32,
|
||||
size: vec2<f32>,
|
||||
deltaTime: f32,
|
||||
time: f32,
|
||||
brushWidth: f32,
|
||||
brushBlurWidth: f32
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> settings : Settings;
|
||||
@group(0) @binding(0) var<uniform> settings: Settings;
|
||||
@group(0) @binding(1) var Sampler: sampler;
|
||||
@group(0) @binding(2) var noise : texture_2d<f32>;
|
||||
@group(0) @binding(2) var noise: texture_2d<f32>;
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) position : vec4<f32>,
|
||||
@location(0) screenPosition : vec2<f32>,
|
||||
@location(1) start : vec2<f32>,
|
||||
@location(2) end : vec2<f32>
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) screenPosition: vec2<f32>,
|
||||
@location(1) start: vec2<f32>,
|
||||
@location(2) end: vec2<f32>
|
||||
}
|
||||
|
||||
@vertex
|
||||
fn vertex(
|
||||
@location(0) screenPosition : vec2<f32>,
|
||||
@location(1) @interpolate(flat) start : vec2<f32>,
|
||||
@location(2) @interpolate(flat) end : vec2<f32>
|
||||
@location(0) screenPosition: vec2<f32>,
|
||||
@location(1) @interpolate(flat) start: vec2<f32>,
|
||||
@location(2) @interpolate(flat) end: vec2<f32>
|
||||
) -> VertexOutput {
|
||||
let uv = screenPosition / settings.size;
|
||||
let position = uv * 2.0 - 1.0;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
struct Settings {
|
||||
size : vec2<f32>,
|
||||
deltaTime : f32,
|
||||
time : f32,
|
||||
size: vec2<f32>,
|
||||
deltaTime: f32,
|
||||
time: f32,
|
||||
|
||||
diffusionRate : f32,
|
||||
decayRate : f32,
|
||||
diffusionRate: f32,
|
||||
decayRate: f32,
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> settings : Settings;
|
||||
@group(0) @binding(0) var<uniform> settings: Settings;
|
||||
@group(0) @binding(1) var Sampler: sampler;
|
||||
@group(0) @binding(2) var trailMap : texture_2d<f32>;
|
||||
@group(0) @binding(2) var trailMap: texture_2d<f32>;
|
||||
|
||||
@fragment
|
||||
fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
struct Settings {
|
||||
size : vec2<f32>,
|
||||
deltaTime : f32,
|
||||
time : f32,
|
||||
size: vec2<f32>,
|
||||
deltaTime: f32,
|
||||
time: f32,
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> settings : Settings;
|
||||
@group(0) @binding(0) var<uniform> settings: Settings;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var TargetTexture : texture_2d<f32>;
|
||||
@group(0) @binding(2) var TargetTexture: texture_2d<f32>;
|
||||
|
||||
@fragment
|
||||
fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
struct VertexOutput {
|
||||
@builtin(position) position : vec4<f32>,
|
||||
@location(0) uv : vec2<f32>,
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) uv: vec2<f32>,
|
||||
}
|
||||
|
||||
@vertex
|
||||
fn vertex(
|
||||
@location(0) position : vec2<f32>,
|
||||
@location(1) uv : vec2<f32>
|
||||
@location(0) position: vec2<f32>,
|
||||
@location(1) uv: vec2<f32>
|
||||
) -> VertexOutput {
|
||||
return VertexOutput(vec4(position, 0.0, 1.0), uv);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue