Getting ground color for grass

Hi!

I’ve got a bit of a project going but I’m a complete beginner so my understanding on the material system is still pretty limited, though growing each day.

I’ve got an idea I want to try out, which is to set the base color for my grass on a piece of landscape, as the color of the terrain the grass is located on. As if the grass picks up the color from the ground. I could then apply detail texture on top of that, but the base color for it should come from the ground.

http://joe.simnet.is/FH/proto/questions/PickGroundColor.jpg

The thing is, I haven’t got a clue on if it’s possible or how I’d go about doing it. I’d appreciate any help, a nudge in the right direction?

Thanks!

It’s certainly doable, CDProjekt is doing just that for The Witcher 3.

There is a presentation floating around on the net showing how they handled this.

Oh, Good luck with that, just keep working on it and improve it more and more.

Here’s the PDF for how CDProjekt is doing their terrain. Might give some guidance or help a light bulb appear above your head . It’s not a tutorial. I’m no pro myself so I’m interested in learning. They’re doing exactly what you want. Specifically detailed in the “Pigment Map” portion of the presentation. It’s certainly interesting and hopefully some experts chime in to help translate CDProjekt’s method into a BP method.

Anyway, the PDF link: http://twvideo01.ubm-us.net/o1/vault/GDC2014/Presentations/Gollent_Marcin_Landscape_Creation_and.pdf

I’ve done this both in UDK and UE4 so it’s certainly doable.
I did it by having a color map that shows the variation in color throughout the landscape, I removed all unwanted colors like rocks, sand and such and only had variations of green and brown then I let that color my foliage.
I’m not at home right now and it was a while ago so I don’t remember exactly but i found that Ülrich Thümmler did something similar here:

I can check when I get home exactly how I did it but that should get you going.

That scene with all the colored grass looks great- I’m curious how it actually runs.

There is something like that in CryEngine2/3, and there was no noticeable rendering cost for coloring grass to match underlying terrain color.

Though, my bet is, to make it really performance friendly, you would need to create custom shading model in HLSL, with access to Landscape textures info, and sample colors from here, to blend them over grass.
A task, for someone, who is good at writing shaders and understands unreal rendering ;).

I’m not sure if material editor have enough information exposed to it, to make it work.

This sample scene run in udk with 120fps (460gtx). In UE4 is the same performace.

The important thing is to clone your landscape(ground) texture and set the mipmap to 128px or 64px.

You can expand the shader, for example, snow, autumn, rain, wind or alpha mask death trees.

The Witcher 3 grass looks a bit like what I had in mind, after a quick glance, looks good as well. I think I understand what they did but need to read through it to form how I’d do it. The whole document seems like an interesting read actually, thanks for that!

Inside, yeah, Refractor 2 (Battlefield 2) had that same option, which is where I got the idea from to try this out.

Ülrich, great work on that grass, it looks fantastic! And gives me something to try out with the material, will be testing it tonight. Thanks for clarifying the numbers!

Thanks everyone for the help, I’m loving the helpfulness of this community! I’ll post an update on if I get it working!

The basic idea is to have a texture showing the base colors of the underlaying terrain. When using an external terrain generation software you might be able to export that texture from there. Otherwise you could to a top down render of your landscape in game or editor.

Once you got the texture it’s all about sampling it properly in the grass material to match the actual landscape size and position:

1 Like

Noob here :frowning: How do I make a top down render of the landscape?

Switch from perspective camera to top.

Thank you :slight_smile:

has anyone figured out a way to actually get the color from the terrain? if I take a picture from up top and then I repaint something on the terrain I’ll have to start over.

I have a color overlay map on my grass tileset material, it tints the grass to give it variety. I then use the same map and scaling (world coordinates) on the grass model material.

This way wherever I paint my grass, it always matches the landscape material.

Is the “Terrain base color” a top down texture of your terrain? I’m curious how it updates when you paint on new layers. This is exactly what I need I’m just a little slow with the concept.

Yes, the terrain base color is a manual render of your landscape. The render itself does not update automatically when you paint new layers. Switch to top down perspective and hide everything but your landscape, then update the texture as necessary.

, could you show how your materials look like? :slight_smile:

Would also love a way to do this by just getting the landscape colour.

What is the node tagged as “LandscapeLocation(X,Y)”?

It’s not a special node. Those are your Landscape X,Y location coordinates of your landscape. Just copy those number and put in constant 2 vector.