Тёмный

Object Space Gradient in UE4 

tharlevfx
Подписаться 15 тыс.
Просмотров 60 тыс.
50% 1

An Unreal Engine material tutorial to be able to create a dynamic object space gradient using math nodes, and then using that gradient to map a texture to the object in local space.
If you want to learn more about Materials in Unreal Engine check out my new course here:
tharlevfx.gumroad.com/l/ue5ma...
If you have any questions about Game Art VFX or the Unreal Engine then email me: tharlevfx@gmail.com
Or you can find more tutorials on my website: www.tharlevfx.com
or check out my work on the Unreal Marketplace:
www.unrealengine.com/marketpl...
or follow me on twitter @tharlevfx

Опубликовано:

 

27 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 90   
@Kokuyous3ki
@Kokuyous3ki Год назад
I'm so happy that there are people here who actually only include what we need in their tutorial. Not starting from how to make a cube in blender and import it so that we can learn what materials are before finally starting to talk about what is actually in the title
@xylvnking
@xylvnking 4 месяца назад
man you've come in clutch for me so many times. using this to reduce wpo wind for trees based on height. thank you.
@filipprimus7875
@filipprimus7875 5 лет назад
One of the best UE4 material technics tuts. The explanation of every node is invaluable. Thanks a lot!!
@__dane__
@__dane__ 3 года назад
This is likely the only video I've seen where someone shows a simple way to create an object world space gradient
@oisit
@oisit 2 года назад
Thank you so much for all you do to help everyone understand what's going on. Your tutorials are excellent!
@MelvilleG
@MelvilleG 3 года назад
Thanks man. As always - the most valuable info comes in a most humble manner. Just pure essense. Thank you for your work.
@ForeverPrototyping
@ForeverPrototyping 3 года назад
This was brilliant, thanks for explaining so clearly mate
@Obiwahn89
@Obiwahn89 3 года назад
Very high value content! I needed this and remembered you did a video about this.
@privaatsak
@privaatsak 3 года назад
Precisely what I was looking for - thanks so much!
@esk6a
@esk6a Год назад
Was looking for this! So useful and well explained! Thank you sir!
@byunjoy1320
@byunjoy1320 2 года назад
This objectlocalbound and divided is so useful
@RupertMcGruber
@RupertMcGruber 4 года назад
Thanks a bunch for this, super helpful and pleasant to follow!
@Lumpappsofficial
@Lumpappsofficial 4 года назад
Just what I needed for a SynthWave project videoclip ;) Thanks!
@aweidenhammer
@aweidenhammer 5 лет назад
Great tutorial, thanks! I've used several of your tutorials now to build up an ever-increasing library of MatFuncs that help our productions out a ton! This one in particular is so useful. I'm always wanting to make a quick object grad on something but not wanting to go bake one, or bother with ingesting a texture for the purpose. I added some cheapContrast, direction (component mask) switches, and paramaterized the offset value so the MF has some more control.
@tharlevfx
@tharlevfx 5 лет назад
Andrew Weidenhammer making it into a function is a great idea! Glad you’re finding these useful :)
@Daniel-be6cj
@Daniel-be6cj 2 года назад
Exactly what I needed, thank you!
@solennripoteau6218
@solennripoteau6218 3 года назад
Great tutorial, thank you!
@legacythegame
@legacythegame 4 года назад
Great stuff, cheers!
@aghayejalebian7364
@aghayejalebian7364 6 месяцев назад
HOLY SHIT THIS IS AWESOME
@werti4894
@werti4894 4 месяца назад
this is what I needed!! thank you so much
@glennet9613
@glennet9613 2 года назад
Great video, I'm planning to use it for a water shader by plugging it into opacity.
@habib90ful
@habib90ful Год назад
great tuts, subscribed
@user-jw9zn1fg9n
@user-jw9zn1fg9n 3 года назад
Amazing tutorial! This makes all the hassle we go through trying to create UVs in C++ unnecessary!
@terraint3697
@terraint3697 4 года назад
Thanks for this!
@Clazzid
@Clazzid 2 месяца назад
You can sort of get it to work with instances, using a VertexInterpolator after the Object position you now get the position of the instance, but no idea how to get the scale or bounds
@MarkOfArgyll
@MarkOfArgyll 4 года назад
I won't pretend to understand everything there, but it's exactly the sort of thing I've been looking for! Thank you so very much for doing tutorials! :) Subscribed - no brainer :D
@tharlevfx
@tharlevfx 4 года назад
Mark Brown thanks man, let me know if you have any questions or topic requests!
@MarkOfArgyll
@MarkOfArgyll 4 года назад
@@tharlevfx Once I've watched all of your UE4 vids, perhaps but I generally feel uncomfortable making requests from folks I haven't had much interaction with. Feels like I'm being "one of those" - you know what I mean? lol
@cmds.learning7426
@cmds.learning7426 4 года назад
cool work!tnanks
@huard666
@huard666 3 года назад
That is great, helped me a lot - THANKS
@anderl22
@anderl22 2 года назад
very helpful! thanks!
@kromenoi9082
@kromenoi9082 5 лет назад
Just thought I'd mention, this does work with foliage instances if you use the fairly new vertex interpolator node!
@tharlevfx
@tharlevfx 5 лет назад
Good to know! I’ll have to check it out :)
@VRock121
@VRock121 4 года назад
Wanna elaborate on how to achieve this?
@spacegamestudio
@spacegamestudio Год назад
sweet !! thanks man !
@miloszgierczak4806
@miloszgierczak4806 3 года назад
thank you!
@cr3ap3r1
@cr3ap3r1 2 года назад
Thanks for this pivot point gradient AO control! I was trying to use Texcoord control and it just wasn't working the way I wanted since the texture orientation on an atlas is not always bottom to top.
@IndyStry
@IndyStry 2 года назад
Thanks man!!
@fanyang2876
@fanyang2876 4 года назад
thanks this's help mush.
@rysone3173
@rysone3173 2 года назад
Thanks!
@SomeKindOfMattias
@SomeKindOfMattias 3 года назад
Ahh, very pedagogical, thanks! UV's and positions can be a bit hard to... wrap your head around ARRRR :))
@_UpVector_
@_UpVector_ 3 года назад
Hey, thanks man this is wornderful. To make it work with foliage over uneaven terrains (I need to inject a ramp on trees so they look like occluding each other the closer we get to the base), just stick a VertexInterpolator between the Object Position's TransformPosition branch and the subtract. Cheers!
@SuWoopSparrow
@SuWoopSparrow 3 года назад
Its not letting me use the vertex interpolator because its only available in pixel shaders. I'm not sure how to set my foliage material to a pixel shader. Do you know what determines this?
@NOOBIEPIE
@NOOBIEPIE 2 года назад
Hey Great video Thanks! Is there any way to make it work with Landscapes? because right now it just uses each draw cell as an object..
@anthonypossobon
@anthonypossobon 4 года назад
This was what I was looking for! Thanks for putting this together. Quick question, I'm using what you've done here as a UV just like you've shown by the end of the tutorial. I'm using this UV to funnel in my own custom gradient among other things. Everything is mapping correctly however, I am getting banding from my gradient which I assume is happening because of the Divide node with the ObjectLocalBounds. Mind pointing me into the right direction to smooth this out? Thanks in advance!
@tharlevfx
@tharlevfx 4 года назад
Anthony Possobon do you mean like a gradient map? It might be worth trying different compression settings, the uvs are mathematical so shouldn’t get banding but if you’re using a texture gradient too that might.
@anthonypossobon
@anthonypossobon 4 года назад
@@tharlevfx Actually I believe it's because I'm trying to cheat the system in what I'm sure is a very noob way of doing things :3. I used what you've shown in your tutorial to create a UV that plugs into the my objects material base color pin. Later, in a post processing material, I use ScreenTexture: Diffuse Color to get "UV" pass to do other effects like adding gradients and such. I'm sure because of this I'm getting the banding. Thanks for the reply and help!
@ScottBarrettihq
@ScottBarrettihq 3 года назад
good tutorial, but for future ones, because there is so much on screen, it is mostly impossible to read anything (even on my 40" screen). I recommend allowing the name of the node to fully appear before you slam enter and as well, call it out, more clearly, as though you were talking to a dog. My dog wasn't able to follow this at all.
@myelinsheathxd
@myelinsheathxd 2 года назад
thx!
@bobcharlotte8724
@bobcharlotte8724 Год назад
Hugs for that!
@houseofvultures582
@houseofvultures582 Год назад
will this work if the mesh is used in a niagara system? the gradient seems to resort back to world position in that case
@MrFabutan
@MrFabutan 2 года назад
I would love to know how to generate these gradients on a character in pre skinned space.
@ali3ser
@ali3ser 3 месяца назад
hello oliver!
@3xchris
@3xchris 2 года назад
Great video! How would I change this if I always wanted the black part of the gradient at the bottom all the time if the object gets rotated around?
@tharlevfx
@tharlevfx 2 года назад
If you use the World Position node you can create a gradient that’s always the same regardless of how the object is rotated
@LeonardoViale
@LeonardoViale 4 года назад
Sweet! Great tutorial! Question, what if we want to keep the gradient always aligned to the Z axis regardless of the object's rotation, but keep the gradient relative the the object bounds?
@tharlevfx
@tharlevfx 4 года назад
Leo good question! If you take the world position z, subtract the object position z to get the gradient 0 at the pivot and then divide by the object z bounds to get the scale correct? I think that should work!
@LeonardoViale
@LeonardoViale 4 года назад
@@tharlevfx Thanks! I tried that but doesn't make a difference, specially since there's a mask after those calculations are done, right? I tried without the world/local transform and kinda works but the gradient stays in the same position so it's not really working. I think the matter comes to getting the bounds to work independent of the object transforms so that way it reads the bounding box changing as you rotate for instance.
@tharlevfx
@tharlevfx 4 года назад
Leo I think you’re over complicating it - the world position z gives you a vertical gradient, subtracting the object position moves the gradient start point to the object and scaling by the object bounds scales it to be 0-1 on the object. I guess you technically need the lowest point of the bounding box and the vertical size of the rotated bounding box to get it perfect but I don’t think you can get that data in the material editor directly, so maybe the approximate solution isn’t good enough for your needs...
@LeonardoViale
@LeonardoViale 4 года назад
@@tharlevfx yeah maybe I'm trying to overthink it lol, your method is really good and works great, I'll add a parameter for the height and that'll work. Thanks for the help and great tutorial!
@alxleiva
@alxleiva 2 года назад
This is great, I just would like to know if there's a way to achieve this local bounds range on a post-process material? TransformVector only works on Surface materials. I'm trying to use the post-process volume's bounds as my domain.
@tharlevfx
@tharlevfx 2 года назад
You could probably use a blueprint to pass the volume dimensions to a material parameter collection?
@agathayu
@agathayu 4 года назад
Thank you so much for the tutorial. I was wondering how can i stretch the gradient across a fixed height from the bottom of object to say 2 units up?
@tharlevfx
@tharlevfx 4 года назад
try multiplying the gradient to change how quickly it goes from black to white, and adding to it to move where the black point starts. dont forget to clamp it if you only what values between 0 and 1
@agathayu
@agathayu 4 года назад
@@tharlevfx sorry It's not super clear for me. are you saying to add a multiply patch after the divide (by objectlocalbound) and connect it to a add node?
@tharlevfx
@tharlevfx 4 года назад
Agatha Yu I’m not sure exactly your problem - can you email me with screenshots? tharlevfx@gmail.com
@agathayu
@agathayu 4 года назад
@@tharlevfx I just sent you an email. Thanks so much!
@smsjs5138
@smsjs5138 2 года назад
thank you!!!!!!!
@davinsaputraartandgamedev9453
@davinsaputraartandgamedev9453 3 года назад
or the last thing you show, If I change the color to blue, and the transformvetor into world space, will I get a snow effect?
@tharlevfx
@tharlevfx 3 года назад
You could use this for a snow effect but check out my video on the dot product - that’s how I would automate snow on top of meshes
@witchreturns2263
@witchreturns2263 Год назад
Thank you very much! I have a question... a small detail about to ask. I created the exhaust for a floating craft with this and when I move it on the map the gradiant material is constrained to the obj. But, the problem appears when the object has it's own animation, such as... it raises a meter above earth so the gradiant get modified. In relation to the map is ok, but in relation to it's animation it gets modified. I hope you understand the issue... what can I do to fix it, to stay the same fully to itself, no matter what? except UV
@tharlevfx
@tharlevfx Год назад
If the object is animating and changing the bounding box then this might not work - probably uvs are the best solution I’m afraid. They usually are - there’s just some times where techniques like this can add something.
@witchreturns2263
@witchreturns2263 Год назад
@@tharlevfx Thank you for the reply! what I found is to simply try to animate the material's offset, when it's down and when it's up (to be the same). I think it will solve the issue fully
@yacue2843
@yacue2843 3 года назад
I have a question. When applied to a mesh, the gradient is well applied in the local direction. Why is it applied to a mesh particle and the gradient is in world coordinates? When the particle rotates
@tharlevfx
@tharlevfx 3 года назад
Mesh particles have their own space since the introduction of niagara - try transforming the gradient into mesh particle space and see if that works?
@ryanjstever
@ryanjstever 2 года назад
hmm, anyone know why my material blinks like crazy as soon as I divide obectlocalbounds? Latest UE5 build
@Rossilaz58
@Rossilaz58 Год назад
Could you theoretically use PerInstanceCustomData to get this working on foliage? (I don't need to get it working on foliage, just curious)
@tharlevfx
@tharlevfx Год назад
Check out the vertex interpolator video - it’s actually pretty simple to get per object data on foliage instances with that
@samliveshere88
@samliveshere88 3 года назад
is there a way to rotate the gradient after its set up for instance have it on a 45 degree angle?
@tharlevfx
@tharlevfx 3 года назад
If you take your two gradients and append them into a vector2 you should be able to plug that into a Rotator node and plug a constant into time to rotate the gradients
@tharlevfx
@tharlevfx 3 года назад
FYI - Rotators take an input in radians so a value of 2*pi will give you a full rotation. There’s also an inbuilt function containing pi if you need it.
@samliveshere88
@samliveshere88 3 года назад
thanks for getting back to me, just to clarify I'm appending the abs world position and the object position right after their transform position nodes and pluging that into the coordinate node for the rotator while having a constant in the time, sorry for the questions, materials can get confusing sometimes
@manmohan_manoj
@manmohan_manoj 2 года назад
Is there a way to make this work with vertex animation, it seems to treat is similar to the instances.
@tharlevfx
@tharlevfx 2 года назад
i'm not sure there is unfortuanately - the vertex animation won't affect the bounding box of the object which is used in the gradient calculation
@manmohan_manoj
@manmohan_manoj 2 года назад
@@tharlevfx one of my friends found a solution. PreSkinnedPosition node seems to be the solution. It gives you the right data and convert it though vertex interpolator and it goes with the mesh
@JONminiminiME
@JONminiminiME 11 месяцев назад
How many of you checked your phone at 3:29?
@richarddrenka
@richarddrenka 3 года назад
this basic material mappings for object based gradients should be already 'built in', even in basic mesh mapping settings.. not mentioning UE compiles thousands of 'shaders' in vain whenever possible, and still there are really basic things missing..
@DonEsteban3D
@DonEsteban3D 3 года назад
now borrow me magnifier glass to see your nodes...
@tharlevfx
@tharlevfx 3 года назад
Haha, sorry - it’s in 4K, I don’t make videos in this resolution anymore
@DonEsteban3D
@DonEsteban3D 3 года назад
@@tharlevfx Thx for this anyway :)
Далее
Refraction and Distortion with Scene Colour in UE4
10:32
Animating Materials with Gradients
15:29
Просмотров 18 тыс.
UE4 - AO Mask [Rus]
18:12
Просмотров 10 тыс.
Optimizing my Game so it Runs on a Potato
19:02
Просмотров 503 тыс.
Upgrade Your Graphics With Gradients!
7:05
Просмотров 32 тыс.
World Position | 5-Minute Materials [UE4]
8:04
Просмотров 43 тыс.
How To Make Unreal Look More Cinematic
29:07
Просмотров 693 тыс.