Announcement

Collapse
No announcement yet.

Milkdrop fun with multi images

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

  • Milkdrop fun with multi images

    Hi all, I just throwing these presets I've been messing with in a new thread in case anyone is interested in doing something with these. I kind of hit a stopping point with what I can do with the limited (non-existent) coding knowledge I have.

    What is this you ask? When I saw amandio c - muybridge's horse, I thought it would be awesome to be able to swap different pictures into a preset for different effects, kind of like having a template for multiple images for a preset. Well, obviously Milkdrop and other presets doesn't play nice with multiple images and trying to mix shaders into this did not work. When it is coded into gmagabuf, then some shaders would work, but I am clueless on gmagabuf.

    Until I stumbled on a preset by none other than, Martin, with his face down ass up preset, and that was a huge help.

    In my trying to understand this, amandio c was able to sequence 16 images that ran in order in the per-frame section whereas Martin did it in the warp shader which limited it to 5 images but was able to be forced to play nice with other presets. Amandio c's did their thing no matter what.

    So xmuzack + martin + various - stormy midnight drive is 5 pics with effects in a 12345 sequence that reacts to music and

    xmuzack + martin + various - EQ Dancer has effects, reacts to music too but the images show up in random order instead of 12345 sequence. I was trying to have the dancer hit a different pose each time a beat hit, but it's not quite there, lol

    Anyone is welcome to tinker with these or make it better if so desired, I hit a dead end on what else I can do to make these better.

    Apologies in advance to Martin, I butchered your coding.
    Attached Files

  • #2
    decided to have fun too

    I too, have a similar vision, for multiple images serving more than horse, but I'm becoming aware that the dancer has her limits as well.

    Back before the legend endowed my feeble grasp on Milkdrop, I was scavenging google images for .gifs to disassemble and mash in with shaders. Today, I still get very confused. It might take me a whole semester of kindergarten to connect the dots with your equations, so instead of tinkering with your preset, I tinkered with the dancer and put her in a preset I have been tinkering with recently. Somehow I've already reached the maximum # of textures, so I wasn't able to squeeze in the last image, but she still mashes well with comp shaders. Until I tinker out where this extra texture is, I'll save my questions about the legends water effects.

    By the way, I love that jellyfish you did. You did more with that one image than I with fifteen.
    Attached Files

    Comment


    • #3
      Butterbeaster, thanks for the compliments, but I can't really take any credit for the coding since I'm sill struggling with Milkdrop coding and am merely working off of the back of giants like Martin and Flexi. Heck, even your coding is awesome. I still have your first preset you asked for help here in my rotation. I'm still trying to learn enough to where I can present my own original preset.

      Wow! Your !!!!!!!!!!!!!!tester4cuttlefish in bucket with chips and dip for xmuzacks dancer is amazing! I'm trying to figure out how you managed to get the bnot(t) in the per_frame working with the comp shaders. I tried and tried and tried and it either has no affect or shows a black screen, but you did it, wow. And Martin managed it with megabuf.

      I still have a lot of work ahead of me, lol

      Comment


      • #4
        Butterbeaster, I love how you defined the the samples in the warp shader using #define. Neat.

        Comment


        • #5
          I guess the best way to feed more textures into a preset is to pack them into a single file. Milkdrop supports DDS which I think is suitable, but I never tried it.

          @Butterbeaster: The preset does not show because textures are missing. Please do not expect me to have all textures posted on the forum on my drive.

          @xmuzack: What is your issue with bnot ? Whatever you define in the frames section, you can convey to the shaders via the q variables (and only these ! The shader sections do not know megabuf neither the reg variables).

          Tip: bnot(1-t%5) can be written shorter: t%5==1. These old milkdrop boolean functions still work but are no longer required, and can also be written in C style, e.g.
          bnot(a) is the same as !a (negation)
          equal(a,b) is the same as a==b
          above(a,b) is the same as a>b
          below(a,b) is the same as a<b
          band(a,b) is the same as a&b (bitwise and)
          Saves some typing and is easier to read

          Comment


          • #6
            Hi Nitorami, interesting you mentioned Milkdrop supporting DDS. I'm going to have to play with that since Photoshop is in my background. So would learning C or C++ be a help for a few ideas I have for Milkdrop? Tons of resourses on C on the web, and it seems to me Butterbeaster used some C. I could be wrong of course.

            Here's the issues I'm having, I'm sorry if this is a bit long:

            Barrowed form Amandio C's Muybridge Horse and shortened to used 5 images, I understand that the samples is defined in the comp shader so the only way for that to work is to manually work the shaders in there. Example being the Muybridge Horse pixelated preset (not shown below).

            per_frame_15=t=200*(2-.05*time);
            per_frame_16=q12=bnot(t%5);
            per_frame_17=q13=bnot(1-t%5);
            per_frame_18=q14=bnot(2-t%5);
            per_frame_19=q15=bnot(3-t%5);
            per_frame_20=q16=bnot(4-t%5);
            warp_1=`shader_body {}
            comp_1=`sampler sampler_dancer1, sampler_dancer2, sampler_dancer3, sampler_dancer4, sampler_dancer5;
            comp_2=`
            comp_3=`shader_body
            comp_4=`{
            comp_5=`
            comp_6=`if (q12) { ret=(tex2D(sampler_dancer1,uv)); }
            comp_7=`if (q13) { ret=(tex2D(sampler_dancer2,uv)); }
            comp_8=`if (q14) { ret=(tex2D(sampler_dancer3,uv)); }
            comp_9=`if (q15) { ret=(tex2D(sampler_dancer4,uv)); }
            comp_10=`if (q16) { ret=(tex2D(sampler_dancer5,uv)); }
            comp_11=`
            comp_12=`}


            ---------------------------------------------------------------------------------

            Then I tried moving it from comp shader to the warp shader, the screen goes white and I get this flag:

            error compiling ps_2_a warp shader:
            (170): error X3017: cannot implicitly convert from 'const float2' to 'float3'


            per_frame_15=t=200*(2-.05*time);
            per_frame_16=q12=bnot(t%5);
            per_frame_17=q13=bnot(1-t%5);
            per_frame_18=q14=bnot(2-t%5);
            per_frame_19=q15=bnot(3-t%5);
            per_frame_20=q16=bnot(4-t%5);
            warp_1=`sampler sampler_dancer1;
            warp_2=`sampler sampler_dancer2;
            warp_3=`sampler sampler_dancer3;
            warp_4=`sampler sampler_dancer4;
            warp_5=`sampler sampler_dancer5;
            warp_6=`
            warp_7=`shader_body{
            warp_8=`
            warp_9=`ret= q12*(sampler_dancer1,uv);
            warp_10=`ret= ret+tex2D+q13*(sampler_dancer2,uv);
            warp_11=`ret= ret+tex2D+q14*(sampler_dancer3,uv);
            warp_12=`ret= ret+tex2D+q15*(sampler_dancer4,uv);
            warp_13=`ret= ret+tex2D+q16*(sampler_dancer5,uv);
            warp_14=`
            warp_15=`}


            ---------------------------------------------------------------------------------------

            This flag pops up when I try these:

            error compiling ps_2_a warp shader:
            (170): error X3017: cannot implicitly convert from 'const float2' to 'float3'


            warp_9=`if (q12==1) {ret = tex2D (sampler_dancer1, uv1*texsize.xy*texsize_001.zw);}
            warp_10=`if (q13==2) {ret = tex2D (sampler_dancer2, uv1*texsize.xy*texsize_001.zw);}
            warp_11=`if (q14==3) {ret = tex2D (sampler_dancer3, uv1*texsize.xy*texsize_001.zw);}
            warp_12=`if (q15==4) {ret = tex2D (sampler_dancer4, uv1*texsize.xy*texsize_001.zw);}
            warp_13=`if (q16==5) {ret = tex2D (sampler_dancer5, uv1*texsize.xy*texsize_001.zw);}


            error compiling ps_2_a warp shader:
            (170): error X3004: undeclared identifier 'text2D'


            warp_9=`ret= ret+tex2D+q12*(sampler_dancer1,uv);
            warp_10=`ret= ret+tex2D+q13*(sampler_dancer2,uv);
            warp_11=`ret= ret+tex2D+q14*(sampler_dancer3,uv);
            warp_12=`ret= ret+tex2D+q15*(sampler_dancer4,uv);
            warp_13=`ret= ret+tex2D+q16*(sampler_dancer5,uv);


            error compiling ps_2_a warp shader:
            (170): error X3004: undeclared identifier 'text2D'


            warp_9=`ret= tex2D+q12*(sampler_dancer1,uv);
            warp_10=`ret= tex2D+q13*(sampler_dancer2,uv);
            warp_11=`ret= tex2D+q14*(sampler_dancer3,uv);
            warp_12=`ret= tex2D+q15*(sampler_dancer4,uv);
            warp_13=`ret= tex2D+q16*(sampler_dancer5,uv);


            Obviously, I'm missing something here. Thanks for your help.
            Last edited by xmuzack; 18 February 2018, 15:02. Reason: formatting

            Comment


            • #7
              xmuzack
              your code has a lot of blatant errors.

              ret= q12*(sampler_dancer1,uv); makes no sense and should be
              ret= q12*tex2D(sampler_dancer1,uv);

              Then,
              ret= ret+tex2D+q13*(sampler_dancer2,uv);
              What does that mean? You probably meant
              ret= ret+q13*tex2D(sampler_dancer2,uv);

              The message
              error compiling ps_2_a warp shader: (170): error X3004: undeclared identifier 'text2D'
              probably means that you typed text2D instead of tex2D. Check for typos.

              Comment


              • #8
                Blatant errors is an understatement. I've spent weeks trying to figure this out and it was staring right at me in my face. I'm a dunce, lol Thank you Nitorami for pointing this out to me. Honestly, I was scared of asking for help.

                So, tex2D has to be right next to the () and Milkdrop was screaming to me the answer, undeclared identifier 'text2D' wow. I'll work on improving my coding.

                Whelp, the code worked as soon as I fixed it and I now realized it's not limited to only 5 images. Yay.

                Hmm, I wonder why my mistakes worked in the comp_shader and not in the warp_shader. Interesting. Disregard this last sentence, I see my mistake here.
                Last edited by xmuzack; 18 February 2018, 21:01. Reason: Added sentence

                Comment


                • #9
                  tex2D(uv, some_texture) is a function, and "samples" some_texture at point uv.
                  uv has a x- and y- coordinate uv.x and uv.y.
                  Both are floating point numbers between 0...1.
                  So uv contains 2 floating point numbers and is therefore of type "float2". A "point" in x-y-coordinates.
                  The shader works on all pixels at the same time. What happens when you define

                  ret = tex2D(sampler_dancer1,uv);

                  is that the shader "samples" the texture sampler_dancer.jpg at each x,y coordinate between (0;0) and (1;1) at the same time and throws the result to the screen (which is "ret").

                  More precisely not each coordinate, because the number of possible coordinates would be infinite, but each pixel. On a 1024 x 1280 screen, this would be 1.310.710 pixels.

                  Comment


                  • #10
                    Thanks Nitorami, if I remember correctly, I believe I saw a post from you from years ago, where you mentioned images within Milkdrop wasn't your strong suit.

                    The explanation you just gave me above is the best explanation I've read on the mysteries of tex2D, Milkdrop coordinates and ret and makes reading the Milkdrop Preset Authoring Guide a bit easier to comprehend. I'll be working through it again with your insight in mind.

                    Thank you once again.

                    Comment


                    • #11
                      To a lot of folks, shaders seem to be a mystery. And indeed shader programming is different to what one would naively expect when doing a image processing routine in a language like C or any other. We would start with loops
                      code:

                      for x:= 0 to 1279 do
                      for y := 0 to 1023 do
                      ret := Some_Colour_as_function_of (x,y)
                      end;
                      end;

                      In the shaders, the loop is implicit. You do not need to define it manually. It took me quite a long while to understand this principle:

                      The video card runs the exact same shader code for each pixel on the screen.
                      Then why isn't each pixel the same and we only see a uniform screen ?
                      Because the code uses variable uv, which is the screen position for each pixel.

                      The entire shader code is one big formula which does the same for each pixel, only depending on the screen position uv. If your code does not use uv, all pixels will inevitably be the same. Using uv is the ONLY way to produce some sort of picture.

                      For instance,

                      ret = tex2D(sampler_dancer, uv); - samples the content of texture sampler_dancer at each pixel.

                      ret = uv.y; - produces a vertical grayscale.

                      ret.g = sin (50*uv.x); - produces vertical green stripes.

                      ret = float3 (0.1, 0.5, 0.9); - produces a uniform blueish screen. As we did not use uv here, the screen can only have uniform colour.

                      Remember this. It helps.

                      Comment


                      • #12
                        Very insightful posts Martin. I wish this was explained better in the milkdrop tutorial, but, well, here it is . Helps me a lot in understanding !
                        Creativity turned into madness. And then back again.

                        Comment

                        Working...
                        X
                        😀
                        🥰
                        🤢
                        😎
                        😡
                        👍
                        👎