Commandos Cone of Sight FX in Unity | GPUMAN

  Рет қаралды 7,085

GPUMAN

GPUMAN

Күн бұрын

Пікірлер: 26
@vannda2743
@vannda2743 4 жыл бұрын
i wish you can do it in shader graph too.
@MrlKost
@MrlKost 4 жыл бұрын
Great tutorial works perfectly and very educational!
@matthewblank7691
@matthewblank7691 2 жыл бұрын
A nice looking solution but due to the need of use of multiple cameras very performance heavy. I only did some profiling in Editor but it's hitting GPU pretty heavy. With 9 instances of this view cone - and even setting up the Render Texture to be 1/4th the size with depth buffer of only 4 it increases the render thread time from ~4ms to ~11ms.
@matthewblank7691
@matthewblank7691 2 жыл бұрын
And I have 3080 so on a lower tier hardware will be very bad.
@dexter_hacks
@dexter_hacks Жыл бұрын
@@matthewblank7691 Maybe use this only for enemies that are perched above and have to look down at objects of different heights and use the other normal raycasting for on-ground enemies?
@matthewblank7691
@matthewblank7691 Жыл бұрын
@@dexter_hacks It was not the issue of the CPU and raycasting but the view cone rendering on the GPU caused by the amount of cameras that were rendering to the RenderTexture. I was able to speed it up a little by creating custom simple objects that were used for obstacles instead of the real ones and setting the cameras to only see thoseX lowering down the resolution of the RenderTexture way down and setting up the view cone to only render about 20 times per second. This improved things enough.
@dexter_hacks
@dexter_hacks Жыл бұрын
@@matthewblank7691 Ok. In Desperados, it probably activates only those cameras in an area where the player is currently, and the rest is inactive (unless you manually activate it). But I wonder how they keep track of multiple players running in different directions and still detect the players. It starts with 30-40 enemies, but on an alert, you have additional enemies running out.
@matthewblank7691
@matthewblank7691 Жыл бұрын
@@dexter_hacks Yeah, I'm doing this as well. It deactivates the View Cone if the mesh is not inside the Main Camera frustrum. The player detection is handled separately. I also had multiple characters on the map. Each NPC first calculates the distance squared, then does view angle and height calculations and only if both determine that the character can be seen I'm throwing raycast. This way i can have a lot of NPCs and only do full calculations for a few.
@advaita6643
@advaita6643 Жыл бұрын
The camera in the ConeOfSight object renders this as per culling mask for the 'Obstacle' layer. How would one go about creating a block for the cone, along with this? So if there is an object (like a tall solid wall etc.) with a particular layer like 'OpaqueObstacle' or any layer that isn't an 'Obstacle' it should not be creating a shadow.
@thomasharvey2980
@thomasharvey2980 3 жыл бұрын
I was curious becomes I can't figure it out, is there a way to use this trick to create a fog of war like system? Something like what Zomboid does but in a full 3D setting like you have in this video
@EdenDev
@EdenDev 6 ай бұрын
How does this shader behave when the field of view height gets too close to the surface height? There, the depth comparison even with bias leads to oscillation in shape of teeth or sinus. Did you notice that?
@elmichiapologeta
@elmichiapologeta 4 ай бұрын
How could i replicate this in unreal engine?
@telemaco9822
@telemaco9822 4 жыл бұрын
How can i implement It correctly in the Universal Render Pipeline? Apparently when i download the Universal RP package the cone no longer modifies itself if there are obstacles in front of the soldier.
@ssoltani498
@ssoltani498 3 жыл бұрын
Is there any tutorial somewhere to make it using the Shader Graph?
@WelshGuitarDude
@WelshGuitarDude Жыл бұрын
How does Unity know which camera to use when it gets the depth data? You have multiple cameras all writing to the same _CameraDepthTexture - how does it have the right camera? Also you have a _ViewDepthTexture as well... confusing me where these two come from. Why do you need two?
@GPUMan
@GPUMan Жыл бұрын
_CameraDepthTexture is created by Unity and comes indeed from the main game camera (the player view). This is only used to check the object's intersection with the scene and to draw the cone as a decal. This is a global texture shared by all shaders. _ViewDepthTexture is used to render obstacle occlusion. It's created, rendered to, and passed into the material from ConeOfSightRenderer.Start() with ViewCamera.SetTargetBuffers and mMaterial.SetTexture (explained from 5:20). This means each soldier camera will write to its unique custom depth texture (and not the global _CameraDepthTexture) Each character has its own POV of the obstacles in front of them so it's necessary then that each camera (or soldier) renders to and samples from its own unique depth texture. Check the code here for a bit more context github.com/joscanper/unity_coneofsightfx/blob/master/Assets/Scripts/ConeOfSightRenderer.cs I hope that helps
@WelshGuitarDude
@WelshGuitarDude Жыл бұрын
@@GPUMan your script you linked doesn't use the set target buffer method that unity provides? Is there a reason for that?
@GPUMan
@GPUMan Жыл бұрын
@@WelshGuitarDude I don't recall exactly but probably just for simplification's sake. SetTargetBuffer allows you to specify multiple targets which wasn't necessary in this case
@WelshGuitarDude
@WelshGuitarDude Жыл бұрын
@@GPUMan ah i see thats why you used target texture? Also do you know much about how Desperados changes the vision cone texture for crouching behind objects that are a certain height versus objects that fully clip the vision cone ?
@GPUMan
@GPUMan Жыл бұрын
@@WelshGuitarDude hmm, that might not be possible with this method I'm afraid. Considering Desperados core tech is like 20 years old I wouldn't be surprised if they use regular ray tracing against simplified shapes at 3 different heights. Something a bit like this github.com/configithub/ray-tracer
@patek2385
@patek2385 2 жыл бұрын
Can You actually show or tell how did you add those shaders to the object?
@GPUMan
@GPUMan 2 жыл бұрын
The shader is applied to the material that is added to the cube. If you struggle with this, I would recommend following a tutorial about the basics of shaders first, since that's not the goal of this tutorial. Shaders 101 by "Makin' Stuff Look Good" is a great one.
@rodrigoguerra8372
@rodrigoguerra8372 4 жыл бұрын
Interesting effect, but you need a Phd to understand how to make this.
Unity line of sight checking using sensors [AI #08]
19:24
TheKiwiCoder
Рет қаралды 56 М.
Field of View Effect in Unity (Line of Sight, View Cone)
23:35
Code Monkey
Рет қаралды 157 М.
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 64 МЛН
路飞做的坏事被拆穿了 #路飞#海贼王
00:41
路飞与唐舞桐
Рет қаралды 25 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 53 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
Unlocking The Power Of Unity's Scriptable Render Pipeline
21:05
Game Dev Guide
Рет қаралды 225 М.
Recreating Darkwood's Vision Effect in Unity
4:01
aarthificial
Рет қаралды 51 М.
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 447 М.
«Если 50 детей не рожу - ничего не добился»
1:26:17
Саша Сулим
Рет қаралды 1,9 МЛН
Enemy Line of Sight, Stealth Game in Unity (Field of View)
11:57
Code Monkey
Рет қаралды 55 М.
How Games Have Worked for 30 Years to Do Less Work
23:40
SimonDev
Рет қаралды 1,4 МЛН
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 545 М.
Evolution Of Commandos Games [1998-2019]
5:19
The Silent Gaming Fish
Рет қаралды 1,4 МЛН
THIRD PERSON MOVEMENT in Unity
21:05
Brackeys
Рет қаралды 1,5 МЛН
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 64 МЛН