Skip to content

splash-damage/collisionvis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDCollisionVis

  1. Quick Start
  2. Settings
  3. Offline Rendering

SDCollisionVis is a plugin for UnrealEngine to help see the actual state of the scene, as Chaos sees it. The collision viewmodes that come with Unreal only draw the rendering mesh, not the physics mesh. Using LineTraceSingleByObjectType, we can raytrace the physics scene directly and build a better image of what's going on.

Alt Reference
Reference (MedievalGame)


Alt FacingRatio
Facing Ratio


Alt PrimitiveID
Primitive ID


Alt TriangleID
Triangle ID


Alt MaterialID
Material ID


Alt RaytracingTime
Raytracing Time


Alt TriangleDensity
Triangle Density


Quick Start

Installing

The easiest way to add this to Unreal, is by going to either Engine/Plugins or Project/Plugins and git cloning this repo directly there.

git clone https://github.com/splash-damage/collisionvis.git SDCollisionVis

And you should end up with something like:

Engine/Plugins/SDCollisionVis

Launching

By default, the plugin is enabled for Editor, Game, Client and Server for everything but Shipping.

If you're in editor, you can very quickly enable the realtime overlay by toggling on this visualisation mode.

Alt FacingRatio

In a cooked build, you can instead toggle it on with:

show SDCollisionVis

Settings

Everything in SDCollisionVis is configured via cvars.

VisMode

You can change the current visualisation mode via r.SDCollisionVis.Settings.VisType:

  1. Default
    Facing Ratio Based Thing
  2. Primitive Id
    Hash of HitResult.ElementIndex
  3. Triangle Id
    Hash of HitResult.ElementIndex + HitResult.FaceIndex
  4. Material Id
    Hash of HitResult.PhysMaterial->GetUniqueID()
  5. Raytrace Time
    Takes the time difference before and after the raycast.
    Can be configured further with:
    • r.SDCollisionVis.Settings.RaytraceTime.IncludeMisses
    • r.SDCollisionVis.Settings.RaytraceTime.MinTime
    • r.SDCollisionVis.Settings.RaytraceTime.MaxTime
  6. Triangle Density
    Attempts to extract a triangle from the underlying physics mesh and computes its' area.
    Can be configured further with:
    • r.SDCollisionVis.Settings.TriangleDensity.MinArea
    • r.SDCollisionVis.Settings.TriangleDensity.MaxArea

Min Ray Length

If you're playing a first person game, it's very likely the character's capsule will occlude the entire screen.

For cases like that, there is:

r.SDCollisionVis.Settings.MinDistance
Defaults to 100.

TileSize and Scale

In order to keep things from turning your experience into a full on slide show, the realtime renderer cuts up the screen into tiles and will only evaluate one pixel of that tile per frame.

You can configure this with:

r.SDCollisionVis.Settings.TileSize
Defaults to 8, and clamped between 2 (2x2) and 128 (128x128).


Additionally, the framebuffer can be scaled, so less pixels overall need to be evaluated.

r.SDCollisionVis.Settings.Scale
Defaults to 0.5


The defaults were chosen based upon running things at 3840x2160 and prioritising image clarity.

If you want a very rapid update, like if you want to walk around, something like this might be a good option:

r.SDCollisionVis.Settings.Scale 0.25
r.SDCollisionVis.Settings.TileSize 2

FCollisionObjectQueryParams

The object query params are configured under r.SDCollisionVis.CollisionObjectQuery.*:

  • AllObjects
  • AllStaticObjects
  • AllDynamicObjects
  • WorldStatic
  • WorldDynamic
  • Pawn
  • Visibility
  • Camera
  • PhysicsBody
  • Vehicle
  • Destructible

FCollisionQueryParams

The query params are configured under r.SDCollisionVis.CollisionQuery.*:

  • TraceTag
  • TraceComplex
  • IgnoreBlocks
  • IgnoreTouches
  • MobilityType

Presets

If you mess up, you can reset FCollisionObjectQueryParams and FCollisionQueryParams with:

r.SDCollisionVis.Preset.Default()

Offline Rendering

If you want a higher quality offline render, there is:

r.SDCollisionVis.OfflineRender()

Args:
    -resolution         : Resolution to use. (Default: 512)
    -max-rays-per-frame : Number of rays to dispatch per frame. (Default: 1024)
    -cubemap            : Render as a CubeMap. (Default: false)
    -player-controller  : Player controller for fetching transform info. (Default: 0)

e.g:

r.SDCollisionVis.OfflineRender() -cubemap -resolution=2048

The output will go into: Saved/SDCollisionVis, with a .png for normal and a .dds for cubemaps. The FOV is always fixed to 90deg for none cubemap.

Alt Offline
Offline


Alt OfflineCubemap
Offline Cubemap


Server Debugging

If in PIE, in the same process, you can redirect the realtime renderer to use the servers world.

r.SDCollisionVis.Settings.UseServerWorld 1

Otherwise you can use serverexec.

serverexec r.SDCollsionVis.Settings.VisType 2
serverexec r.SDCollisionVis.OfflineRender() -cubemap -resolution=2048

And it will have to be manually copied from the server.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •