Skip to content

Commit

Permalink
Quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bbazukun123 committed Jan 5, 2024
1 parent fcd7c66 commit 7cf7401
Show file tree
Hide file tree
Showing 5 changed files with 18,050 additions and 36,017 deletions.
9 changes: 5 additions & 4 deletions filters/color-map/src/ColorMapFilter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vertex, wgslVertex } from '@tools/fragments';
import { Filter, GlProgram, GpuProgram, SCALE_MODE, Texture, TextureSource } from 'pixi.js';
import fragment from './color-map.frag';
import source from './color-map.wgsl';
import { Filter, Texture, TextureSource, GlProgram, GpuProgram, SCALE_MODE } from 'pixi.js';
import { vertex, wgslVertex } from '@tools/fragments';

type ColorMapTexture = TextureSource | Texture;

Expand Down Expand Up @@ -89,7 +89,8 @@ export class ColorMapFilter extends Filter
uSlicePixelSize: { value: 0, type: 'f32' },
uSliceInnerSize: { value: 0, type: 'f32' },
},
uMapTexture: options.colorMap,
uMapTexture: options.colorMap.source,
uMapSampler: options.colorMap.source.style,
},
});

Expand Down Expand Up @@ -144,7 +145,7 @@ export class ColorMapFilter extends Filter

if (texture && texture.source)
{
texture.source.style.scaleMode = this._scaleMode;
texture.source.scaleMode = this._scaleMode;
texture.source.autoGenerateMipmaps = false;
texture.source.style.update();
texture.source.update();
Expand Down
5 changes: 3 additions & 2 deletions filters/color-map/src/color-map.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct ColorMapUniforms {
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> colorMapUniforms : ColorMapUniforms;
@group(1) @binding(1) var uMapTexture: texture_2d<f32>;
@group(1) @binding(2) var uMapSampler: sampler;

@fragment
fn mainFragment(
Expand All @@ -28,8 +29,8 @@ fn mainFragment(
let s0: f32 = xOffset + (zSlice0 * colorMapUniforms.uSliceSize);
let s1: f32 = xOffset + (zSlice1 * colorMapUniforms.uSliceSize);
let yOffset: f32 = colorMapUniforms.uSliceSize * 0.5 + color.g * (1.0 - colorMapUniforms.uSliceSize);
let slice0Color: vec4<f32> = textureSample(uMapTexture, uSampler, vec2(s0,yOffset));
let slice1Color: vec4<f32> = textureSample(uMapTexture, uSampler, vec2(s1,yOffset));
let slice0Color: vec4<f32> = textureSample(uMapTexture, uMapSampler, vec2(s0,yOffset));
let slice1Color: vec4<f32> = textureSample(uMapTexture, uMapSampler, vec2(s1,yOffset));
let zOffset: f32 = fract(color.b * innerWidth);
adjusted = mix(slice0Color, slice1Color, zOffset);
altColor = vec4<f32>(color.rgb * color.a, color.a);
Expand Down
Loading

0 comments on commit 7cf7401

Please sign in to comment.