# World Position Offset after Shadow projection and depth check

**URL:** <https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737>\
**Category:** Rendering\
**Tags:** Shadows, world-position-offse, perspective, unreal-engine, question\
**Created:** [May 16, 2017, 9:00am UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737 "2017-05-16T09:00:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![foberokubo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@foberokubo](https://forums.unrealengine.com/u/foberokubo)\
**Post date:** [May 16, 2017, 9:00am UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/1 "2017-05-16T09:00:46Z")

</div>

Have a _World Position Offset_ that changes camera perspective to _Fisheye_, deforming scene.  
Dynamic _shadow pass_ is calculated after _World Position Offset_ resulting errors. Static baked shadows look OK.

Question is, how to change _shadow pass_ order so that _dynamic shadows_ are calculated before WPO?

Or how to set shadow and reflection shader to use WorldPosition (Excluding Material Offsets)?

---

<div class="post-metadata">

**Author:** ![Tuxmask75](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tuxmask75](https://forums.unrealengine.com/u/Tuxmask75)\
**Post date:** [May 16, 2017, 9:19pm UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/2 "2017-05-16T21:19:31Z")

</div>

I’d like to know this too ! since my game uses fisheye as well lol ( point lights don’t seem to work with it also, so I guess how do we update lighting before the WPO?) Perhaps you figured that out already? if so please let me know!

Sorry to jack your thread, but to show people what fisheye looks like.,… and for my issue…  
For point lights Here’s the partial solution we came up with in UDK, by moving the lights during gameplay using Fisheye math, it kind of faked what we were going for, there are some issues though, which are not shown here. The issues that it had was when moving inward and outwards in the level. ( the lights would kinda slide around. The other issue was if you had a large light radius than we were back to seeing the light slide around walls which was odd to look at.

---

<div class="post-metadata">

**Author:** ![foberokubo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@foberokubo](https://forums.unrealengine.com/u/foberokubo)\
**Post date:** [May 17, 2017, 1:20pm UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/3 "2017-05-17T13:20:00Z")

</div>

Thought Im only one using fisheye vertex shader. Think this shadow pass before WPO is UE4 feature and guess changing it requires some notepad work in _BasePassForForwardShadingPixelShader.usf_ located in Engine\Shaders but that’s hard to figure out when you’re not a programmer.

Tell me more about your game, is that this Sonic? Did you made fisheye shader by your own or got it from youtube/forum?

---

<div class="post-metadata">

**Author:** ![Tuxmask75](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tuxmask75](https://forums.unrealengine.com/u/Tuxmask75)\
**Post date:** [May 17, 2017, 5:22pm UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/4 "2017-05-17T17:22:39Z")

</div>

I been working on this game since 2006 based on the canceled sonic X-treme game from Sega Saturn from 1996. the original game had fisheye and yes it ran on Sega Saturn and windows 95 PC. It took us a few years to figure out how to do fisheye shader the way they did it (this was back in 2008 or so). That was when the game was in Game maker and used Ult 3D plugin, We later moved to UDK, which was a godsend! everything was perfect ad we got most of the gameplay complete, But the only drawback was that we could not rotate the player collision cylinder which caused some gameplay issues because our gameplay worked with rotating worlds. ( we had some work abounds in place, but they were not perfect, Now we are in Unreal 4. It took 1 year to catch up with re-setting up all the assets that we had set up in UDK. We were in UDK from from 2011 - 2015.  
Quite a long time for a hobby project ! A lot of the time went into rebuilding as many of the original test levels from the original game. there are over 90 of them! And I plan to do some custom levels as well, because the original beta levels really didn’t play well with their poor level layouts.

https://www.youtube.com/embed/pawNmPAchg4?feature=oembed&wmode=opaque&list=PLjVabxmQnqww7mMPnD0FSq5JwX1Rtswsr

and here’s the forum thread,

> **[Project AXSX (2013 and Beyond)](https://forums.sonicretro.org/index.php/threads/31255)**
>
> \[img\]
> 
> AXSX originally started out recreating assets from scratch and by hand to try and replicate what was seen in blurry magazine scans and videos....

How about your project ?

---

<div class="post-metadata">

**Author:** ![foberokubo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@foberokubo](https://forums.unrealengine.com/u/foberokubo)\
**Post date:** [May 18, 2017, 9:09am UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/5 "2017-05-18T09:09:01Z")

</div>

I see what you did with that space bending. Made similar shader for curved earth effect where you would input planet radius, and the origin of bending would be at camera location minus planet radius.  
That’s a long time indeed for a hobby project.  
I was interested into creating fisheye shader to fix linear perspective problems, like movement nausea, deformations on the screen edges. Did you know that in 1420 AD, when linear perspective was introduced, people call it “Italian Stylization” as they did not seen it realistic.  
For a personal scientific research, created shader that can render 3D environment in Orthographic or Stereographic perspective, giving more natural motion.

---

<div class="post-metadata">

**Author:** ![Tuxmask75](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tuxmask75](https://forums.unrealengine.com/u/Tuxmask75)\
**Post date:** [May 18, 2017, 1:12pm UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/6 "2017-05-18T13:12:00Z")

</div>

That is a very interesting story! and I wish you the best of luck with your project ! I’ll be keeping my eye on this to see if we get our answers related to doing the shadow pass before the WPO pass because I think its very important!

---

<div class="post-metadata">

**Author:** ![Tuxmask75](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tuxmask75](https://forums.unrealengine.com/u/Tuxmask75)\
**Post date:** [May 29, 2017, 3:11pm UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/7 "2017-05-29T15:11:24Z")

</div>

Idea… It don’t look like we can use world position offset inside a post process effect because the input is greyed out.  
However can a Post process contain a world position offset for all mesh on screen some other way maybe?

---

<div class="post-metadata">

**Author:** ![foberokubo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@foberokubo](https://forums.unrealengine.com/u/foberokubo)\
**Post date:** [June 1, 2017, 10:42pm UTC](https://forums.unrealengine.com/t/world-position-offset-after-shadow-projection-and-depth-check/393737/8 "2017-06-01T22:42:07Z")

</div>

Maybe it would be possible after editing “PostProcessMaterialShaders.usf” (located in “Epic Games\UE\_4.9\Engine\Shaders”). But that’s just guessing. I would likely pay someone for figuring that out.
