Home Unreal Engine

UDK UV mapping a world position offset object, Almost done!

polycounter lvl 10
Offline / Send Message
tuxmask75 polycounter lvl 10
Okay guys, here's what's going down !

Im working on a game that uses a vertex shader to produce a fisheye effect for the level geometry which is constructed out of blocks.
(See video here: https://www.youtube.com/watch?v=iImBtvXtXrk&list=UUfDV5xinF2VjLd8LSAAfgCg

However since I wanted to speed up my workflow a bit , I went ahead and set up a single texture and material that can spread across multiple blocks, when I drag the block the texture stays in world space position, so that we can just drag the blocks around and have some nice UV tiling. This did not cut it when I applied it with the fisheye vertex shader! When the vertex moves the texture is in world position and did not move with the vertex. ( a sliding texture effect like a cubemap was produced for textures on sides and top... ( front and back worked correct)

Some time later I came up with a hacky method ! dudes it worked ! ( well with 1 issue )

Here is what I needed to do!

I had to set up 6 UV sets , and masked each with a vector direction. ( 1 for each side of the cube)
Next each one is added together so that each side has its own UV set.
this time it works with the fisheye shader! Hell fucken yeah manS !

Now guys ! Here is the issue i'm having,, (Look at the nods in the UV_STUFF_Tiling nod group) the Object world Position nod does not seem to take the object's Pivot point into consideration. It looks like its using the object's Bounding box center as a pivot point. (true pivot point is ignored!) (all my cubes have pivot at the bottom front left as a note)
So if we have objects that are different sizes than the tiling for the objects do not align between the sizes since the bounding boxes are not all the same. (ouch!)
Any one know how to wright up a custom nod to catch the objects true pivot point within the shader? There is a function in material function library, but it says only useable with world position offset.

Blocks of same size shown below, they tile side by side correctly! ( check box at top is the same as bottom)
bZ7QRT0.png

Block at top with different size ( UV offset shown with dotted line, bad offset caused by using bounding box pivot point instead of true pivot point to align material to.)
YhMYxn8.png

True UV's
265Q0WN.png

Block structure full on view.. works nice with 100% cubes ,,, Someone please help Break threw the pivot issue !
NOCrwzp.png

Replies

  • tuxmask75
    Options
    Offline / Send Message
    tuxmask75 polycounter lvl 10
    In case you guys may be confused as to what im in need of here..
    check these 2 screens out.

    Showing bounds center and object's pivot points for both models.
    The shader is using the Bounds center as the pivot, when it should be using the objects pivot point. That way the UV's generated by the shader are always aligned on an imaginary grid so that the texture always aligns between blocks of various sizes.

    I think the only way to pull this off would be threw a custom nod that locates the objects true pivot, replacing the Object world Position nod.

    DEH4Jlg.png

    ayeYPqO.png
  • tuxmask75
    Options
    Offline / Send Message
    tuxmask75 polycounter lvl 10
    Wow is the Unreal section of Polycount dead or what ?!
    Come on guys , really need help here.
  • tuxmask75
    Options
    Offline / Send Message
    tuxmask75 polycounter lvl 10
    Bump, this is killing me...
  • mAlkAv!An
    Options
    Offline / Send Message
    mAlkAv!An polycounter lvl 5
    I was going to suggest to transform a (0,0,0)-vector from local to world space but that's the material function you already mentioned. Unfortunately it's not working in the pixel shader for UE3 (it does for UE4). I've also looked trough some UE3 shader files but haven't found anything helpful to use in a custom node.

    There might be a way to get your initial approach (using world position UVs) working though.
  • tuxmask75
    Options
    Offline / Send Message
    tuxmask75 polycounter lvl 10
    mAlkAv!An wrote: »
    I was going to suggest to transform a (0,0,0)-vector from local to world space but that's the material function you already mentioned. Unfortunately it's not working in the pixel shader for UE3 (it does for UE4). I've also looked trough some UE3 shader files but haven't found anything helpful to use in a custom node.

    There might be a way to get your initial approach (using world position UVs) working though.

    If there is i'd really like to know ,feels like i've tried everything.
  • ImSlightlyBored
    Options
    Offline / Send Message
    ImSlightlyBored polycounter lvl 13
    you are correct, objectworld takes the center of the objects bounds.
    just look for actorworldposition (it may be named something different in U4) which takes the pivot location of the object, and not the bounds.

    I'm 99.99% confident this works, used it a lot.

    edit: "ActorPositionWS"
  • tuxmask75
    Options
    Offline / Send Message
    tuxmask75 polycounter lvl 10
    you are correct, objectworld takes the center of the objects bounds.
    just look for actorworldposition (it may be named something different in U4) which takes the pivot location of the object, and not the bounds.

    I'm 99.99% confident this works, used it a lot.

    edit: "ActorPositionWS"

    Okay,,, you've got to be kidding me ! all this trouble because I overlooked a simple nod ?! I feel pretty stupid just about now! Anyways thanks so much !
Sign In or Register to comment.