Jump to content
FishMan

Some fun with acog scope.

Recommended Posts

15 hours ago, FishMan said:

I ****ing did it!!!

I fixed the scope! Shit it took me 3 weeks to understand this shit! Omg!

 

 

Here is the code...

 

pic.jpg

 

You can add effects to this and sphere mask as an opacity so the reticle would not fly through scope.

 

I still not sure what is the nature of this constant vector (0.153; 4,32; 0) maybe it is the shift from weapon blueprint or difference between the attachment and optics position, I will investigate this later...

 

UPD: Ah yeah! It is the local position of the scope center.

Here is the screenshot from 3ds max:

pic.jpg

 

Dont forger that mesh reticle is also shifted (by developers) you should move it back at the center of the scope to force it work right.

 

You know what? You can even force the scope to remain the same scale no matter the distance I will show you tomorrow how to do this.

 

 

 

 

 

Fantastic work! Have the DEVs gotten in contact with you already?

Share this post


Link to post
Share on other sites
FishMan   

By the way I guess the tank turret stabilistation might work the simlar way it the future.

 

Here is the code to force it always remain the same size:

pic.jpg

 

If you ignorant enough (like me) you will notice that its not about size but about positon. This code just basically shifting the retilce in camera depth so it allways remain at the same distance (second value of 3vector parameter. In our case - 17 cm), no matter where are you or where is your weapon.

 

And this what causes the problem when you trynig to mask it out with sphere mask.

 

Cause sphere masks has depth as well and allways moving with the scope and most of the time it's not even touch the reticle mesh.

Here is what I mean:

 

 

You can shift it with the reticle together, but it now will remain the same size, while the lens changing its sizes while moving in depth (cause this is how prespective works). I guess you can modify the radius of the sphere depending on the distance from camera, but in my opinion it will end in some really big and paintfull FOV-dependend calculations using Pythagorean theorem or something like that.

 

I also was trying to solve this by generating 2D cirle mask using lenght of 2d vector, but first of all - It's not stable and secondly it's always remain the same size on the screen, while lens should become smaller when it moving in camera z axis (depth) as I said before. We basically needs a cylinder mask, that will change its radius in 3d space depending on its position but it should have unlimited height (like 2d cirle), I wasn't able to generate such mask...

 

Anyway I wasn't able to find any beautifull solution for this. And by beautifull I mean the solution that works just using shader math.

 

BUT! (here is that dramatic point where you should forget everything that I was saying before)

 

There is another way to solve this. We can use Custom Stencils (or custom depth - but I personally  prefer stencils because they have bit masks). 

 

 

As you can see it very stable.

The problem is that you have to modify the weapon blueprits to make everything right, here is the short tutorial about how to do it:

 

 

So now you can use this code in the shader to get that mask:

 

pic.jpg

 

The result you can see on the second video that I've posted.

 

So here is what we got so far, just to be clear:

 

pic.jpg

 

This code shifting the reticle and masking it so it never leave the scope area. Here is the result:

 

 

It doesn't matter what is your fov. It can be compatible with PIP scope and any kind of effects. It will be visible on top of the smoke. 

 

Another good news is that you can use this not only for masking the retilce, but for some cool effects as well.

I will tell you about them in my next post...

I want to take a break to have some tea with sugar, eat some semechki and pelmens with mayonez to recharge my slav powers...

 

TO BE CONTINUED

 


 

Edited by FishMan

Share this post


Link to post
Share on other sites
FishMan   

Ok. So I said you can use custom stencils for additional effects. For exmaple you can blur everything but lens.

Here is how it looks assembled:

 

Screenshot:

pic.jpg

 

I also added parallax effect from first pages of this thread.

How I did it...

I just closed the hole in the scope and made it so the cap is used its own material.

I could make everything in one material but I've decided that it will become unnesessary complicated in this case.

Here is the shader which I used for parallax effect:

pic.jpg

 

And here is the post-process shader which I use to blur everything but lens:

pic.jpg

 

The devs allready made Post-process slot in their weapon blueprint so I just plugged it there.

 

As you can see here I'am using custom material function called "average blur".

It just takes pixels shifting them and average them. Unreal has native function for this, but I've made my own, so it better suit for my needs.

 

Why average blur? Cause it pretty cheap and aeasy to do (understand), but my goal is to make something similar to Heroes and Generals. So when I figure out how to do good blur effect which will not kill perfomance I will change this, other words may be I'll figure our later how to do another blur, Gussian for example, but for now its AverageBlur.

 

Here is how AverageBlur function looks like:

pic.jpg

 

I will add later chromatic abberations and lens distortion effect to it. I also have some experiments with it, but nothing super exciting for now:

 

 

 

