F
fig2k4

  • Jul 11, 2023
  • Joined Jun 24, 2023
  • 1 best answer
  • I noticed that there's multiple updates as the preview is generated, which isn't great when your creating a texture from the end result, so I added a preview_complete to the module that only gets fired once.

    This is the script to produce the texture that I needed.

    And the texture on a simple plane.

  • So, I wrote a module almost exactly the same as the github project I mentioned and I now have a something that works pretty well.

    I realise now that ColorRect is basically just a canvas so it's not possible to convert it to a texture. What I should try is drawing the waveform to an Image and then create a TextureImage from that. I'm sure that's how it's supposed to be done.

    Here's the ColorRect script that produces the waveform.

  • Hi, I have 2 questions that I can't get my head around. If someone could point me in the right direction I'd appreciate it.

    I need to generate a visual waveform as a texture. I see there's an AudioStreamPreviewGenerator class but is this available in GDScript 4? There's a Github project here that's basically just a copy of the Godot code with the added bind functions to make it accessible in GDScript via a custom module. It's been inactive for over a year so I was going to update it for Godot 4 myself, but that leads me to question 2.

    The example script from that project draws to a ColorRect. Most shaders I've seen also do the same. Could someone please tell me how I can convert a ColorRect to a texture so I can use it on a 3D object? Just FYI, I'm working on a VR project so using 2D overlay isn't an option.

    • I noticed that there's multiple updates as the preview is generated, which isn't great when your creating a texture from the end result, so I added a preview_complete to the module that only gets fired once.

      This is the script to produce the texture that I needed.

      And the texture on a simple plane.