How are shader uniforms supposed to work? #8172
Unanswered
Kimmottaja
asked this question in
Q&A
Replies: 3 comments
-
pain,too pain, after three year,no one answer, the path to learn shader sososososossoso hard |
Beta Was this translation helpful? Give feedback.
0 replies
-
here is v8.0 api version, I try to pass resolution to shader fragment.this way is work const shader = Shader.from({
gl: {
vertex,
fragment,
},
resources: {
shaderToyUniforms: {
iResolution: { value: [width, height, 1], type: 'vec3<f32>' },
iTime: { value: 0, type: 'f32' },
},
uTexture: (await Assets.load(runtimePath('/img/noise/perlin.jpg'))).source,
},
})
|
Beta Was this translation helpful? Give feedback.
0 replies
-
或者这种, 我是从迁移文档里找的 const uTime = new UniformGroup({
uTime: { value: 1, type: 'f32' },
})
const shader = Shader.from({
gl: {
vertex,
fragment,
},
resources: {
uTime,
uTexture: (await Assets.load(runtimePath('/img/noise/noise1.jpg'))).source,
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I can't get shader uniforms to work and can't find any documentation on how it's supposed to work.
I've tried using only the values and this seems to work fine for floats.
let uniforms = { time: 0 };
But specifying the type doesn't work for some reason.
let uniforms = { time: { type: '1f', value: 0 } }
For vectors I've tried:
let uniforms = { resolution: { type: '2f', value: [100, 100] } }
let uniforms = { resolution: { type: '2f', value: {x:100, y:100} } }
and
let uniforms = { resolution: {x:100, y:100} }
let uniforms = { resolution: [100, 100] }
But I can't get them to work.
How are they supposed to work? Should I use objects with type and value attributes or just the plain numbers?
I'm using pixi.js version 6.14.13
Beta Was this translation helpful? Give feedback.
All reactions