Announcement

Collapse
No announcement yet.

RayMarching Presets

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RayMarching Presets

    I spent a lot of time learning raymarching method in the last year, mostly on shadertoy, and I wanted to implement some of my shaders also on milkdrop, so I could get a good reaction to the music.
    Yet I noticed that its not optimal to implement raymarching shaders on milkdrop, since it take a lot of time to compile, especially when I compute light and shadows, and you gonna need a decent gpu for this.. so yeah, its not gonna work right on any pc, but its still fun to play with

    So, I am sharing with you guys some of them here: Download
    you can see a sample to each preset inside

  • #2
    Hi nivush
    the screenshots look great, but I cannot get any of the presets running. It is just black screeen.

    I found that the presets all use shader "version 4"

    PSVERSION=4
    PSVERSION_WARP=4
    PSVERSION_COMP=4

    which is known to cause problems on many video cards.

    You probably needed version 4 because this allows 1024 instructions rather than 512. I tried to change manually to version 3 but then I get other errors such as "variable d0 is not initialized", "loop does not appear to terminate in a timely manner", "invalid const register num: 32. max allowed is 31"...

    Comment


    • #3
      Originally Posted by Nitorami View Post
      Hi nivush
      the screenshots look great, but I cannot get any of the presets running. It is just black screeen.

      I found that the presets all use shader "version 4"

      PSVERSION=4
      PSVERSION_WARP=4
      PSVERSION_COMP=4

      which is known to cause problems on many video cards.

      You probably needed version 4 because this allows 1024 instructions rather than 512. I tried to change manually to version 3 but then I get other errors such as "variable d0 is not initialized", "loop does not appear to terminate in a timely manner", "invalid const register num: 32. max allowed is 31"...
      hey martin
      yes, I needed version 4 because of that..
      sorry that its not working for you.
      anyway, you can visit my page in shadertoy, I made many similar shaders there.
      I also mentioned you in "Heading to sun" shader, since I took your code for the stars tunnel, hope you alright with that

      Comment


      • #4
        also, if you can give me a hint about your 3d effects method, ill be really happy, since raymarching is too heavy for making presets in milkdrop..

        Comment


        • #5
          Hi nivush

          Looks great. What a pity this cannot be done in milkdrop. At least not at reasonable cost.

          I myself used raymarching (or sort of) only in the mandelbox presets, e.g. frosty caves. As you say, it is way too expensive to sample the entire (x,y,z)-space so I used a few tricks. Essentially, the z coordinate of the mandelbox structure is estimated, using neighbouring screen points, then buffered, then refined in the next frame etc. Unfortunately, milkdrop does not provide a buffer to store contents over two frames except ret in the warp shader. So I had to sacrifice ret.gb for the buffer (I need 16bit resolution, hence 2 colour channels).

          All other 3D effects are based on transforming the uv coordinates and mapping a texture to it. Say we want to show a 2D plane in "real world" 3D space. Plane parallel to the screen is trivial, but we want its tilted or rotated.

          Let (x,y,z) be the real world coordinates, where z points forward (in viewing direction). I.e. z is the "depth".

          Let the plane be drawn as a noise texture as follows:
          ret = tex2D(sampler_noise_lq, float2 (p,q));

          p and q are two orthogonal 3D vectors spanning the texture. Obviously if (p,q) = uv, we'll get to see the "normal" noise texture in the screen plane. This is not what we want.

          Let us instead define p and q arbitrarily in the (x,y,z) space. General form:
          p = a*x + b*y + c*z
          q = d*x + e*y + f*z

          Obviously the coefficients a,b,c etc need to be in a certain relation to assure orthogonality of p and q; I won't bother about that now.

          The problem is: z does not exist. Milkdrop does not allow to define objects with a z coordinate. All it offers is uv.xy, the flat screen. In principle, projecting a texture arbitrarily rotated in space is a trivial task but milkdrop's lack of a geometry or z coordinate requires do it ass-backwards.

          Let's continue as if we had a z, and project our texture to the screen. The general projection rules are simple

          uv.x = x/z
          uv.y = y/z
          where (x,y,z) are all the points of the texture spanned by (p,q)... is that clear ? I struggle to explain without pictures.

          There is no way to get z. But if you use these 4 equations with each other, you'll find that x,y,z can be eliminated and you can express (p,q) as a function of uv only. Use this (p,q) for the texture mapping and voila.

          Don't know if that is understandable, I would need a few pictures and a worked example to make it clearer. It' s rather twisted. It works, but only for simple geometries, e.g. flat planes, cylindric tubes or similar. With more complex structures, e.g. a toroid, closed solutions for the equations likely don't exist or will get ridiculously complex.

          Martin

          Comment


          • #6
            Nivush, wanted to chime in here that your raytracing presets works on a cheap Intel laptop with integrated graphics. Some like the Circus Torus preset took like maybe 10 seconds to load and run. I wonder if that's the issue Martin is running into. He would really like these I imagine. It appears that Milkdrop can handle this. I'm using Winamp 5.66.

            These presets looks absolutly stunning! Especially the Torus Disco. Thanks for sharing with us here.

            I was browsing through shadertoy.com a few months ago and was meaning to start going trough some of their lessons, but life and work got in the way unfortunately. I need to go back and take a look.

            edit: I loaded your presets on a slightly newer laptop with AMD non-integrated graphics and the presets do not work on it. The AMD also makes some of my Milkdrop remixed presets wonky and a bit broken whereas it looks great on the Intel laptop.

            edit #2: So maybe Milkdrop plays nice with only Intel equipped PCs? I already know that any future laptop I buy must have Intel. Love Winamp and Milkdrop too much.
            Last edited by xmuzack; 19 March 2020, 01:13. Reason: Add info

            Comment


            • #7
              I think it is not as simple as blaming it to AMD. I believe (just guessing) the issue may be whether the compiler does a loopunroll optimization or not. If I change the circus_torus code to shader 3 and reduce MaxSteps to 1 (and correct the indeed uninitalised variable dO), I get an error after a few seconds compilation time that the compiled code uses too many instruction slots (1107 of 512 allowed).
              When increasing MaxSteps to 5, the compiler tells me after bloody ages that it would require even 2445 instructions... which allows me to estimate that with the original MaxSteps=100 the code would require approximately 20000 instructions. That is completely impossible, the maximum is 1024 even with shader model 4. So I guess my compiler under milkdrop tries to unroll the loop, unnecessarily duplicating code and making it impossible to fit into 1024 instructions. While shadertoy does NOT unroll and therefore needs far less instructions which do not scale with MaxSteps, at the cost of possibly slightly worse performance.

              As shadertoy can compile and run the code on my machine, this compiler behaviour cannot be machine specific but must be controllable. Not via milkdrop however. Maybe in global video / driver settings ? But I cannot find anything useful in the nvidia control center either.

              P.S. My own mandelbrot orbit trap preset, which I wrote on a PC with AMD CPU & Nvidia GPU, does not run any longer on my new PC which also has an AMD CPU & Nvidia GPU... just 15 years later. The preset also has a loop of depth 50, so this smells like a similar issue.

              Comment


              • #8
                Hey guys!!!
                nivush your presets are amazing! I had a lot of fun mashing/editing them up.
                have a look :

                Comment


                • #9
                  These are pretty cool, especially circus torus (so psychedelic because of the repeating intricate pattern) and torus disco. Any chance you could share the texture "s.j" which the heading to the sun presets try to load?

                  Comment

                  Working...
                  X