No announcement yet.

Custom material - getting object position

  • Filter
  • Time
  • Show
Clear All
new posts

    Custom material - getting object position

    Hi everyone,

    Was just wondering if anyone knows if it's possible to get a reference a different object position than to the current one which has the material applied to it or the camera position??

    I would like to try and create a pretty cool effect when a certain object nears the material. I am thinking of using the custom material node for this.

    Any help would be much appreciated


    If you look at the material compendium documentation on the udn website:

    I am trying to get a similar effect to the example they give for the Pixel depth node but instead of the distance between the pixel and the camera, i need to find the distance between an object and the pixel. Does that make sense????


      Ok finally got it sorted and looking right

      Found out that opacity masks don't work on translucent materials so changed it to additive and just used the opacity channel.

      I used the fog shader tutorial from Chris's website:

      I got some ideas from and combined them together and ended up with a pretty kl looking shader

      Sorry can't be more specific!!!


        You can't directly call another object through the material editor with the default nodes. Translucent materials require that you use the opacity input instead of the opacity mask input. additive shouldn't need either input. It just adds its color to whatever is behind it.
        If you want to check any time anything is close to the material, you can use a depth biased alpha to create a mask that you can use to detect nearness of other objects, but you can't be specific (Only that one boulder).

        I'm glad that you got something working. If you still want to refine it more, I can probably help you.


          Kl thanks for that Wyldhunt, very useful information

          By any chance do you know much about Cascade? I have found some modules that you can't use by default and was wondering if you knew how to add them to the list?

          I will prob be asking you some more questions about materials too Thanks!


            Unfortunately, I don't know much at all about Cascade. I can make materials do almost anything that doesn't require HLSL, but I Fail at particles. Which modules are you referring to, exactly? I can take a look and see if I can figure it out.


              I was asked to try and make a rain effect and i didn't like all the work you had to put into doing the plane version i've seen around so i thought i'd try a particle effect version. I saw that there were collisions and event scripts you can call so i thought great, i'll set an emitter at the top of my world and set the particles to call the splash particle effect upon impact but i just couldn't get this to work.

              I then read somewhere that in unreal tournament 3 they used a rain particle effect and looking through the source code for UDK i found the ParticleModuleUberBase class and the subclasses ParticleModuleUberRainDrops, ParticleModuleUberRainImpact, ParticleModuleUberRainSplashA, ParticleModuleUberRainSplashB. And now the problem i face is that these options don't appear in the cascade editor along with the other options such as velocity or location :S

              I'm still comparing these modules to find out exactly whats different in them but i'm dreading thats its something embedded in C++


                What part of your rain emitter failed? Did it make the rain and just fail to splash, or did it fail entirely?

                One thing that I can almost guarantee needs to be done:
                The emitter needs to be attached to the player so that it follows them and only rains in a circle around them (Large enough so that they can't tell). If you make a huge emitter, you'll lag to death. Slow and painful.

                Here's a video that shows how to make a splash effect:

                If you're limiting the rain effect to be just around the player, you may be able to make random splash effects over a wider area around them. Lining up the effects may not be necessary. Not many players are going to track an individual raindrop to see where it lands if their screen is full of rain.

                That Rain emitter is interesting. I've no idea where to begin trying to use it though.


                  Ye thanks Wyldhunt i already knew that using it over the entire level would be very laggy but for the purposes i'm using it this would be ok

                  I can't remember what it was i had, but basically i had the collision module setup so that it would kill the sprite on impact but this only ever worked in the cascade editor. Whenever i tried it in the game world (using the exact same static mesh in the editor and bsp) it failed to collide and continued to fall through the level.

                  I disabled the life time module so perhaps this needs to be set in order for the collision module to work properly?

                  The problem i foresee with attaching the emitter to the player is that when the player goes indoors, it will be trouble getting the rain to appear outside (with a good standard, not using triggers so that it abruptly appears). I was thinking of making a collision component for the emitter so that when it hit an object it would simply stay put until it was freely able to follow the player again.

                  I think i forget to mention in my haste that the type of game is a third person action game


                    Keep in mind that I haven't ever used Cascade or particle systems...
                    But, I do know that there's an option in meshes where you can set them to be a fluid drain. If your rain is a fluid particle, then that would make your rain go away as soon as it touched the mesh instead of falling through it.

                    I'll see about looking in to particle stuff more. I need to do that anyway.
                    Right now, I think I'm mostly just managing to bump your thread to make sure everyone else has a chance to respond.