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

temp commit

parent 691c11a1
No related branches found
No related tags found
No related merge requests found
No preview for this file type
File added
......@@ -31,7 +31,8 @@ ULineInstancedStaticMeshComponent::ULineInstancedStaticMeshComponent(const FObje
SetRenderCustomDepth(true);
SetCastShadow(false);
SetCollisionEnabled(ECollisionEnabled::NoCollision);
SetCullDistance(10000);
SetBoundsScale(1000); // Prevent culling due to usage of worldpositionoffset
SegmentsPerLine = 20;
LineNumber = 16;
......@@ -95,8 +96,8 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices,
{
FTransform LineTransform;
LineTransform.SetScale3D({ 0, 0, 0 });
LineTransform.SetLocation({ 0, 0, 0 });
LineTransform.SetScale3D({ 1, 1, 1 });
LineTransform.SetLocation(GetComponentLocation());
// Rotation - align z to point towards End:
......@@ -124,6 +125,12 @@ void ULineInstancedStaticMeshComponent::InitLineSegments(TArray<int32> Indices,
TextureRegion->Height = LineNumber;
TextureRegion->Width = 1;
IndexMap = UTexture2D::CreateTransient(1, LineNumber);
IndexMap->UpdateResource();
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());
DynamicLaserMaterial->SetTextureParameterValue("IndexMap", IndexMap);
}
}
......@@ -137,16 +144,13 @@ void ULineInstancedStaticMeshComponent::UpdateLUT(TArray<FColor> ColorMap)
// Store the actual laser index in the alpha component of the LUT - bit hacky but should do the trick for now.
// first column stores the
ColorLUT = UTexture2D::CreateTransient(1, LineNumber);
ColorLUT->UpdateResource();
UE_LOG(LogTemp, Display, TEXT("ColorLUT | LineNumber (%i | %i "), ColorLUT->GetSizeX(), LineNumber);
ColorLUT->UpdateTextureRegions(0, 1, TextureRegion.Get(), sizeof(FColor), sizeof(FColor), (uint8*)ColorArray.GetData());
DynamicLaserMaterial->SetTextureParameterValue("LUT", ColorLUT);
UE_LOG(LogTemp, Display, TEXT("#Colors: %i"), ColorArray.Num());
}
......@@ -155,13 +159,17 @@ void ULineInstancedStaticMeshComponent::UpdateLUT(TArray<FColor> ColorMap)
void ULineInstancedStaticMeshComponent::SetLaserMaterial(UMaterialInstanceDynamic * Mat)
{
// 1 for now, could be #Lines if we want multicolored lines
ColorLUT = UTexture2D::CreateTransient(1, LineNumber);
ColorLUT = UTexture2D::CreateTransient(1, LineNumber, EPixelFormat::PF_R32_FLOAT);
ColorLUT->UpdateResource();
IndexMap = UTexture2D::CreateTransient(1, LineNumber);
IndexMap->UpdateResource();
DynamicLaserMaterial = Mat;
SetMaterial(0, DynamicLaserMaterial);
DynamicLaserMaterial->SetTextureParameterValue("LUT", ColorLUT);
DynamicLaserMaterial->SetTextureParameterValue("IndexMap", IndexMap);
/*DynamicLaserMaterial->SetScalarParameterValue("Segments", SegmentsPerLine);
DynamicLaserMaterial->SetScalarParameterValue("Lines", LineNumber);
*/
......
......@@ -576,7 +576,7 @@ void FOptiXContextManager::InitRendering()
// Load the materials
RegularMaterial = LoadObject<UMaterial>(GetTransientPackage(), TEXT("Material'/OptiX/PPMaterials/TextureMaterial.TextureMaterial'"));
VRMaterial = LoadObject<UMaterial>(GetTransientPackage(), TEXT("Material'/OptiX/PPMaterials/TextureMaterialVR.TextureMaterialVR'"));
LaserMaterial = LoadObject<UMaterial>(GetTransientPackage(), TEXT("Material'/OptiX/LaserMaterialOffset.LaserMaterialOffset'"));
LaserMaterial = LoadObject<UMaterial>(GetTransientPackage(), TEXT("Material'/OptiX/Laser/LaserMaterial.LaserMaterial'"));
LaserMaterialDynamic = UMaterialInstanceDynamic::Create(LaserMaterial.Get(), OptiXContext.Get(), "DynamicLaserMaterial");
LaserMaterialDynamic->SetTextureParameterValue("IntersectionTexture", LaserIntersectionTexture.Get());
......
......@@ -53,6 +53,9 @@ public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = OptiX)
UTexture2D* ColorLUT;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = OptiX)
UTexture2D* IndexMap;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = OptiX)
TArray<FColor> ColorArray;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment