Skip to content

Commit baeb810

Browse files
Add files via upload
1 parent b482602 commit baeb810

File tree

8 files changed

+172
-8
lines changed

8 files changed

+172
-8
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "VertexLightingFunctionLibrary_C.h"
2+
#include "Engine/TextureRenderTarget2D.h"
3+
#include "RenderTargetPool.h"
4+
#include "RHICommandList.h"
5+
#include "RenderUtils.h"
6+
#include "TextureResource.h"
7+
8+
void UVertexLightingFunctionLibrary_C::DrawVertexLightInformationToRenderTarget(UTextureRenderTarget2D* RenderTarget, const TArray<FLinearColor>& VertexLights_Locations, const TArray<FLinearColor>& VertexLights_Colors)
9+
{
10+
if (!RenderTarget)
11+
{
12+
UE_LOG(LogTemp, Warning, TEXT("RenderTarget is not valid"));
13+
return;
14+
}
15+
16+
int32 Width = RenderTarget->SizeX;
17+
int32 Height = RenderTarget->SizeY;
18+
19+
int32 NumCol = FMath::Min(VertexLights_Locations.Num(), VertexLights_Colors.Num());
20+
21+
if (Width < NumCol || Height < 2)
22+
{
23+
UE_LOG(LogTemp, Warning, TEXT("RenderTarget must be at least Nx2 in size."));
24+
return;
25+
}
26+
27+
// Prepare pixel buffer
28+
TArray<FFloat16Color> PixelData;
29+
PixelData.SetNumZeroed(Width * Height);
30+
31+
for (int32 X = 0; X < NumCol; ++X)
32+
{
33+
PixelData[0 * Width + X] = FFloat16Color(VertexLights_Locations[X]); // First row
34+
PixelData[1 * Width + X] = FFloat16Color(VertexLights_Colors[X]); // Second row
35+
}
36+
37+
FTextureRenderTargetResource* RTResource = RenderTarget->GameThread_GetRenderTargetResource();
38+
39+
ENQUEUE_RENDER_COMMAND(UpdateRenderTargetCommand)([RTResource, PixelDataCopy = MoveTemp(PixelData), Width, Height](FRHICommandListImmediate& RHICmdList)
40+
{
41+
FRHITexture* Texture = RTResource->GetRenderTargetTexture();
42+
if (!Texture)
43+
return;
44+
45+
uint32 SrcPitch = Width * sizeof(FFloat16Color);
46+
void* TempMemory = FMemory::Malloc(SrcPitch * Height);
47+
FMemory::Memcpy(TempMemory, PixelDataCopy.GetData(), SrcPitch * Height);
48+
49+
FUpdateTextureRegion2D Region(0, 0, 0, 0, Width, Height);
50+
RHICmdList.UpdateTexture2D(Texture, 0, Region, SrcPitch, static_cast<uint8*>(TempMemory));
51+
52+
FMemory::Free(TempMemory);
53+
}
54+
);
55+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright Epic Games, Inc. All Rights Reserved.
2+
3+
#include "VertexLightingPlugin.h"
4+
5+
#define LOCTEXT_NAMESPACE "FVertexLightingPluginModule"
6+
7+
void FVertexLightingPluginModule::StartupModule()
8+
{
9+
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
10+
}
11+
12+
void FVertexLightingPluginModule::ShutdownModule()
13+
{
14+
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
15+
// we call this function before unloading the module.
16+
}
17+
18+
#undef LOCTEXT_NAMESPACE
19+
20+
IMPLEMENT_MODULE(FVertexLightingPluginModule, VertexLightingPlugin)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include "CoreMinimal.h"
4+
#include "Kismet/BlueprintFunctionLibrary.h"
5+
#include "Engine/TextureRenderTarget2D.h"
6+
#include "VertexLightingFunctionLibrary_C.generated.h"
7+
8+
/**
9+
*
10+
*/
11+
UCLASS()
12+
class VERTEXLIGHTINGPLUGIN_API UVertexLightingFunctionLibrary_C : public UBlueprintFunctionLibrary
13+
{
14+
GENERATED_BODY()
15+
16+
public:
17+
UFUNCTION(BlueprintCallable, Category = "Vertex Lighting")
18+
static void DrawVertexLightInformationToRenderTarget(UTextureRenderTarget2D* RenderTarget,const TArray<FLinearColor>& VertexLights_Locations,const TArray<FLinearColor>& VertexLights_Colors);
19+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Epic Games, Inc. All Rights Reserved.
2+
3+
#pragma once
4+
5+
#include "Modules/ModuleManager.h"
6+
7+
class FVertexLightingPluginModule : public IModuleInterface
8+
{
9+
public:
10+
11+
/** IModuleInterface implementation */
12+
virtual void StartupModule() override;
13+
virtual void ShutdownModule() override;
14+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright Epic Games, Inc. All Rights Reserved.
2+
3+
using UnrealBuildTool;
4+
5+
public class VertexLightingPlugin : ModuleRules
6+
{
7+
public VertexLightingPlugin(ReadOnlyTargetRules Target) : base(Target)
8+
{
9+
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
10+
11+
PublicIncludePaths.AddRange(
12+
new string[] {
13+
// ... add public include paths required here ...
14+
}
15+
);
16+
17+
18+
PrivateIncludePaths.AddRange(
19+
new string[] {
20+
// ... add other private include paths required here ...
21+
}
22+
);
23+
24+
25+
PublicDependencyModuleNames.AddRange(
26+
new string[]
27+
{
28+
"Core",
29+
// ... add other public dependencies that you statically link with here ...
30+
}
31+
);
32+
33+
34+
PrivateDependencyModuleNames.AddRange(
35+
new string[]
36+
{
37+
"CoreUObject",
38+
"Engine",
39+
"InputCore",
40+
"RenderCore",
41+
"RHI",
42+
// ... add private dependencies that you statically link with here ...
43+
}
44+
);
45+
46+
47+
DynamicallyLoadedModuleNames.AddRange(
48+
new string[]
49+
{
50+
// ... add any modules that your module loads dynamically here ...
51+
}
52+
);
53+
}
54+
}

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
theme: jekyll-theme-cayman
1+
theme: jekyll-theme-architect
22
title: Vertex Lighting Plugin Documentation
33
description: Complete documentation on the Vertex Lighting plugin for Unreal Engine
44
site_favicon: favicon.ico
-4.05 KB
Binary file not shown.

docs/index.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## Supported Engine Versions
66
- Unreal Engine 5.5
7+
- Unreal Engine 5.6
78

89
<p style="color:#0F52BA;"> <b>[🗒️NOTE] <a href="https://github.com/PixelIndieDev/Vertex-Lighting-Plugin-For-Unreal-Engine-5/issues/1" target="_self">Why are no other engine versions supported?</a> </b> </p>
910

@@ -29,7 +30,6 @@
2930

3031
<img src="images/guide_images/plugin_enabled.avif" alt="The Vertex Lighting Plugin being enabled" width="400">
3132

32-
<p style="color:#4F7942;"> <b>[💡Dependencies] This plugin depends on the <i>MeshPainting</i> plugin. The <i>MeshPainting</i> plugin is only used to paint the icons of the vertex light actors in the editor to match their light color or ambient color. It is NOT used for the actual vertex lighting.</b> </p>
3333
---
3434

3535
## How to Use
@@ -61,7 +61,7 @@ The plugin includes a demo level showcasing multiple vertex lighting configurati
6161
The `VertexLighting_Manager` is essential for vertex lighting functionality.
6262
<p style="color:#8A2BE2;"> <b>[📑IMPORTANT] Ensure only <ins>one</ins> manager is present per level.</b> </p>
6363

64-
<p style="color:#D2042D;"> <b>[‼️CAUTION] Only up to 256 vertex lights can be registered at the same time, without modifications.</b> </p>
64+
<p style="color:#D2042D;"> <b>[‼️CAUTION] Only up to 256 vertex lights can be registered at the same time, without easy and simple modifications.</b> </p>
6565

6666
<img src="images/actor_icons/Light_Manager.avif" alt="The icon of the VertexLighting_Manager" width="200">
6767

@@ -78,6 +78,12 @@ The `VertexLighting_Manager` is essential for vertex lighting functionality.
7878
- *Default*: 0.01s | *Type*: Float | *Range*: 0.0-Infinite
7979
- **TickRate DayNightCycle**: Time interval between day-night cycle updates. Set to `0.0` to disable updates.
8080
- *Default*: 0.25s | *Type*: Float | *Range*: 0.0-Infinite
81+
82+
###### Time Events:
83+
- **Call OnMinute**: Enables the event dispatcher that triggers when the time updates by one minute.
84+
- *Default*: False | *Type*: Boolean
85+
- **Call OnHour**: Enables the event dispatcher that triggers when the time updates by one hour.
86+
- *Default*: False | *Type*: Boolean
8187

8288
##### Ambient:
8389
- **Ambient Color**: Default environmental color.
@@ -170,12 +176,8 @@ The `VertexLighting_Light_Animated` adds a static or dynamic vertex light with a
170176
#### Default Settings:
171177
- **WorldPosition (Optional)**: Allows manual override of the world position. Defaults to the Absolute World Position.
172178
- *Default*: Absolute World Position | *Type*: Vector3
173-
- **PixelBasedNormals (Optional)**: Best suited for the normals of 2D sprite characters. Only works when the `DisableVertexInterpolator` option is set to enabled.
174-
- *Default*: 0.0, 0.0, 1.0 | *Type*: Vector3
175179
- **VertexBasedNormals (Optional)**: Input for normals interpolated per vertex.
176180
- *Default*: VertexNormalWS | *Type*: Vector3
177-
- **DisableVertexInterpolator (Optional)**: Disables vertex interpolation.
178-
- *Default*: False | *Type*: Boolean
179181

180182
---
181183

@@ -218,4 +220,4 @@ Ensure the following:
218220
---
219221

220222
## Credit
221-
<p style="color:#0F52BA;"> <b>[🗒️NOTE] This project builds upon the work of <a href="https://x.com/evilreflex" target="_self">EvilReFlex</a> </b> </p>
223+
<p style="color:#0F52BA;"> <b>[🗒️NOTE] Portions of this project are based and improved upon on the vertex lighting implementation originally created by <a href="https://x.com/evilreflex" target="_self">EvilReFlex</a>, shared via Discord.</b> </p>

0 commit comments

Comments
 (0)