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

getting there slowly

parent 5cb2ad30
No related branches found
No related tags found
No related merge requests found
No preview for this file type
File added
No preview for this file type
No preview for this file type
...@@ -125,10 +125,18 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices, ...@@ -125,10 +125,18 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices,
TextureRegion->Height = LineNumber; TextureRegion->Height = LineNumber;
TextureRegion->Width = 1; TextureRegion->Width = 1;
IndexMap = UTexture2D::CreateTransient(1, LineNumber); LaserIndicesFloat.Empty();
LaserIndicesFloat.SetNumZeroed(LineNumber);
for (int32 i = 0; i < LineNumber; i++)
{
LaserIndicesFloat[i] = static_cast<float>(LaserIndices[i]);
}
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*)LaserIndices.GetData()); IndexMap->UpdateTextureRegions(0, 1, TextureRegion.Get(), sizeof(float), sizeof(float), (uint8*)LaserIndicesFloat.GetData());
DynamicLaserMaterial->SetTextureParameterValue("IndexMap", IndexMap); DynamicLaserMaterial->SetTextureParameterValue("IndexMap", IndexMap);
} }
...@@ -162,7 +170,7 @@ void ULineInstancedStaticMeshComponent::SetLaserMaterial(UMaterialInstanceDynami ...@@ -162,7 +170,7 @@ void ULineInstancedStaticMeshComponent::SetLaserMaterial(UMaterialInstanceDynami
ColorLUT = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT); ColorLUT = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT);
ColorLUT->UpdateResource(); ColorLUT->UpdateResource();
IndexMap = UTexture2D::CreateTransient(1, LineNumber); IndexMap = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT);
IndexMap->UpdateResource(); IndexMap->UpdateResource();
DynamicLaserMaterial = Mat; DynamicLaserMaterial = Mat;
......
...@@ -188,9 +188,15 @@ void AOptiXLaserActor::UpdateLaserPattern(EPatternTypes Pattern) ...@@ -188,9 +188,15 @@ void AOptiXLaserActor::UpdateLaserPattern(EPatternTypes Pattern)
LineInstancedStaticMeshComponent->UpdateLUT(OptiXLaserComponent->LaserIndexColorMap); LineInstancedStaticMeshComponent->UpdateLUT(OptiXLaserComponent->LaserIndexColorMap);
} }
void AOptiXLaserActor::UpdateLaserWidth(float NewWidth)
void AOptiXLaserActor::DisplayLines()
{ {
OptiXLaserComponent->SetLaserWidth(NewWidth);
LineInstancedStaticMeshComponent->DynamicLaserMaterial->SetScalarParameterValue("Width", NewWidth);
}
//void AOptiXLaserActor::DisplayLines()
//{
/* /*
This works and is decently efficient but the actual optix setup is incredibly wasteful and weird. This works and is decently efficient but the actual optix setup is incredibly wasteful and weird.
There's no need for 3 huge buffers which contain almost no data, as only a few of the 50 * 50 possible rays get traced. There's no need for 3 huge buffers which contain almost no data, as only a few of the 50 * 50 possible rays get traced.
...@@ -198,7 +204,7 @@ void AOptiXLaserActor::DisplayLines() ...@@ -198,7 +204,7 @@ void AOptiXLaserActor::DisplayLines()
*/ */
LineInstancedStaticMeshComponent->UpdateLines(OptiXLaserComponent->GetLaserWidth()); //LineInstancedStaticMeshComponent->UpdateLines(OptiXLaserComponent->GetLaserWidth());
// Update the material here for now TODO // Update the material here for now TODO
...@@ -310,4 +316,4 @@ void AOptiXLaserActor::DisplayLines() ...@@ -310,4 +316,4 @@ void AOptiXLaserActor::DisplayLines()
//UE_LOG(LogTemp, Display, TEXT("Lines : %i"), Lines.Num()); //UE_LOG(LogTemp, Display, TEXT("Lines : %i"), Lines.Num());
//MultiLineActorRef->UpdateMesh(Lines); //MultiLineActorRef->UpdateMesh(Lines);
} //}
...@@ -30,7 +30,7 @@ UOptiXLaserComponent::UOptiXLaserComponent() ...@@ -30,7 +30,7 @@ UOptiXLaserComponent::UOptiXLaserComponent()
TargetColorMode = 0; // todo TargetColorMode = 0; // todo
Wavelength = 450.0f; Wavelength = 450.0f;
LaserWidth = 0.025f; LaserWidth = 0.025f;
CurrentLaserPattern = EPatternTypes::CIRCLE; CurrentLaserPattern = EPatternTypes::POINTER;
LaserTracesPerFrame = 20; LaserTracesPerFrame = 20;
// Find and load default patterns: // Find and load default patterns:
...@@ -170,6 +170,7 @@ void UOptiXLaserComponent::UpdateOptiXContextVariables() ...@@ -170,6 +170,7 @@ void UOptiXLaserComponent::UpdateOptiXContextVariables()
OptiXContext->SetFloat("laserBeamWidth", LaserWidth); OptiXContext->SetFloat("laserBeamWidth", LaserWidth);
// Upload buffer data // Upload buffer data
if (bPatternChanged) if (bPatternChanged)
......
...@@ -51,7 +51,7 @@ rtDeclareVariable(float, laserSize, , ); ...@@ -51,7 +51,7 @@ rtDeclareVariable(float, laserSize, , );
rtBuffer<int, 2> laserIndex; rtBuffer<int, 2> laserIndex;
rtBuffer<float3, 2> laserDir; rtBuffer<float3, 2> laserDir;
rtBuffer<float4, 1> result_laser; rtBuffer<float4, 2> result_laser;
RT_PROGRAM void laser_caster(){ RT_PROGRAM void laser_caster(){
...@@ -82,17 +82,19 @@ RT_PROGRAM void laser_caster(){ ...@@ -82,17 +82,19 @@ RT_PROGRAM void laser_caster(){
prd.direction = laser_rot3x3 * normalize(make_float3(1,1,-1)*laserDir[make_uint2(launch_index)]); prd.direction = laser_rot3x3 * normalize(make_float3(1,1,-1)*laserDir[make_uint2(launch_index)]);
unsigned int startIndex = (launch_index.y * 50 + launch_index.x) * max_depth_laser * 2;
unsigned int widthIndex = launch_index.y * 50 + launch_index.x;
//unsigned int startIndex = widthIndex * max_depth_laser * 2;
bool cast_ray = laserIndex[make_uint2(launch_index)] < 0; bool cast_ray = laserIndex[make_uint2(launch_index)] < 0;
for(int i = 0; i < max_depth_laser * 2; i += 2){ for(int i = 0; i < max_depth_laser * 2; i += 2){
//Determine if this launch_index, depth or last ray should trigger new cast //Determine if this launch_index, depth or last ray should trigger new cast
if(cast_ray || prd.done || prd.depth >= max_depth_laser){ // just write rest of data as "invalid" if(cast_ray || prd.done || prd.depth >= max_depth_laser){ // just write rest of data as "invalid"
if(launch_index.z == 0) result_laser[startIndex + i] = make_float4(0,-1,0,1); if(launch_index.z == 0) result_laser[make_uint2(widthIndex, i)] = make_float4(0,-1,0,1);
if(launch_index.z == 0) result_laser[startIndex + i + 1] = make_float4(0,-1,0,1); if(launch_index.z == 0) result_laser[make_uint2(widthIndex, i + 1)] = make_float4(0,-1,0,1);
continue; continue;
} }
if(launch_index.z == 0) result_laser[startIndex + i] = make_float4(prd.origin,1); if(launch_index.z == 0) result_laser[make_uint2(widthIndex, i)] = make_float4(prd.origin,1);
ray.origin = prd.origin; ray.origin = prd.origin;
ray.direction = prd.direction; ray.direction = prd.direction;
...@@ -100,6 +102,6 @@ RT_PROGRAM void laser_caster(){ ...@@ -100,6 +102,6 @@ RT_PROGRAM void laser_caster(){
// Update ray data for the next path segment // Update ray data for the next path segment
prd.depth++; prd.depth++;
if(launch_index.z == 0) result_laser[startIndex + i + 1] = make_float4(prd.origin,1); if(launch_index.z == 0) result_laser[make_uint2(widthIndex, i + 1)] = make_float4(prd.origin,1);
} }
} }
\ 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_iterative, prd_radiance_it, rtPayload, );
rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
RT_PROGRAM void miss_iterative()
{
prd_radiance_it.origin = ray.origin + ray.direction * 1500.0f;
prd_radiance_it.done = true;
}
...@@ -61,6 +61,7 @@ public: ...@@ -61,6 +61,7 @@ public:
//UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = OptiX) //UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = OptiX)
TArray<int32> LaserIndices; TArray<int32> LaserIndices;
TArray<float> LaserIndicesFloat;
TUniquePtr<FUpdateTextureRegion2D> TextureRegion; TUniquePtr<FUpdateTextureRegion2D> TextureRegion;
......
...@@ -34,8 +34,8 @@ public: ...@@ -34,8 +34,8 @@ public:
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXActor") //UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXActor")
void DisplayLines(); //void DisplayLines();
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXActor") UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXActor")
void UpdateLaserPattern(EPatternTypes Pattern); void UpdateLaserPattern(EPatternTypes Pattern);
...@@ -48,6 +48,9 @@ public: ...@@ -48,6 +48,9 @@ public:
LineInstancedStaticMeshComponent->SetLaserMaterial(DynamicLaserMaterial); LineInstancedStaticMeshComponent->SetLaserMaterial(DynamicLaserMaterial);
} }
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXActor")
void UpdateLaserWidth(float NewWidth);
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = OptiX) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = OptiX)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment