x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Get Value of a Material Input in Blueprint?

I have a Material named "WaterMaterial" and a Blueprint called "Water_Surface". The water material contains some math to set the World Position Offset which makes the material look like it's splashing up down. Meanwhile, my blueprint as a Collision Box that is parented to the box I've applied the WaterMaterial to.

I need accurate collision on the water_surface, which means I need my collision box to move with the WaterMaterial box.

I'm struggling to find a way to grab the World Position Offset value. Is there any way I could do that through blueprints?

Attached is an image of the code that's driving my World Position Offset value inside the WaterMaterial.

World Position Offset Code

Product Version: Not Selected
Tags:
screenshot_8.png (183.4 kB)
more ▼

asked May 04 '15 at 11:01 PM in Blueprint Scripting

avatar image

McJobless
1 1 2 4

avatar image McJobless May 04 '15 at 11:02 PM

To make it clear, I just need help either getting the direct World Position Offset Value, or sending all this data into some kind of variable or parameter which I can access in Blueprint.

Getting the collision box to move is easy.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi, you can get the value of a scalar or vector parameter stored in a material via a blueprint, but there is no path to get a value solved by the material for a specific position like you are asking. It is still doable though with a different approach.

What you need to do in this case is replicate the sine waves in your blueprint and synchronize the time variable. You could try using "get real time in seconds" or better use a timeline or deltatime on tick in the eventgraph to increment a global parameter in a material parameter collection. Or drive a material instance dynamic. As long as time and the values of your parameters and math are the same, you will get accurate wave height. Also account for any additional Z offsetting that may need to come from actor position.

more ▼

answered May 05 '15 at 03:01 AM

avatar image

RyanB STAFF
1.9k 55 20 116

avatar image McJobless May 05 '15 at 06:46 AM

Thank you for the reply!

I've been having great difficulty setting this up in Blueprint. I've recreated the formula in blueprint, and applied it to an object "Vision Cube" which has the same size, shape and origin point as my water cube. I have attached my Blueprints below. The problem is that it's not moving correctly; it's moving too slow compared to the object with the water material applied, and when I speed it up by multiplying the "Game Time In Seconds" module, it doesn't increase the Z (technically X due to the way the objects are laid out in the blueprint) value properly.

Can you determine what I'm doing wrong?

Components layout Blueprint Layout PIE Result

NOTE: The Plane shouldn't affect anything and is disabled in game; it's just there for reference.

screenshot_13.png (209.4 kB)
avatar image RyanB STAFF May 18 '15 at 10:56 PM

This is most likely because the period of the sine nodes is not matching up. I think the sine in the material editor has a period of 1 or so while the BP one has a period of 2pi. Try setting them to the same thing.

Also not sure why you are adding the X for the water plane. I would keep it to Z offsetting in worldspace to remove any orientation issues.

Whenever in doubt of the time values, debug them. You can easily debug time in the material editor with "Debug Scalar values" and debugging time in BP is as simple as "print text" or my favorite making a text component show time by setting text to time.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question