Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MasterTestProjekt
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
MasterTestProjekt
Commits
455c7bec
Commit
455c7bec
authored
Jun 06, 2017
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
texture write
parent
3b471513
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
20 deletions
+69
-20
Minimal_Default.umap
Content/MobileStarterContent/Maps/Minimal_Default.umap
+0
-0
Minimal_Default_BuiltData.uasset
...obileStarterContent/Maps/Minimal_Default_BuiltData.uasset
+0
-0
TestTextureMaterial.uasset
Content/materials/TestTextureMaterial.uasset
+0
-0
DynamicTextureUtilities.cpp
Source/MasterTestProject/DynamicTextureUtilities.cpp
+46
-20
DynamicTextureUtilities.h
Source/MasterTestProject/DynamicTextureUtilities.h
+3
-0
Tileset.cpp
Source/MasterTestProject/Tileset.cpp
+10
-0
Tileset.h
Source/MasterTestProject/Tileset.h
+10
-0
No files found.
Content/MobileStarterContent/Maps/Minimal_Default.umap
View file @
455c7bec
No preview for this file type
Content/MobileStarterContent/Maps/Minimal_Default_BuiltData.uasset
View file @
455c7bec
No preview for this file type
Content/materials/TestTextureMaterial.uasset
0 → 100644
View file @
455c7bec
File added
Source/MasterTestProject/DynamicTextureUtilities.cpp
View file @
455c7bec
...
...
@@ -39,24 +39,24 @@ void UDynamicTextureUtilities::UpdateTextureRegion(UTexture2D* Texture, int32 Mi
bool
,
bFreeData
,
bFreeData
,
{
int32
CurrentFirstMip
=
RegionData
->
Texture2DResource
->
GetCurrentFirstMip
();
if
(
RegionData
->
MipIndex
>=
CurrentFirstMip
)
{
RHIUpdateTexture2D
(
RegionData
->
Texture2DResource
->
GetTexture2DRHI
(),
RegionData
->
MipIndex
-
CurrentFirstMip
,
RegionData
->
Region
,
RegionData
->
SrcPitch
,
RegionData
->
SrcData
+
RegionData
->
Region
.
SrcY
*
RegionData
->
SrcPitch
+
RegionData
->
Region
.
SrcX
*
RegionData
->
SrcBpp
);
}
// TODO is this leaking if we never set this to true??
if
(
bFreeData
)
{
FMemory
::
Free
(
RegionData
->
SrcData
);
}
delete
RegionData
;
if
(
RegionData
->
MipIndex
>=
CurrentFirstMip
)
{
RHIUpdateTexture2D
(
RegionData
->
Texture2DResource
->
GetTexture2DRHI
(),
RegionData
->
MipIndex
-
CurrentFirstMip
,
RegionData
->
Region
,
RegionData
->
SrcPitch
,
RegionData
->
SrcData
+
RegionData
->
Region
.
SrcY
*
RegionData
->
SrcPitch
+
RegionData
->
Region
.
SrcX
*
RegionData
->
SrcBpp
);
}
// TODO is this leaking if we never set this to true??
if
(
bFreeData
)
{
FMemory
::
Free
(
RegionData
->
SrcData
);
}
delete
RegionData
;
});
}
...
...
@@ -66,14 +66,14 @@ void UDynamicTextureUtilities::UpdateTextureRegion(UTexture2D* Texture, int32 Mi
void
UDynamicTextureUtilities
::
UpdateDynamicVectorTexture
(
const
TArray
<
FLinearColor
>&
Source
,
UTexture2D
*
Texture
)
{
// Only handles 32-bit float textures
if
(
!
Texture
||
Texture
->
GetPixelFormat
()
!=
PF_
A32B32G32R32F
)
return
;
if
(
!
Texture
||
Texture
->
GetPixelFormat
()
!=
PF_
FloatRGB
)
return
;
// Shouldn't do anything if there's no data
if
(
Source
.
Num
()
<
1
)
return
;
UpdateTextureRegion
(
Texture
,
0
,
FUpdateTextureRegion2D
(
0
,
0
,
0
,
0
,
Texture
->
GetSizeX
(),
Texture
->
GetSizeY
()),
Texture
->
GetSizeX
()
*
sizeof
(
FLinearColor
),
sizeof
(
FLinearColor
),
(
uint8
*
)
Source
.
GetData
(),
false
);
}
UTexture2D
*
UDynamicTextureUtilities
::
CreateTransientDynamicTexture
(
int32
Width
,
int32
Height
,
EPixelFormat
PixelFormat
/*= PF_A32B32G32R32F*/
)
UTexture2D
*
UDynamicTextureUtilities
::
CreateTransientDynamicTexture
(
int32
Width
,
int32
Height
,
EPixelFormat
PixelFormat
)
{
auto
*
Texture
=
UTexture2D
::
CreateTransient
(
Width
,
Height
,
PixelFormat
);
if
(
Texture
)
...
...
@@ -85,6 +85,32 @@ UTexture2D* UDynamicTextureUtilities::CreateTransientDynamicTexture(int32 Width,
return
Texture
;
}
UTexture2D
*
UDynamicTextureUtilities
::
CreateDynamicTextureWithData
(
int
length
,
uint8
*
data
)
{
int32
size
=
FMath
::
FloorToInt
(
FMath
::
Sqrt
(
length
))
+
1
;
UE_LOG
(
TILES
,
Error
,
TEXT
(
"Texturein %d, size %d"
),
length
,
size
);
auto
*
Texture
=
UTexture2D
::
CreateTransient
(
size
,
size
,
PF_FloatRGB
);
if
(
Texture
)
{
Texture
->
CompressionSettings
=
TextureCompressionSettings
::
TC_VectorDisplacementmap
;
Texture
->
SRGB
=
0
;
Texture
->
UpdateResource
();
}
UpdateTextureRegion
(
Texture
,
0
,
FUpdateTextureRegion2D
(
0
,
0
,
0
,
0
,
size
,
size
),
size
*
3
*
sizeof
(
float
),
3
*
sizeof
(
float
),
data
,
false
);
return
Texture
;
}
/*
void UDynamicTextureUtilities::SetDynamicTextureAndIndex(class UStaticMeshComponent* Component, class UTexture2D* Texture, int32 Index, FName IndexParameterName, FName TextureParameterName)
{
...
...
Source/MasterTestProject/DynamicTextureUtilities.h
View file @
455c7bec
...
...
@@ -3,6 +3,7 @@
#pragma once
#include "UObject/NoExportTypes.h"
#include "UnrealMath.h"
#include "DynamicTextureUtilities.generated.h"
/**
...
...
@@ -30,5 +31,7 @@ public:
// material, otherwise this will not have the proper effect.
//static void SetDynamicTextureAndIndex(class UStaticMeshComponent* Component, class UTexture2D* Texture, int32 Index, FName IndexParameterName, FName TextureParameterName);
// input rgb flaot array
static
UTexture2D
*
UDynamicTextureUtilities
::
CreateDynamicTextureWithData
(
int
length
,
uint8
*
data
);
};
Source/MasterTestProject/Tileset.cpp
View file @
455c7bec
...
...
@@ -348,6 +348,16 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
uint32
featureTableBinaryOffset
=
pntheader
->
getFeatureStart
()
+
pntheader
->
featureTable
.
featureTableJSONByteLength
;
TSharedPtr
<
FJsonObject
>
binaryBodyReference
=
FeatureTableJSON
->
GetObjectField
(
"POSITION"
);
int32
byteOffset
=
binaryBodyReference
->
GetIntegerField
(
"byteOffset"
);
uint8
*
start
=
(
uint8
*
)(
data
.
GetData
()
+
pntheader
->
getFeatureBinaryStart
()
+
byteOffset
);
UTexture2D
*
points
=
UDynamicTextureUtilities
::
CreateDynamicTextureWithData
(
instances_length
,
start
);
if
(
TextureTest
&&
points
)
{
UMaterialInstanceDynamic
*
Material
=
UMaterialInstanceDynamic
::
Create
(
TextureTest
->
GetStaticMeshComponent
()
->
GetMaterial
(
0
),
nullptr
);
Material
->
SetTextureParameterValue
(
FName
(
"DynamicTexture"
),
points
);
TextureTest
->
GetStaticMeshComponent
()
->
SetMaterial
(
0
,
Material
);
}
/*
TArray<FVector> positons = getAsArray<FVector>(data.GetData(), (int32)(featureTableBinaryOffset + byteOffset), instances_length);
...
...
Source/MasterTestProject/Tileset.h
View file @
455c7bec
...
...
@@ -3,6 +3,7 @@
#pragma once
#include "UObject/NoExportTypes.h"
#include "DynamicTextureUtilities.h"
#include "Tileset.generated.h"
...
...
@@ -295,10 +296,16 @@ struct PointCloudHeader {
return
28
/*headersize*/
;
}
uint32
getFeatureBinaryStart
()
{
return
getFeatureStart
()
+
featureTable
.
featureTableJSONByteLength
;
}
uint32
getBatchStart
()
{
return
getFeatureStart
()
+
featureTable
.
length
();
}
FString
getpartAsString
(
int
start
,
int
lenght
)
{
char
*
ansiiData
=
new
char
[
lenght
+
1
];
memcpy
(
ansiiData
,
(
void
*
)(((
uint8
*
)
this
)
+
start
),
lenght
);
//Assumes bytesRead is always smaller than 1024 bytes
...
...
@@ -334,6 +341,9 @@ public:
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"LOD"
)
float
LODtreshold
=
0
.
1
;
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"Texture"
)
AStaticMeshActor
*
TextureTest
=
NULL
;
// Called when the game starts or when spawned
virtual
void
BeginPlay
()
override
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment