Announcement

Collapse
No announcement yet.

Material Expression Landscape Grass - Setting Parameters at Runtime

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

    Material Expression Landscape Grass - Setting Parameters at Runtime

    Hi everyone,

    I have an issue currently that I cannot seem to solve. If someone has a suggestion I'd love to hear it. Otherwise it may be a limitation and ideally I'd suggest an addition.

    I have a landscape material which uses the Material Expression Landscape Grass Output.

    That, of course, links to a Landscape Grass Type - an object with several grass varieties inside.

    Each of those grass varieties has its own material instance.

    At runtime (through the level blueprint) I'd like to be able to set scalar parameter values on those material instances.

    For example - I change wind direction at runtime. It impacts things like clothing and flags, etc.
    Unfortunately I have no way of changing the Wind Direction parameter that I added to the Grass materials.

    The result is that flags and clothes are being blown one way by the wind direction component, whereas the grass does not respond to the wind direction component - it has its own 'simulated' wind direction in the material. It stands out and looks bad.

    I added the Wind Direction parameter value to plug into the wind direction component in the level blueprint, but I have no way of calling it.

    I can access to landscape's material instance, but since I use the material expression landscape grass output I cannot then access any of the members of that expression through the landscape's material instance.

    #2
    Hi, use a "material parameter collection". Those can be accessed from any material and you can set their values from blueprint.

    So inside the "material parameter collections" you have created you would have all the scalar and vector parameters for your wind and then you would access those inside the materials. The advantage is that you can change your "material parameter collections" directly from blueprints and therefore won't need any reference to any material.

    https://docs.unrealengine.com/en-US/...ons/index.html

    Comment


      #3
      Thanks I'll give this a try today

      Comment


        #4
        Originally posted by chrudimer View Post
        Hi, use a "material parameter collection". Those can be accessed from any material and you can set their values from blueprint.

        So inside the "material parameter collections" you have created you would have all the scalar and vector parameters for your wind and then you would access those inside the materials. The advantage is that you can change your "material parameter collections" directly from blueprints and therefore won't need any reference to any material.

        https://docs.unrealengine.com/en-US/...ons/index.html
        This worked!

        Great recommendation, and great feature.

        I'm still learning a whole lot about materials. It's such a deep topic.

        Comment


          #5
          Hello, sorry to hop on this topic but I really need help. I´ve done like 20 times the tutorial called Grass Quick Start, and every time I get to Part 5 Step 3 which reads:

          "On the Landscape Terrain under the Detail panel in the Landscape Material section, press the Arrow icon to apply the MAT_GT_Grass Material to the Landscape Terrain".

          When I do this the Landscape turns to black, and does not get the Texture as seen in the Tutorial. I have repeated all the steps time after time, either in an existing project and on a new one and it is not working. I´ve also searched on line and there seems to be many people with this problem, and everybody says it is a bug. Could you please confirm if there is a solution for this?

          Thank you


          Comment


            #6
            Hi, do step 4-6 that should solve it. If not then could you post an image of your landscape material?

            Basically you need to create the landscape layer info for your grass and rock layer, and you would do that in step 4-6.


            General info:

            The landscape is basically just a heightmap (grayscale texture) with a certain resolution. By default it is 1 pixel per 1 square meter. So if the landscape would be 1009m x 1009m then the heightmap resolution would be 1009x1009 pixel. If you sculpt then you just paint on that heightmap and you can export and import heightmaps.
            Same goes for the paint layers. If the landscape would be 1009x1009 pixel then each landscape layer info would have a resolution of 1009x1009 pixel. If you paint on the landscape then you essentially painting on that layer info texture.

            So until step 3 you have only defined that this material should have a grass layer and a rock layer. But you haven't created any landscape layer info for it to use so far. So you would need to create a landscape layer info for both the grass and the rock layer.

            Comment


              #7
              Dear Chrudimer, thank you for your quick answer. Effectively steps 4 to 6 resolve the problem. I just wanted to make sure if I was doing anything wrong, since I try to follow thoroughly all the steps in Unreal´s tutorials, so that, in a future when I work in my projects I dont face major issues. I will just skip that step that does not work as shown in the tutorial and move on. Once again thank you for your answer

              Comment

              Working...
              X