Questions tagged [wgsl]

WGSL is the shading language specifically designed for WebGPU. Use this tag for questions about shaders syntax, bugs, usage in WebGPU and implementation details in comparison to other shader languages such as GLSL and HLSL.

37 questions
0
votes
1 answer

What's the equivalent of GLSL's uintBitsToFloat in WGSL?

I am converting a random number generator from GLSL to WGSL, and it uses the function uintBitsToFloat. What's the equivalent in WGSL? Example use, from https://www.shadertoy.com/view/Mt3cRX: uint Hash_Wang(uint key) { key = (key ^ 61u) ^ (key >>…
javirk
  • 23
  • 5
0
votes
1 answer

SDF WebGPU. How to modify the code for SDF purpose like in ShaderToy.com?

I want to create a WebGPU version of Shadertoy, but I can't to prepare the code correctly. How to draw in @fragment shader for SDF in WebGPU ? I clipped space [-1,1, 1,1, -1,-1, 1,-1] of canvas but what I need to do next ?
Teamur
  • 67
  • 1
  • 4
0
votes
2 answers

Rust WGPU Atomic Texture Operations

TL;DR: Is it possible to access textures atomically in WGSL? By atomically, I mean like specified in the "Atomic Operations" section of the documentation of OpenGL's GL_TEXTURE_*. If not, will changing to GLSL work in WGPU? Background: Hi, recently…
Ely Shaffir
  • 317
  • 3
  • 17
0
votes
1 answer

How can I declare and use a *constant* array in a WGSL vertex shader?

Background I'm trying to render a single triangle by encoding the vertices directly in my WGSL vertex shader. My idea was to have a global constant array, TRI_VERTICES contain the vertices of the triangle, from which I will look up the appropriate…
statusfailed
  • 738
  • 4
  • 15
0
votes
1 answer

What's the idiomatic replacement for glsl output parameters in wgsl?

In glsl and hlsl, I can define a function like this: float voronoi(vec2 x, out int2 cell) { cell = ... return ... } However, it doesn't seem like this is possible in wgsl. What's the intended replacement for this? I guess I could define a…
bobbaluba
  • 3,584
  • 2
  • 31
  • 45
0
votes
1 answer

How to use a random number within WGSL?

I'm trying to create a fragment shader in a WebGPU application for rendering a black white image noise. White_noise (wikipedia) For this I just want each pixel to have a random color value like this: [[stage(fragment)]] fn main() -> [[location(0)]]…
Michael Hilus
  • 1,647
  • 2
  • 21
  • 42
0
votes
1 answer

Deriving transformation matrix in wgsl shader

Deriving the transformation matrix is a fairly common requirement for shaders. Are there and wgsl standard libraries for doing this sort of thing? i.e. even mat4x4 - mat4x4 multiplication would be useful! I've written a rough draft below, but it…
1 2
3