# Grease Pencil object brighter the further away from the camera it is

Hello,

I work on a desert background with a 2D atmosphere.
I set up geometric nodes to instantiate several stones on the ground.
Each stone is a grease pencil object. I want the color of the stone to be brighter the further away from the camera it is. Or maybe change the opacity.
Any idea how this could be done?
Thank you.

Hmmâ€¦ interesingâ€¦ im not very familiar with th grease pencil material or objectâ€¦ in a real 3D scene the distance (or maybe simpler location on oen axis) of the stones can drive some parameters in the shader.

So the stones are simply set in 2D ?? Then there is no â€śdistanceâ€ť but you somehow sized them accordingly, so then ther should eb a way to use thsi size info the alter the base color (or some other) of the solid stroke for thisâ€¦ Of course only if the geomtry nodes made Grease PEncil object can be instanced also like 3D geometryâ€¦

(Should be doing more with GPâ€¦ )

1 Like

Hi,
No the stones are instantiate also on the 3D space. I tried to work with a driver on the opacity of the stone, calculating the distance between the camera and the object and use the value to change the opacity. Itâ€™s working but when I use the geometry nodes to instantiate the stone, each object have the same opacity value, even the one that are farway from the camera.

This is sort of tricky, since GP objects donâ€™t react to light the way normal objects do, the their materials system isnâ€™t nearly as sophisticated.

My first thought might be to have several different materials for the stone colors that are different shades, and just manually assign them as they go further back. Selecting each rock and changing its material could be pretty labor-intensive, so if you decide to go this route it would probably be easier for you to just start over with one of each of your unique rocks, make a duplicate of each color, then re-populate your scene that way.

Another thought is that you might be better off doing this in the compositor! If you make a collection of all your rocks, you can make a new view layer with just that â€śrocksâ€ť collection enabled. Then you make another collection/view layer for the environment. Once youâ€™ve got your view layers set up, you can render out a Z pass on the environment, and use that Z pass to drive a node that adjusts the color of the rocks. Youâ€™ll have to use a Map Range node to dial in the Z path, but itâ€™s actually a pretty simple setup.

I donâ€™t have time to get into the step-by-step, but I whipped together an example with a few screenshots to hopefully make a little more sense.

5 Likes

Thanks you yes the compositor solution is nice. But before that I will struggle a bit more on that issue.

here is screen capture of the driver I mentioned before.
Itâ€™s strange that it put the same value of opacity to each instance.

2 Likes

Whatâ€™s being driven by the driver? Is it the stoneâ€™s color material? GPâ€™s materials system is much less sophisticated than the materials for meshes. Iâ€™d have to do some tests to be sure, but I really donâ€™t think that a GP material would even know how to look at the positing of the specific instance itâ€™s contained in.

Indeed, as mentioned by others, GP materials are a bit limitedâ€¦ youâ€™ll need to use some method to convert the GP to a mesh and then use regular materials

e.g. here using Curve To Mesh to extract some GP outlines:

â€¦ using â€śInstancerâ€ť attribute stored in GNâ€¦ that is something you canâ€™t currently do with GP materials.

Hope that helps.

2 Likes

Itâ€™s driven a GP effect that change the transparency of the object.

Thank you I will try that.

You can duplicate the ground and assign to the new stroke a texture fill material where fill is a gradient texture (the type of the fill is texture, the texture image is a gradient, do not use gradient type of fill).

You must fiddle with the new material settings (blend, scale y etc) to get it right.