0
votes

tl;dr:

I'm a shader newbie and I'm trying to port an HLSL shader to GLSL.
What is the GLSL equivalent for RWTexture2D<float4> whatever; ?

I need to programmatically create a texture inside a shader.

Longer version:

I'm trying to port the "slime shader" from this video to GLSL, and load it in a web page (at the moment I'm using Three.js). I managed to code the pseudo-random hash function and display the noise on screen, but now I'm stuck.
(Here's the HLSL shader code)

In the original shader there is this: RWTexture2D<float4> TrailMap; and I can't find a way to make something similar in my shader. All the info that I have found online is about loading external textures, but what I need is a texture that is created and modified inside the shader (and it seems to me that the way GLSL handles textures is not very beginner friendly).

I also tried using this converter. What I get is uniform image2D TrailMap; but it gives me this error:

'image2D' : Illegal use of reserved word

What am I missing?

1
Try replacing image2D with sampler2D - Rojo
@Rojo: You can't write to a sampler. - Nicol Bolas

1 Answers

0
votes

WebGL doesn't have access to image load/store, the ability to modify image data arbitrarily within shaders. The converter is doing the right thing, but WebGL simply doesn't provide access to this hardware functionality.