Skip to content
Snippets Groups Projects
Commit 2715863d authored by David Gilbert's avatar David Gilbert :bug:
Browse files

Merge branch 'feature/refactor' into 'develop'

Feature/refactor

See merge request dgilbert/unrealopticalbench!2
parents 213c1d6f 4954b843
No related branches found
No related tags found
No related merge requests found
Showing
with 1410 additions and 1068 deletions
No preview for this file type
No preview for this file type
...@@ -14,7 +14,7 @@ public class OptiX : ModuleRules ...@@ -14,7 +14,7 @@ public class OptiX : ModuleRules
string EnginePath = Path.GetFullPath(Target.RelativeEnginePath); string EnginePath = Path.GetFullPath(Target.RelativeEnginePath);
string ModulePath = ModuleDirectory; string ModulePath = ModuleDirectory;
Definitions.Add("MALLOC_LEAKDETECTION=0"); PublicDefinitions.Add("MALLOC_LEAKDETECTION=0");
PublicIncludePaths.AddRange( PublicIncludePaths.AddRange(
...@@ -47,6 +47,8 @@ public class OptiX : ModuleRules ...@@ -47,6 +47,8 @@ public class OptiX : ModuleRules
"UMG", "UMG",
"Slate", "Slate",
"SlateCore", "SlateCore",
"D3D11RHI"
} }
); );
PrivateDependencyModuleNames.AddRange( PrivateDependencyModuleNames.AddRange(
...@@ -62,7 +64,8 @@ public class OptiX : ModuleRules ...@@ -62,7 +64,8 @@ public class OptiX : ModuleRules
"Json", "Json",
"JsonUtilities", "JsonUtilities",
"RenderCore", "RenderCore",
"RHI" "RHI",
"D3D11RHI"
} }
); );
......
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "LineInstancedStaticMeshComponent.h" #include "LineInstancedStaticMeshComponent.h"
#include "Components/InstancedStaticMeshComponent.h" #include "Components/InstancedStaticMeshComponent.h"
...@@ -14,6 +13,9 @@ ...@@ -14,6 +13,9 @@
#include "OptiXModule.h" #include "OptiXModule.h"
#include "OptiXContextManager.h" #include "OptiXContextManager.h"
#include "StatsDefines.h"
ULineInstancedStaticMeshComponent::ULineInstancedStaticMeshComponent(const FObjectInitializer& ObjectInitializer) ULineInstancedStaticMeshComponent::ULineInstancedStaticMeshComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
...@@ -45,6 +47,7 @@ void ULineInstancedStaticMeshComponent::BeginPlay() ...@@ -45,6 +47,7 @@ void ULineInstancedStaticMeshComponent::BeginPlay()
FPrimitiveSceneProxy* ULineInstancedStaticMeshComponent::CreateSceneProxy() FPrimitiveSceneProxy* ULineInstancedStaticMeshComponent::CreateSceneProxy()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ULineInstancedStaticMeshComponent::CreateSceneProxy"))
FPrimitiveSceneProxy* Proxy = Super::CreateSceneProxy(); FPrimitiveSceneProxy* Proxy = Super::CreateSceneProxy();
...@@ -82,6 +85,7 @@ FPrimitiveSceneProxy* ULineInstancedStaticMeshComponent::CreateSceneProxy() ...@@ -82,6 +85,7 @@ FPrimitiveSceneProxy* ULineInstancedStaticMeshComponent::CreateSceneProxy()
// todo currently copies the array, save a reference/ptr instead // todo currently copies the array, save a reference/ptr instead
void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices, int32 NumberOfSegmentsPerLine, float LineW) void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices, int32 NumberOfSegmentsPerLine, float LineW)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ULineInstancedStaticMeshComponent::InitLineSegments"))
ClearInstances(); ClearInstances();
...@@ -138,7 +142,7 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices, ...@@ -138,7 +142,7 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices,
IndexMap = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT); IndexMap = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT);
IndexMap->UpdateResource(); IndexMap->UpdateResource();
UE_LOG(LogTemp, Display, TEXT("IndexMap | LineNumber (%i | %i "), IndexMap->GetSizeX(), LineNumber); UE_LOG(LogTemp, Display, TEXT("IndexMap | LineNumber (%i | %i )"), IndexMap->GetSizeX(), LineNumber);
IndexMap->UpdateTextureRegions(0, 1, TextureRegion.Get(), sizeof(float), sizeof(float), (uint8*)LaserIndicesFloat.GetData()); IndexMap->UpdateTextureRegions(0, 1, TextureRegion.Get(), sizeof(float), sizeof(float), (uint8*)LaserIndicesFloat.GetData());
DynamicLaserMaterial->SetTextureParameterValue("IndexMap", IndexMap); DynamicLaserMaterial->SetTextureParameterValue("IndexMap", IndexMap);
...@@ -149,6 +153,8 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices, ...@@ -149,6 +153,8 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices,
void ULineInstancedStaticMeshComponent::UpdateLines() void ULineInstancedStaticMeshComponent::UpdateLines()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ULineInstancedStaticMeshComponent::UpdateLines"))
LineNumber = LaserIndices.Num(); LineNumber = LaserIndices.Num();
for (int32 Line = 0; Line < LineNumber; Line++) for (int32 Line = 0; Line < LineNumber; Line++)
...@@ -175,6 +181,8 @@ void ULineInstancedStaticMeshComponent::UpdateLines() ...@@ -175,6 +181,8 @@ void ULineInstancedStaticMeshComponent::UpdateLines()
void ULineInstancedStaticMeshComponent::UpdateLUT(TArray<FColor> ColorMap) void ULineInstancedStaticMeshComponent::UpdateLUT(TArray<FColor> ColorMap)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ULineInstancedStaticMeshComponent::UpdateLUT"))
if (DynamicLaserMaterial != NULL) if (DynamicLaserMaterial != NULL)
{ {
...@@ -197,6 +205,8 @@ void ULineInstancedStaticMeshComponent::UpdateLUT(TArray<FColor> ColorMap) ...@@ -197,6 +205,8 @@ void ULineInstancedStaticMeshComponent::UpdateLUT(TArray<FColor> ColorMap)
void ULineInstancedStaticMeshComponent::SetLaserMaterial(UMaterialInstanceDynamic * Mat) void ULineInstancedStaticMeshComponent::SetLaserMaterial(UMaterialInstanceDynamic * Mat)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ULineInstancedStaticMeshComponent::SetLaserMaterial"))
// 1 for now, could be #Lines if we want multicolored lines // 1 for now, could be #Lines if we want multicolored lines
ColorLUT = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT); ColorLUT = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT);
ColorLUT->UpdateResource(); ColorLUT->UpdateResource();
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "Runtime/Engine/Classes/Camera/CameraActor.h" #include "Runtime/Engine/Classes/Camera/CameraActor.h"
#include "StatsDefines.h"
DEFINE_LOG_CATEGORY(OptiXPluginCameraActor); DEFINE_LOG_CATEGORY(OptiXPluginCameraActor);
...@@ -129,6 +131,8 @@ void AOptiXPlayerCameraManager::EndPlay(const EEndPlayReason::Type EndPlayReason ...@@ -129,6 +131,8 @@ void AOptiXPlayerCameraManager::EndPlay(const EEndPlayReason::Type EndPlayReason
void AOptiXPlayerCameraManager::Tick(float DeltaSeconds) void AOptiXPlayerCameraManager::Tick(float DeltaSeconds)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXPlayerCameraManager::Tick"))
Super::Tick(DeltaSeconds); Super::Tick(DeltaSeconds);
if (C == 2) if (C == 2)
{ {
...@@ -155,6 +159,7 @@ void AOptiXPlayerCameraManager::Init() ...@@ -155,6 +159,7 @@ void AOptiXPlayerCameraManager::Init()
void AOptiXPlayerCameraManager::CaptureCubemap() void AOptiXPlayerCameraManager::CaptureCubemap()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXPlayerCameraManager::CaptureCubemap"))
// 2D // 2D
TArray<FVector> Directions = TArray<FVector> Directions =
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include <EngineGlobals.h> #include <EngineGlobals.h>
#include <Runtime/Engine/Classes/Engine/Engine.h> #include <Runtime/Engine/Classes/Engine/Engine.h>
#include "StatsDefines.h"
DEFINE_LOG_CATEGORY(OptiXPluginContext); DEFINE_LOG_CATEGORY(OptiXPluginContext);
...@@ -35,6 +38,8 @@ optix::Context UOptiXContext::Init() ...@@ -35,6 +38,8 @@ optix::Context UOptiXContext::Init()
void UOptiXContext::UpdateVariables() void UOptiXContext::UpdateVariables()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXContext::UpdateVariables"))
check(IsInRenderingThread()); check(IsInRenderingThread());
for (UOptiXTransform* T : TransformMap) for (UOptiXTransform* T : TransformMap)
...@@ -901,22 +906,10 @@ UOptiXProgram* UOptiXContext::GetMissProgram(int32 RayTypeIndex) ...@@ -901,22 +906,10 @@ UOptiXProgram* UOptiXContext::GetMissProgram(int32 RayTypeIndex)
return Program; return Program;
} }
void UOptiXContext::Compile()
{
try
{
NativeContext->compile();
}
catch (optix::Exception& E)
{
FString Message = FString(E.getErrorString().c_str());
UE_LOG(OptiXPluginContext, Error, TEXT("OptiX Error: %s"), *Message);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("OptiX Error %s"), *Message));
}
}
void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth) void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXContext::Launch1D"))
try try
{ {
NativeContext->launch(EntryPointIndex, ImageWidth); NativeContext->launch(EntryPointIndex, ImageWidth);
...@@ -932,6 +925,7 @@ void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth) ...@@ -932,6 +925,7 @@ void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth)
void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth, uint64 ImageHeight) void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth, uint64 ImageHeight)
{ {
//UE_LOG(OptiXPluginContext, Warning, TEXT("Child count: %i"), GeometryGroupMap["top_object"]->GetChildCount()); //UE_LOG(OptiXPluginContext, Warning, TEXT("Child count: %i"), GeometryGroupMap["top_object"]->GetChildCount());
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXContext::Launch2D"))
try try
{ {
...@@ -947,6 +941,8 @@ void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth, uint64 Imag ...@@ -947,6 +941,8 @@ void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth, uint64 Imag
void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth, uint64 ImageHeight, uint64 ImageDepth) void UOptiXContext::Launch(int32 EntryPointIndex, uint64 ImageWidth, uint64 ImageHeight, uint64 ImageDepth)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXContext::Launch3D"))
try try
{ {
NativeContext->launch(EntryPointIndex, ImageWidth, ImageHeight, ImageDepth); NativeContext->launch(EntryPointIndex, ImageWidth, ImageHeight, ImageDepth);
......
This diff is collapsed.
...@@ -581,36 +581,6 @@ UOptiXProgram* UOptiXGeometry::GetIntersectionProgram() ...@@ -581,36 +581,6 @@ UOptiXProgram* UOptiXGeometry::GetIntersectionProgram()
return Prog; return Prog;
} }
void UOptiXGeometry::MarkDirty()
{
try
{
NativeGeometry->markDirty();
}
catch (optix::Exception& E)
{
FString Message = FString(E.getErrorString().c_str());
UE_LOG(OptiXPluginGeometry, Error, TEXT("OptiX Error: %s"), *Message);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("OptiX Error %s"), *Message));
}
}
bool UOptiXGeometry::IsDirty()
{
bool Dirty = false;
try
{
Dirty = NativeGeometry->isDirty();
}
catch (optix::Exception& E)
{
FString Message = FString(E.getErrorString().c_str());
UE_LOG(OptiXPluginGeometry, Error, TEXT("OptiX Error: %s"), *Message);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("OptiX Error %s"), *Message));
}
return Dirty;
}
void UOptiXGeometry::SetBuffer(FString Name, UOptiXBuffer* Buffer) void UOptiXGeometry::SetBuffer(FString Name, UOptiXBuffer* Buffer)
{ {
try try
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "OptiXModule.h" #include "OptiXModule.h"
#include "UObject/ConstructorHelpers.h" #include "UObject/ConstructorHelpers.h"
#include "StatsDefines.h"
// Sets default values for this component's properties // Sets default values for this component's properties
...@@ -158,6 +159,8 @@ void UOptiXLaserComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransfo ...@@ -158,6 +159,8 @@ void UOptiXLaserComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransfo
void UOptiXLaserComponent::UpdateOptiXContextVariables() void UOptiXLaserComponent::UpdateOptiXContextVariables()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("FOptiXContextManager::UpdateOptiXContextVariables"))
check(IsInRenderingThread()); check(IsInRenderingThread());
if (bUpdateQueued) if (bUpdateQueued)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "OptiXModule.h" #include "OptiXModule.h"
#include "OptiXLaserActor.h" #include "OptiXLaserActor.h"
#include "StatsDefines.h"
AOptiXLaserDetectorActor::AOptiXLaserDetectorActor(const FObjectInitializer& ObjectInitializer) AOptiXLaserDetectorActor::AOptiXLaserDetectorActor(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
...@@ -47,8 +48,10 @@ void AOptiXLaserDetectorActor::EndPlay(const EEndPlayReason::Type EndPlayReason) ...@@ -47,8 +48,10 @@ void AOptiXLaserDetectorActor::EndPlay(const EEndPlayReason::Type EndPlayReason)
void AOptiXLaserDetectorActor::Tick(float DeltaTime) void AOptiXLaserDetectorActor::Tick(float DeltaTime)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXLaserDetectorActor::Tick"))
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
OnLaserTraceFinished(); //OnLaserTraceFinished();
} }
void AOptiXLaserDetectorActor::Init() void AOptiXLaserDetectorActor::Init()
...@@ -89,6 +92,7 @@ void AOptiXLaserDetectorActor::Init() ...@@ -89,6 +92,7 @@ void AOptiXLaserDetectorActor::Init()
void AOptiXLaserDetectorActor::OnLaserTraceFinished() void AOptiXLaserDetectorActor::OnLaserTraceFinished()
{ {
//UE_LOG(LogTemp, Warning, TEXT("lasertracefinished")); //UE_LOG(LogTemp, Warning, TEXT("lasertracefinished"));
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXLaserDetectorActor::OnLaserTraceFinished"))
if (bIsEnabled) if (bIsEnabled)
{ {
...@@ -99,6 +103,7 @@ void AOptiXLaserDetectorActor::OnLaserTraceFinished() ...@@ -99,6 +103,7 @@ void AOptiXLaserDetectorActor::OnLaserTraceFinished()
void AOptiXLaserDetectorActor::RenderDataToTarget() void AOptiXLaserDetectorActor::RenderDataToTarget()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXLaserDetectorActor::RenderDataToTarget"))
// Let's try something else: // Let's try something else:
...@@ -135,6 +140,8 @@ void AOptiXLaserDetectorActor::RenderDataToTarget() ...@@ -135,6 +140,8 @@ void AOptiXLaserDetectorActor::RenderDataToTarget()
void AOptiXLaserDetectorActor::Clear() void AOptiXLaserDetectorActor::Clear()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXLaserDetectorActor::Clear"))
uint32 Size = static_cast<int32>(OptiXLaserTargetComponent->TargetRes); uint32 Size = static_cast<int32>(OptiXLaserTargetComponent->TargetRes);
TArray<FColor> Black; TArray<FColor> Black;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "Runtime/Engine/Classes/Components/StaticMeshComponent.h" #include "Runtime/Engine/Classes/Components/StaticMeshComponent.h"
#include "Runtime/Engine/Classes/Engine/StaticMesh.h" #include "Runtime/Engine/Classes/Engine/StaticMesh.h"
#include "Runtime/Engine/Classes/Materials/MaterialInstanceDynamic.h" #include "Runtime/Engine/Classes/Materials/MaterialInstanceDynamic.h"
#include "StatsDefines.h"
UOptiXLaserTargetComponent::UOptiXLaserTargetComponent(const FObjectInitializer& ObjectInitializer) UOptiXLaserTargetComponent::UOptiXLaserTargetComponent(const FObjectInitializer& ObjectInitializer)
...@@ -164,6 +165,7 @@ float UOptiXLaserTargetComponent::GetMaxFromBuffer() ...@@ -164,6 +165,7 @@ float UOptiXLaserTargetComponent::GetMaxFromBuffer()
void UOptiXLaserTargetComponent::UpdateBufferData() void UOptiXLaserTargetComponent::UpdateBufferData()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXLaserTargetComponent::UpdateBufferData"))
check(IsInRenderingThread()); check(IsInRenderingThread());
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "OptiXModule.h" #include "OptiXModule.h"
#include "StatsDefines.h"
UOptiXLensComponent::UOptiXLensComponent(const FObjectInitializer& ObjectInitializer) UOptiXLensComponent::UOptiXLensComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
...@@ -44,6 +45,8 @@ void UOptiXLensComponent::BeginPlay() ...@@ -44,6 +45,8 @@ void UOptiXLensComponent::BeginPlay()
void UOptiXLensComponent::UpdateOptiXComponentVariables() void UOptiXLensComponent::UpdateOptiXComponentVariables()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXLensComponent::UpdateOptiXComponentVariables"))
check(IsInRenderingThread()); check(IsInRenderingThread());
...@@ -205,6 +208,7 @@ void UOptiXLensComponent::InitCubemap(FRHICommandListImmediate & RHICmdList) ...@@ -205,6 +208,7 @@ void UOptiXLensComponent::InitCubemap(FRHICommandListImmediate & RHICmdList)
void UOptiXLensComponent::UpdateCubemap(FRHICommandListImmediate & RHICmdList) void UOptiXLensComponent::UpdateCubemap(FRHICommandListImmediate & RHICmdList)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXLensComponent::UpdateCubemap"))
UE_LOG(LogTemp, Display, TEXT("Updating Cubemap")); UE_LOG(LogTemp, Display, TEXT("Updating Cubemap"));
...@@ -389,11 +393,6 @@ void UOptiXLensComponent::MarkDirty() ...@@ -389,11 +393,6 @@ void UOptiXLensComponent::MarkDirty()
UE_LOG(LogTemp, Display, TEXT("Marking Dirty")); UE_LOG(LogTemp, Display, TEXT("Marking Dirty"));
if (OptiXGeometry != nullptr)
{
OptiXGeometry->MarkDirty();
}
if (OptiXAcceleration != nullptr) if (OptiXAcceleration != nullptr)
{ {
OptiXAcceleration->MarkDirty(); OptiXAcceleration->MarkDirty();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "OptiXLaserActor.h" #include "OptiXLaserActor.h"
#include "OptiXTargetComponent.h" #include "OptiXTargetComponent.h"
#include "OptiXModule.h" #include "OptiXModule.h"
#include "StatsDefines.h"
UOptiXObjectComponent::UOptiXObjectComponent(const FObjectInitializer& ObjectInitializer) UOptiXObjectComponent::UOptiXObjectComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
...@@ -66,6 +67,8 @@ void UOptiXObjectComponent::RegisterOptiXComponent() ...@@ -66,6 +67,8 @@ void UOptiXObjectComponent::RegisterOptiXComponent()
void UOptiXObjectComponent::QueueOptiXContextUpdate() void UOptiXObjectComponent::QueueOptiXContextUpdate()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXObjectComponent::QueueOptiXContextUpdate"))
if (!bUpdateQueued) if (!bUpdateQueued)
{ {
FOptiXModule::Get().GetOptiXContextManager()->QueueComponentUpdate(this); FOptiXModule::Get().GetOptiXContextManager()->QueueComponentUpdate(this);
...@@ -82,6 +85,8 @@ void UOptiXObjectComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) ...@@ -82,6 +85,8 @@ void UOptiXObjectComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
void UOptiXObjectComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport/* = ETeleportType::None*/) void UOptiXObjectComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport/* = ETeleportType::None*/)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXObjectComponent::OnUpdateTransform"))
Super::OnUpdateTransform(EUpdateTransformFlags::SkipPhysicsUpdate, Teleport); Super::OnUpdateTransform(EUpdateTransformFlags::SkipPhysicsUpdate, Teleport);
UpdateOptiXComponent(); UpdateOptiXComponent();
...@@ -323,6 +328,8 @@ void UOptiXCubemapComponent::SetUpdateQueued(bool UpdateQueued) ...@@ -323,6 +328,8 @@ void UOptiXCubemapComponent::SetUpdateQueued(bool UpdateQueued)
void UOptiXCubemapComponent::RequestCubemapUpdate() void UOptiXCubemapComponent::RequestCubemapUpdate()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UOptiXCubemapComponent::RequestCubemapUpdate"))
CaptureScene(); CaptureScene();
FOptiXModule::Get().GetOptiXContextManager()->RequestCubemapUpdate(this); FOptiXModule::Get().GetOptiXContextManager()->RequestCubemapUpdate(this);
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "PickupActorInterface.h" #include "PickupActorInterface.h"
#include "OptiXModule.h" #include "OptiXModule.h"
#include "StatsDefines.h"
// Sets default values // Sets default values
...@@ -27,6 +28,8 @@ void AOptiXVRPawn::BeginPlay() ...@@ -27,6 +28,8 @@ void AOptiXVRPawn::BeginPlay()
// Called every frame // Called every frame
void AOptiXVRPawn::Tick(float DeltaTime) void AOptiXVRPawn::Tick(float DeltaTime)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXVRPawn::Tick"))
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
} }
...@@ -40,6 +43,8 @@ void AOptiXVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompone ...@@ -40,6 +43,8 @@ void AOptiXVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompone
void AOptiXVRPawn::UpdateTranslation(UPrimitiveComponent* Interaction) void AOptiXVRPawn::UpdateTranslation(UPrimitiveComponent* Interaction)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXVRPawn::UpdateTranslation"))
if (GrabbedLever == NULL) if (GrabbedLever == NULL)
{ {
return; return;
...@@ -105,6 +110,7 @@ UMaterialInstanceDynamic* AOptiXVRPawn::GetMIDOrtho() ...@@ -105,6 +110,7 @@ UMaterialInstanceDynamic* AOptiXVRPawn::GetMIDOrtho()
void AOptiXVRPawn::RequestOrthoPass(const FMinimalViewInfo& ViewInfo) void AOptiXVRPawn::RequestOrthoPass(const FMinimalViewInfo& ViewInfo)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXVRPawn::RequestOrthoPass"))
FSceneViewProjectionData ProjectionData; FSceneViewProjectionData ProjectionData;
ProjectionData.ViewOrigin = ViewInfo.Location; ProjectionData.ViewOrigin = ViewInfo.Location;
...@@ -123,6 +129,8 @@ void AOptiXVRPawn::RequestOrthoPass(const FMinimalViewInfo& ViewInfo) ...@@ -123,6 +129,8 @@ void AOptiXVRPawn::RequestOrthoPass(const FMinimalViewInfo& ViewInfo)
UStaticMeshComponent * AOptiXVRPawn::GetNearestMeshComponent(UPrimitiveComponent * Other) UStaticMeshComponent * AOptiXVRPawn::GetNearestMeshComponent(UPrimitiveComponent * Other)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXVRPawn::GetNearestMeshComponent"))
TArray<UPrimitiveComponent*> OverlappingComponents; TArray<UPrimitiveComponent*> OverlappingComponents;
Other->GetOverlappingComponents(OverlappingComponents); Other->GetOverlappingComponents(OverlappingComponents);
...@@ -148,6 +156,7 @@ UStaticMeshComponent * AOptiXVRPawn::GetNearestMeshComponent(UPrimitiveComponent ...@@ -148,6 +156,7 @@ UStaticMeshComponent * AOptiXVRPawn::GetNearestMeshComponent(UPrimitiveComponent
AActor * AOptiXVRPawn::GetActorNearHand(UPrimitiveComponent * Hand) AActor * AOptiXVRPawn::GetActorNearHand(UPrimitiveComponent * Hand)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("AOptiXVRPawn::GetActorNearHand"))
TArray<AActor*> OverlappingActors; TArray<AActor*> OverlappingActors;
Hand->GetOverlappingActors(OverlappingActors); Hand->GetOverlappingActors(OverlappingActors);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "Runtime/Engine/Classes/Materials/MaterialInstanceDynamic.h" #include "Runtime/Engine/Classes/Materials/MaterialInstanceDynamic.h"
#include "OptiXVRPawn.h" #include "OptiXVRPawn.h"
#include "StatsDefines.h"
ASelectableActorBase::ASelectableActorBase(const FObjectInitializer& ObjectInitializer) ASelectableActorBase::ASelectableActorBase(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
...@@ -377,6 +378,7 @@ void ASelectableActorBase::BeginPlay() ...@@ -377,6 +378,7 @@ void ASelectableActorBase::BeginPlay()
void ASelectableActorBase::Tick(float DeltaTime) void ASelectableActorBase::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ASelectableActorBase::Tick"))
FVector PlayerLocation = UGameplayStatics::GetPlayerPawn(GetWorld(), 0)->GetActorLocation(); FVector PlayerLocation = UGameplayStatics::GetPlayerPawn(GetWorld(), 0)->GetActorLocation();
...@@ -483,6 +485,7 @@ void ASelectableActorBase::DeleteActor() ...@@ -483,6 +485,7 @@ void ASelectableActorBase::DeleteActor()
void ASelectableActorBase::SetRodPosition(FVector TablePosition) void ASelectableActorBase::SetRodPosition(FVector TablePosition)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ASelectableActorBase::SetRodPosition"))
// Flip socket? // Flip socket?
if (Socket->GetComponentLocation().Z > GetActorLocation().Z) if (Socket->GetComponentLocation().Z > GetActorLocation().Z)
......
//------------------------------------------------------------------------------
// Project Phoenix
//
// Copyright (c) 2017-2018 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualization Group.
//------------------------------------------------------------------------------
// License
//
// Licensed under the 3-Clause BSD License (the "License");
// you may not use this file except in compliance with the License.
// See the file LICENSE for the full text.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//------------------------------------------------------------------------------
#include <optix.h>
#include <optix_world.h>
#include "lens_intersections.h"
using namespace optix;
rtDeclareVariable(float3, size, , );
rtDeclareVariable(float, scene_epsilon, , );
rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
rtDeclareVariable(float2, texture_coord, attribute texture_coord, );
RT_PROGRAM void intersect(int primIdx)
{
float3 bounds[] = {-size/2.0f, size/2.0f};
float3 invDir = 1.0f / ray.direction;
uint3 sign = {invDir.x < 0, invDir.y < 0, invDir.z < 0};
float tmin = (bounds[sign.x].x - ray.origin.x) * invDir.x;
float tmax = (bounds[1 - sign.x].x - ray.origin.x) * invDir.x;
float tymin = (bounds[sign.y].y - ray.origin.y) * invDir.y;
float tymax = (bounds[1 - sign.y].y - ray.origin.y) * invDir.y;
if ((tmin > tymax) || (tymin > tmax)) return;
if (tymin > tmin) tmin = tymin;
if (tymax < tmax) tmax = tymax;
float tzmin = (bounds[sign.z].z - ray.origin.z) * invDir.z;
float tzmax = (bounds[1 - sign.z].z - ray.origin.z) * invDir.z;
if ((tmin > tzmax) || (tzmin > tmax)) return;
if (tzmin > tmin) tmin = tzmin;
//if (tzmax < tmax) tmax = tzmax;
if(rtPotentialIntersection(tmin)) {
float3 hit_point = ray.origin + ray.direction * tmin;
texture_coord = make_float2(-1.0f, -1.0f);
if(tmin != tzmin && tmin != tymin){ //x-side
texture_coord = (make_float2(hit_point.y, hit_point.z) - make_float2(-size.y / 2.0f, -size.z / 2.0f))
/make_float2(size.y, size.z);
//rtPrintf("%f, %f\n", texture_coord.x, texture_coord.y);
}
rtReportIntersection(0);
}
}
RT_PROGRAM void bounds (int, optix::Aabb* aabb)
{
aabb->m_min = -size/2.0f;
aabb->m_max = size/2.0f;
}
//------------------------------------------------------------------------------
// Project Phoenix
//
// Copyright (c) 2017-2018 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualization Group.
//------------------------------------------------------------------------------
// License
//
// Licensed under the 3-Clause BSD License (the "License");
// you may not use this file except in compliance with the License.
// See the file LICENSE for the full text.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//------------------------------------------------------------------------------
#include <optix.h>
using namespace optix;
rtDeclareVariable(uint2, launch_index, rtLaunchIndex, );
RT_PROGRAM void exception()
{
const unsigned int code = rtGetExceptionCode();
rtPrintf( "Caught exception 0x%X at launch index (%d,%d)\n", code, launch_index.x, launch_index.y );
}
\ No newline at end of file
//------------------------------------------------------------------------------
// Project Phoenix
//
// Copyright (c) 2017-2018 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualization Group.
//------------------------------------------------------------------------------
// License
//
// Licensed under the 3-Clause BSD License (the "License");
// you may not use this file except in compliance with the License.
// See the file LICENSE for the full text.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//------------------------------------------------------------------------------
#include <optix_world.h>
#include "prd.h"
rtDeclareVariable(PerRayData_radiance, prd_radiance, rtPayload, );
rtDeclareVariable(PerRayData_radiance_iterative, prd_radiance_it, rtPayload, );
rtTextureSampler<float4, 2> frameTexture;
rtDeclareVariable(float2, texture_coord, attribute texture_coord, );
rtDeclareVariable(float, hit_depth, rtIntersectionDistance, );
rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
RT_PROGRAM void closest_hit_radiance()
{
if(texture_coord.x >= 0 && texture_coord.y >= 0){
prd_radiance.result = make_float3(tex2D(frameTexture, texture_coord.x, texture_coord.y));
}else{
prd_radiance.result = make_float3(1.0f);
}
prd_radiance.hit_depth = hit_depth;
}
RT_PROGRAM void closest_hit_iterative()
{
float3 hit_point = ray.origin + hit_depth * ray.direction;
prd_radiance_it.origin = hit_point;
prd_radiance_it.done = true;
}
/*
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <optix.h>
#include <optixu/optixu_math_namespace.h>
#include "prd.h"
#include "random.h"
using namespace optix;
rtDeclareVariable(float3, shading_normal, attribute shading_normal, );
rtDeclareVariable(float3, front_hit_point, attribute front_hit_point, );
rtDeclareVariable(float3, back_hit_point, attribute back_hit_point, );
rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
rtDeclareVariable(float, t_hit, rtIntersectionDistance, );
rtDeclareVariable(int, allowTir, , );
rtDeclareVariable(float, refraction_index, , );
rtDeclareVariable(float, laserWaveLength, , );
rtDeclareVariable(PerRayData_radiance_iterative, prd_radiance, rtPayload, );
RT_PROGRAM void closest_hit_radiance()
{
prd_radiance.hit_lens = 1;
const float3 w_out = -ray.direction;
float3 normal = normalize(rtTransformNormal(RT_OBJECT_TO_WORLD, shading_normal));
float cos_theta_i = optix::dot( w_out, normal );
float eta = ( cos_theta_i > 0.0f ) * refraction_index + ( cos_theta_i <= 0.0f ) * 1.0f / refraction_index;
normal = ( cos_theta_i > 0.0f ) * normal + ( cos_theta_i <= 0.0f ) * -normal;
float3 w_t;
const bool tir = !optix::refract( w_t, -w_out, normal, eta );
const float3 w_in = (tir > 0) * optix::reflect( -w_out, normal ) + (tir <= 0) * w_t;
const float3 fhp = rtTransformPoint(RT_OBJECT_TO_WORLD, front_hit_point);
const float3 bhp = rtTransformPoint(RT_OBJECT_TO_WORLD, back_hit_point);
prd_radiance.origin = (tir > 0) * fhp + (tir <= 0) * bhp;
prd_radiance.direction = w_in;
prd_radiance.done = !allowTir && tir;
// Note: we do not trace the ray for the next bounce here, we just set it up for
// the ray-gen program using per-ray data.
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment