Is it possible to render the first person completely seperately. Not panini related

yeah thats fair enough, but I do need to find a solution to the barrel/iron sights. I dont want to use a render target though, too expensive.

Which makes sense. Add A parameter for “muzzle length”, use the box with that parameter, and fine tune to shader for the gun itself as to achieve the same as the plane but using a box.

Or maybe the plane function you edited the position of isn’t so trivial and you need to add the object position to that skinned position?

on COD:MW (the new one) some scopes actually have a more zoomed in view through the scope than outside the scope. this isn’t currently possible to do -properly- in UE4 (you can “zoom in” via refraction but that will result in blurred pixels because refraction is just a post process). of course you can use a scenecapture with a render target (IIRC Insurgency Sandstorm did it like that) but the performance cost is very high

as for the ‘clipping’ of the weapon front, IMO the most elegant way to do this is not supported out of the box: by rendering the scope lens into CustomDepth, and then sampling that same CustomDepth in the weapon material to mask out anything that you see through the lens. this way you don’t need to mess with masks, all you need is the lens geometry which is already different per-weapon.
but like I said sadly this doesn’t work out of the box - UE4 can render CustomDepth before base pass, but base pass cannot sample from CustomDepth. It’s been requested but Epic never implemented it, but it’s doable by modifying the engine.

PS. I know my post is not very useful, it’s mostly wishful thinking :stuck_out_tongue:

Yeah I know about the extra zoom in the scope in COD:MW (new one)

And yes, this is exactly what I was trying to do at first, I had a mask for my lens, and just needed a way to mask out that part of the gun, then composite it back together in the world. I think thats clearly what you can see in that short GIF in COD:MW I linked.

Question is, what is the most elegant way you can do it in Unreal Engine 4, because theres still definitely games that achieve removing the irons/barrel from the scoped view, insurgency is one example…

Saying it dosent work without engine modification is still valuable information, especially for people coming here in the future questioning the same thing. I had read elsewhere the same thing already, but im sure others can learn from that.

Theres got to be a way to do this that isnt jank or hacky. Completely dynamic based on weapon and scope combinations. Arkiras video is very close.

… no offence but… have you no fantasy at all?

How about vertex paint?
Just color up the gun in one channel, say red.
For all the parts you want to “disappear”.

Then just make the gun material vertex red channel disappear.

And toggle that on/off with a lerp or a switch or an if anything really…

Otherwise, make a mask in a DCC and do the same with the mask/texture.

There’s maybe a billion ways to achieve cutting out a specific part…

You’re correct, silly of me. It works fine when placed at the origin.

Because none of them are elegant, they’re all predefining what is going to disappear, and thats not something I want to do. I know I can make a mask in a DCC, or vertex paint etc, but that isnt dynamic or remotely elegant. Thats why im trying to see if people here have any creative smart ways to do it. Im not that experienced with materials/rendering stuff so.

Honestly you might wanna get used to janky solutions cause games are built on a mountain of them

Sure, we have a bunch too, just I know there are elegant solutions out there that games use, just a bit disappointing to not be able to do something like Chosker mentioned above in UE4.

It’s better that it isn’t predefined.
This way a handgun won’t just disappear unless you went and added vertex paint to it…

Adding vertex paint to an item takes what? 20seconds maybe?
And you can prevent things that shouldn’t like the mag from disappearing even though it’s past the scope on some guns.

@Arkiras
Don’t fret. The first time you add 2 rotate about axis together without looking up how to do it form someone who’s figured it you basically deserve a degree in rocket surjery…

1 Like

No you’re misundertanding. I dont want to paint which vertexes will just disappear, or paint a mask in a DCC and say this disappears, this dosent.

I want to be able to change what disappears based on what scope you have on the gun and its specific position on the gun. You cant just make a mask that works for every scope on every gun.

Which is why the solution I was originally trying to achieve, and what Chosker mentioned would be ideal, because its completely dynamic.

That actually makes it simpler, thanks for clarifying.

Maybe ask the GroundBranch team how they handle it.
They are usually very open to sharing if you can catch them.

Usually a scope can only be mounted one way on a weapon. So you can’t slide it about.
There’s exception ofc, and picatini rails. But that’s a bit beside the point.

If the scope is attached and Not part of the gun, it’s material is separate and will not affect the gun.

So you go back to having to manually vertex paint what disappears.

If the user can adjust the position of the scope in game. Then you definitely need this as part of your gameplay - and using render captures.

Just gave it a quick google (as I wasnt familiar with the project) and it looks like they use PIP. You can zoom the scope in variably and the rest of the screen stays at the same FOV.

Yes a scope will always be in position ‘X’ on a given weapon, but for example in the case of an ACOG. The ACOG will be positioned differently on every gun potentially, now if you want to just make a per weapon mask with only ACOG in mind, sure it will work, but im talking about every gun having the potential to add multiple scopes.

Games like COD/BF clearly handle this with a dynamic solution, im pretty sure what Chosker said is the way, though I dont know that for sure.

I am 100% sure I am not using a render capture, its too expensive. And I dont think vertex paint/making a manual mask will work. It just wont work for every scope.

If all else fails ill try to make a manual mask obviously, I just see it as a solution that will definitely work but isnt great really…

I dont suppose you managed to fix that bug in game did you?

Possibly. It works fine in world, but I needed to transform the camera position into local space and I’m not entirely sure how that will play out if the gun is a skeletal mesh during animation. I don’t have an animated skeletal mesh gun to test that with at the moment.

You have to make a copy of UE4’s virtual plane coordinates node, then inside that node you add function inputs for coordinates and camera position, using them everywhere worldpos/camerapos are used inside the function.

Material function paste: Untitled - Paste.in - Best tool for storing and sharing text

You have 4 channels of vertex paint to use.
And really only 3 styles of possible scopes.
Acog, red dot, and scope.
You can paint each weapon mask specifically for the scope.
And you get much more solid results than using a “dynamic” solution.

If core part of your gameplay is changing out the scope, then making it so it is well made should be a priority…

Im gonna give it a try soon and ill report back if it works or not, I have a fully animated weapon to use but not sure if it will work with the local stuff like you said.

4 channels isnt enough. We have far more than just ACOG, red dot, and scope. You cant have a modern game with heavy weapon customisation and expect to be able to mask every scope/weapon possibility with just 4 channels. I know what you’re saying will work in theory, but it cant be scaled up.

Just because weapon customisation and being able to change multiple scopes on your weapon is a thing dosent mean that you have to ‘prioritise’ it and force yourself to use PIP. Disagree heavily on this statement. The problem here is that you cant do it in UE4, not that you cant do it. AAA games like COD/BF do what im trying to do.

Im trying to find the next best solution.

It can, by swapping to a render target and using an image dictated by the scope itself. It’s just more of a pain than vertex paint to create.

I think you are making a bit of a mountain out of a molehill here.

First of COD hasn’t really done anything new or special in 10 years.
Many people still seem to prefer MW2 for its realism - how long had that been?
So - and I’m all for innovation, mind you - if stuff that old still “works” why do you think you need to re-invent it?

Second of.
How can you have more than 3 scope classes ? What are the other options? How are they not just tied to a specific weapon?

Third of.
How can you do a scope with x36 without render targets?

Fourth.
Whatever you do, you’ll still end up having to fine tune the gun to the specific scope.
There is no “cure all” when everything is dynamic.
You’ll get things like the front mag on an AK disappearing as well. And have no control over it if you just clip it.

And - this can also become a problem in multi-player.