# Calculate Object Screen Size in Material

**URL:** <https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [December 28, 2020, 10:57am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482 "2020-12-28T10:57:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![blindminds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/blindminds/32/1213160_2.png) [@blindminds](https://forums.unrealengine.com/u/blindminds)\
**Post date:** [December 28, 2020, 10:57am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/1 "2020-12-28T10:57:40Z")

</div>

Using blueprint only, I am trying to calculate an Objects Screen Size (Percentage: 0-1) in the material editor to drive a scalar parameter value for an alpha for a linear interpolation node. Basically, I want to adjust the brightness based on the objects screen size. I am using a Dynamic Material Instance, so I would be able to some calculations in the objects blueprint to help drive the value if everything cannot be calculated in the material editor alone. I would also like a value of 100% (or 1) to be black (0) and 0% to be White (1).

I found someones equation in the forums,

approx\_screen\_percentage = bounding\_sphere\_radius / (distance\_to\_object \* sin(fov\_of\_camera))

 ![325780-screenshot.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/c/5cca707f47273a21649e51e905be50911addc323.png)

This seems to work to an extent, however when I try to reverse the LERP, it breaks and does not work and ends up always being white.

---

<div class="post-metadata">

**Author:** ![Kehel18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kehel18](https://forums.unrealengine.com/u/Kehel18)\
**Post date:** [December 28, 2020, 3:55pm UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/2 "2020-12-28T15:55:26Z")

</div>

Hi there! Can you share all nodes in your material?

---

<div class="post-metadata">

**Author:** ![blindminds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/blindminds/32/1213160_2.png) [@blindminds](https://forums.unrealengine.com/u/blindminds)\
**Post date:** [December 30, 2020, 3:47am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/3 "2020-12-30T03:47:35Z")

</div>

It is way too complex of a material to include all the nodes. This is the important part for what I am trying to accomplish, the result of these nodes is being fed into the emissive input. If I add a LERP with a=0 and b=1 and the result of these nodes as the alpha or try to use a 1- node to invert it, it just end up white and not fading.

---

<div class="post-metadata">

**Author:** ![blindminds](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/blindminds/32/1213160_2.png) [@blindminds](https://forums.unrealengine.com/u/blindminds)\
**Post date:** [December 30, 2020, 3:50am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/4 "2020-12-30T03:50:05Z")

</div>

The actual value for Camera FOV = 37.497356

---

<div class="post-metadata">

**Author:** ![ZlotyGames](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZlotyGames](https://forums.unrealengine.com/u/ZlotyGames)\
**Post date:** [February 23, 2021, 12:38am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/5 "2021-02-23T00:38:52Z")

</div>

**I figured it out after hours of testing different combinations**  
This is how to get the screen size of the mesh in screen:

 ![330548-screensize.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/e/4bedd8535d7492b90d2b8a3e193660c73519a9bf.png)

.

And this is the result:

![330549-screensize2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/d/e/2de22973a0a9d4df7eb1d5b40df456151dc16f78.png)

For those who want to try it, **it works** , but there is a margin of error of 0.001 only when changing the screen percentage of the viewport. Maybe someone will be interested in posting a fix to that, but for me it wasn’t worth the time. Hope it works for you

---

<div class="post-metadata">

**Author:** ![Kein](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kein](https://forums.unrealengine.com/u/Kein)\
**Post date:** [February 14, 2022, 10:18am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/6 "2022-02-14T10:18:04Z")

</div>

They purged all user screenshots when they deleted Unreal Answer.  
Can you reupload?

---

<div class="post-metadata">

**Author:** ![YannEsparbie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YannEsparbie](https://forums.unrealengine.com/u/YannEsparbie)\
**Post date:** [August 9, 2024, 1:02pm UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/7 "2024-08-09T13:02:17Z")

</div>

Hello, I think this calculation would be more correct, this should work with any aspect ratio or field of view

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/5/f4533cf62950153ead95e2dcc6937aa46d901e88.png)

---

<div class="post-metadata">

**Author:** ![Anonymous\_3b9ffdf0499b845574069142ad310dfb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_3b9ffdf0499b845574069142ad310dfb](https://forums.unrealengine.com/u/Anonymous_3b9ffdf0499b845574069142ad310dfb)\
**Post date:** [September 5, 2025, 1:14am UTC](https://forums.unrealengine.com/t/calculate-object-screen-size-in-material/476482/8 "2025-09-05T01:14:56Z")

</div>

You Can Refer The Editor Code ,And Translate to Shader