Also I would like to exepriment with lens flare effects from sun and this luna artifacts when you look not straight through scope (for what it all was started).

 

And finally the last thing.

You can set up zeroing with that veeeeery precise...
You can even bind a key in blueprints to change zeroing using for example mouse scroll. Like in Heroes and Generals.

Example:

And here all the nesessary files:

https://dl.dropboxusercontent.com/u/9760936/collimator/PSO-RETICLEFIX.rar

 

Pay attention that when you load this to your engine it gonna be missing average blur function in PP_Blur_Stenciled material. so you should manually open it and fix it like on this picture, then hit apply.

pic.jpg

 

Also to make it work you should enable custom stencils in project rendering settings.

 

Thats all good luck.

Edited by FishMan

Share this post


Link to post
Share on other sites
LugNut   

Great work!

 

Not knowing any better, would the method to change the scope elevation also work for adjustable rear iron sights?

Share this post


Link to post
Share on other sites
FishMan   
17 minutes ago, LugNut said:

Not knowing any better, would the method to change the scope elevation also work for adjustable rear iron sights?

Nah.  Iron sights is about rotation stuff, not just shifting in X and Y.

 

By the way. About the rerticle. Did I mentioned that you can make it smaller just using parameters? Well you can.

Edited by FishMan

Share this post


Link to post
Share on other sites
Chap   

Very cool man. In such a short time to do so many cool things. In your system may be implemented backlight on the grid?

Edited by Chap

Share this post


Link to post
Share on other sites
FishMan   
4 hours ago, Chap said:

In your system may be implemented backlight on the grid?

Of course it just color of the reticle, right now it's emit black color, basically you can just add vector3 parameter and switch it to any color through blueprint or c++ code.

Share this post


Link to post
Share on other sites
FishMan   

By the way.

I've forgot to say something.

Rangefinder also works if you adjust the reticle scale to right dimentions. But the rande doesn't matter cause you can easily shoot targets on 400 meters with a reticle that was set to 100. Are you sure that there is nothing wrong with the ballisitc in Squad? The bullet drop seems too small.

Anyway the devs did reticle right, so I even haven't changed anything, it just work as it is... Well plus/minus some small error.

Doesn't matter what is the FOV.

 

Here is the video:

 

Share this post


Link to post
Share on other sites
On 9.2.2017 at 11:18 AM, FishMan said:

Are you sure that there is nothing wrong with the ballisitc in Squad? The bullet drop seems too small.

Squad doesn't have bullet drag atm. With bullet drag SVD scope is pretty accurate to 800m which I have extensively tested. Without zeroing though

Share this post


Link to post
Share on other sites

This has to be one of my favorite threads to keep track of! Your work is phenomenal and hopefully the Devs can pull some creative ideas from it all. +1

Share this post


Link to post
Share on other sites
FishMan   

 

Took some time to play with the engine again...

Here some small results from experiments with refraction and chromatic aberrations.

It's basically a post-process shader, at this time I wasn't doing much with my self and just stole everything from this thread:

https://forums.unrealengine.com/showthread.php?119740-Simple-refraction-with-chromatic-aberration

Check it out, It really awesome.

 

But it seems that its a little bit perfomance heavy (not very much), so I might try to do it another way...

May be a default refraction will cost less than this. I have to try it. Soon I will have plenty of time, cause here in Russia we've got some holidays (it's called "Defender of the Fatherland Day") so I might spend more time on this to make something descent.

Edited by FishMan

Share this post


Link to post
Share on other sites

Great job FishMan. That's definitely what's missing currently. A worthy addition. When you say it's performance heavy I guess you mean gpu. Squad being cpu bound on full servers I guess most can take the hit on gpu usage.

Share this post


Link to post
Share on other sites
FishMan   

When I said perfomance heavy - I mean it's red on "shader complexity".

It's not a big deal actually. But I'am looking a solution that will cost as low as possible. Don't forget - refraction and abberation is not all that will be at the end, there will be some additional effects, so I need some space for them as well.

 

This video is a good representation of how I want this shader to look at the end.

 

 

Share this post


Link to post
Share on other sites
8 minutes ago, ZiGreen said:

@Assifuah

 

Some dangerous and possibly destructive stuff here. Fishman is encouraging sniper lone wolf gameplay here. I'd suggest to ban him.

 

Lol, but in reality it would make it more difficult from its current state 

Share this post


Link to post
Share on other sites
ZiGreen   
3 minutes ago, grimshadow said:

Lol, but in reality it would make it more difficult from its current state 

 

That is why I always suggest optics/irons balance through proper implementation of optics. Not only because I am dumb realismfag.

Share this post


Link to post
Share on other sites

×