Repository: AyoubKhammassi/CustomComputeShaders
Branch: master
Commit: 0ada8ca05ff5
Files: 26
Total size: 19.8 KB
Directory structure:
gitextract_pm01ti6p/
├── .gitignore
├── Config/
│ ├── DefaultEditor.ini
│ ├── DefaultEngine.ini
│ └── DefaultGame.ini
├── Content/
│ ├── Maps/
│ │ └── TestMap.umap
│ ├── Materials/
│ │ └── WhiteNoiseMat.uasset
│ ├── WhiteNoiseCS_Output.uasset
│ └── WhiteNoiseCS_RenderTarget.uasset
├── CustomComputeShader.uproject
├── LICENSE
├── README.md
├── Shaders/
│ └── Private/
│ └── WhiteNoiseCS.usf
└── Source/
├── CustomComputeShader/
│ ├── CustomComputeShader.Build.cs
│ ├── CustomComputeShader.cpp
│ ├── CustomComputeShader.h
│ ├── CustomComputeShaderGameModeBase.cpp
│ ├── CustomComputeShaderGameModeBase.h
│ ├── Private/
│ │ └── WhiteNoiseConsumer.cpp
│ └── Public/
│ └── WhiteNoiseConsumer.h
├── CustomComputeShader.Target.cs
├── CustomComputeShaderEditor.Target.cs
└── CustomShadersDeclarations/
├── CustomShadersDeclarations.Build.cs
├── Private/
│ ├── ComputeShaderDeclaration.cpp
│ ├── ComputeShaderDeclaration.h
│ └── CustomShadersDeclarations.cpp
└── Public/
└── CustomShadersDeclarations.h
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
Binaries
DerivedDataCache
Intermediate
Saved
.vscode
.vs
*.VC.db
*.opensdf
*.opendb
*.sdf
*.sln
*.suo
*.xcodeproj
*.xcworkspace
================================================
FILE: Config/DefaultEditor.ini
================================================
================================================
FILE: Config/DefaultEngine.ini
================================================
[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/CustomComputeShader")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/CustomComputeShader")
+ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="CustomComputeShaderGameModeBase")
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum
[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/Maps/TestMap.TestMap
GameDefaultMap=/Game/Maps/TestMap.TestMap
================================================
FILE: Config/DefaultGame.ini
================================================
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=098D2E764A73895DFD1D5EB20AB18FA8
================================================
FILE: CustomComputeShader.uproject
================================================
{
"FileVersion": 3,
"EngineAssociation": "4.24",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "CustomComputeShader",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
},
{
"Name": "CustomShadersDeclarations",
"Type": "Runtime",
"LoadingPhase": "PostConfigInit",
"AdditionalDependencies": [
"Engine"
]
}
]
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2020 Ayoub Khammassi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# CustomComputeShader
A minimal Unreal Engine 4 porject for adding and using a compute shader. I published an article that covers the main steps of the process and I use this project as an example.
## Modules:
* **CustomComputeShader** : The primary game module
* **CustomShadersDeclarations** : The game module that contains all the code for adding and using the compute shader
## Shaders:
* **WhiteNoiseCS** : A simple compute shader that renders white noise to a texture
## UE4 Version
This project was created and tested using **UE4.24**. Id you're using **UE4.25**, you'll need to include **/Engine/Public/Platform.ush** in your shader file in order for it to compile.
================================================
FILE: Shaders/Private/WhiteNoiseCS.usf
================================================
#include "/Engine/Public/Platform.ush"
RWTexture2D<float> OutputTexture;
float2 Dimensions;
uint TimeStamp;
float hash12(float2 p)
{
float3 p3 = frac(float3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return frac((p3.x + p3.y) * p3.z);
}
[numthreads(THREADGROUPSIZE_X, THREADGROUPSIZE_Y, THREADGROUPSIZE_Z)]
void MainComputeShader(uint3 Gid : SV_GroupID, //atm: -, 0...256, - in rows (Y) --> current group index (dispatched by c++)
uint3 DTid : SV_DispatchThreadID, //atm: 0...256 in rows & columns (XY) --> "global" thread id
uint3 GTid : SV_GroupThreadID, //atm: 0...256, -,- in columns (X) --> current threadId in group / "local" threadId
uint GI : SV_GroupIndex) //atm: 0...256 in columns (X) --> "flattened" index of a thread within a group)
{
float2 p = float2(DTid.xy * TimeStamp);
float output = hash12(p);
OutputTexture[DTid.xy] = output;
}
================================================
FILE: Source/CustomComputeShader/CustomComputeShader.Build.cs
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class CustomComputeShader : ModuleRules
{
public CustomComputeShader(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { "CustomShadersDeclarations" });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
================================================
FILE: Source/CustomComputeShader/CustomComputeShader.cpp
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CustomComputeShader.h"
#include "Modules/ModuleManager.h"
#include "Misc/Paths.h"
#include "GlobalShader.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, CustomComputeShader, "CustomComputeShader" );
================================================
FILE: Source/CustomComputeShader/CustomComputeShader.h
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
================================================
FILE: Source/CustomComputeShader/CustomComputeShaderGameModeBase.cpp
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CustomComputeShaderGameModeBase.h"
================================================
FILE: Source/CustomComputeShader/CustomComputeShaderGameModeBase.h
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "CustomComputeShaderGameModeBase.generated.h"
/**
*
*/
UCLASS()
class CUSTOMCOMPUTESHADER_API ACustomComputeShaderGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};
================================================
FILE: Source/CustomComputeShader/Private/WhiteNoiseConsumer.cpp
================================================
#include "WhiteNoiseConsumer.h"
#include "Kismet/GameplayStatics.h"
#include "CustomShadersDeclarations/Private/ComputeShaderDeclaration.h"
// Sets default values
AWhiteNoiseConsumer::AWhiteNoiseConsumer()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
static_mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static Mesh"));
TimeStamp = 0;
}
// Called when the game starts or when spawned
void AWhiteNoiseConsumer::BeginPlay()
{
Super::BeginPlay();
FWhiteNoiseCSManager::Get()->BeginRendering();
//Assuming that the static mesh is already using the material that we're targeting, we create an instance and assign it to it
UMaterialInstanceDynamic* MID = static_mesh->CreateAndSetMaterialInstanceDynamic(0);
MID->SetTextureParameterValue("InputTexture", (UTexture*)RenderTarget);
}
void AWhiteNoiseConsumer::BeginDestroy()
{
FWhiteNoiseCSManager::Get()->EndRendering();
Super::BeginDestroy();
}
// Called every frame
void AWhiteNoiseConsumer::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
//Update parameters
FWhiteNoiseCSParameters parameters(RenderTarget);
TimeStamp++;
parameters.TimeStamp = TimeStamp;
FWhiteNoiseCSManager::Get()->UpdateParameters(parameters);
}
// Called to bind functionality to input
void AWhiteNoiseConsumer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
================================================
FILE: Source/CustomComputeShader/Public/WhiteNoiseConsumer.h
================================================
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "WhiteNoiseConsumer.generated.h"
UCLASS()
class CUSTOMCOMPUTESHADER_API AWhiteNoiseConsumer : public APawn
{
GENERATED_BODY()
//Properties
public:
UPROPERTY()
USceneComponent* Root;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* static_mesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ShaderDemo)
class UTextureRenderTarget2D* RenderTarget;
private:
uint32 TimeStamp;
public:
// Sets default values for this pawn's properties
AWhiteNoiseConsumer();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void BeginDestroy() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
================================================
FILE: Source/CustomComputeShader.Target.cs
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class CustomComputeShaderTarget : TargetRules
{
public CustomComputeShaderTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "CustomComputeShader", "CustomShadersDeclarations" } );
}
}
================================================
FILE: Source/CustomComputeShaderEditor.Target.cs
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class CustomComputeShaderEditorTarget : TargetRules
{
public CustomComputeShaderEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "CustomComputeShader", "CustomShadersDeclarations" } );
}
}
================================================
FILE: Source/CustomShadersDeclarations/CustomShadersDeclarations.Build.cs
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class CustomShadersDeclarations : ModuleRules
{
public CustomShadersDeclarations(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { });
PrivateDependencyModuleNames.AddRange(new string[]
{
"Core",
"CoreUObject",
"Engine",
"Renderer",
"RenderCore",
"RHI",
"Projects"
});
}
}
================================================
FILE: Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp
================================================
#include "ComputeShaderDeclaration.h"
#include "GlobalShader.h"
#include "ShaderParameterStruct.h"
#include "RenderGraphUtils.h"
#include "RenderTargetPool.h"
#include "Modules/ModuleManager.h"
#define NUM_THREADS_PER_GROUP_DIMENSION 32
/// <summary>
/// Internal class thet holds the parameters and connects the HLSL Shader to the engine
/// </summary>
class FWhiteNoiseCS : public FGlobalShader
{
public:
//Declare this class as a global shader
DECLARE_GLOBAL_SHADER(FWhiteNoiseCS);
//Tells the engine that this shader uses a structure for its parameters
SHADER_USE_PARAMETER_STRUCT(FWhiteNoiseCS, FGlobalShader);
/// <summary>
/// DECLARATION OF THE PARAMETER STRUCTURE
/// The parameters must match the parameters in the HLSL code
/// For each parameter, provide the C++ type, and the name (Same name used in HLSL code)
/// </summary>
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
SHADER_PARAMETER_UAV(RWTexture2D<float>, OutputTexture)
SHADER_PARAMETER(FVector2D, Dimensions)
SHADER_PARAMETER(UINT, TimeStamp)
END_SHADER_PARAMETER_STRUCT()
public:
//Called by the engine to determine which permutations to compile for this shader
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
{
return IsFeatureLevelSupported(Parameters.Platform, ERHIFeatureLevel::SM5);
}
//Modifies the compilations environment of the shader
static inline void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
{
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
//We're using it here to add some preprocessor defines. That way we don't have to change both C++ and HLSL code when we change the value for NUM_THREADS_PER_GROUP_DIMENSION
OutEnvironment.SetDefine(TEXT("THREADGROUPSIZE_X"), NUM_THREADS_PER_GROUP_DIMENSION);
OutEnvironment.SetDefine(TEXT("THREADGROUPSIZE_Y"), NUM_THREADS_PER_GROUP_DIMENSION);
OutEnvironment.SetDefine(TEXT("THREADGROUPSIZE_Z"), 1);
}
};
// This will tell the engine to create the shader and where the shader entry point is.
// ShaderType ShaderPath Shader function name Type
IMPLEMENT_GLOBAL_SHADER(FWhiteNoiseCS, "/CustomShaders/WhiteNoiseCS.usf", "MainComputeShader", SF_Compute);
//Static members
FWhiteNoiseCSManager* FWhiteNoiseCSManager::instance = nullptr;
//Begin the execution of the compute shader each frame
void FWhiteNoiseCSManager::BeginRendering()
{
//If the handle is already initalized and valid, no need to do anything
if (OnPostResolvedSceneColorHandle.IsValid())
{
return;
}
bCachedParamsAreValid = false;
//Get the Renderer Module and add our entry to the callbacks so it can be executed each frame after the scene rendering is done
const FName RendererModuleName("Renderer");
IRendererModule* RendererModule = FModuleManager::GetModulePtr<IRendererModule>(RendererModuleName);
if (RendererModule)
{
OnPostResolvedSceneColorHandle = RendererModule->GetResolvedSceneColorCallbacks().AddRaw(this, &FWhiteNoiseCSManager::Execute_RenderThread);
}
}
//Stop the compute shader execution
void FWhiteNoiseCSManager::EndRendering()
{
//If the handle is not valid then there's no cleanup to do
if (!OnPostResolvedSceneColorHandle.IsValid())
{
return;
}
//Get the Renderer Module and remove our entry from the ResolvedSceneColorCallbacks
const FName RendererModuleName("Renderer");
IRendererModule* RendererModule = FModuleManager::GetModulePtr<IRendererModule>(RendererModuleName);
if (RendererModule)
{
RendererModule->GetResolvedSceneColorCallbacks().Remove(OnPostResolvedSceneColorHandle);
}
OnPostResolvedSceneColorHandle.Reset();
}
//Update the parameters by a providing an instance of the Parameters structure used by the shader manager
void FWhiteNoiseCSManager::UpdateParameters(FWhiteNoiseCSParameters& params)
{
cachedParams = params;
bCachedParamsAreValid = true;
}
/// <summary>
/// Creates an instance of the shader type parameters structure and fills it using the cached shader manager parameter structure
/// Gets a reference to the shader type from the global shaders map
/// Dispatches the shader using the parameter structure instance
/// </summary>
void FWhiteNoiseCSManager::Execute_RenderThread(FRHICommandListImmediate& RHICmdList, class FSceneRenderTargets& SceneContext)
{
//If there's no cached parameters to use, skip
//If no Render Target is supplied in the cachedParams, skip
if (!(bCachedParamsAreValid && cachedParams.RenderTarget))
{
return;
}
//Render Thread Assertion
check(IsInRenderingThread());
//If the render target is not valid, get an element from the render target pool by supplying a Descriptor
if (!ComputeShaderOutput.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("Not Valid"));
FPooledRenderTargetDesc ComputeShaderOutputDesc(FPooledRenderTargetDesc::Create2DDesc(cachedParams.GetRenderTargetSize(), cachedParams.RenderTarget->GetRenderTargetResource()->TextureRHI->GetFormat(), FClearValueBinding::None, TexCreate_None, TexCreate_ShaderResource | TexCreate_UAV, false));
ComputeShaderOutputDesc.DebugName = TEXT("WhiteNoiseCS_Output_RenderTarget");
GRenderTargetPool.FindFreeElement(RHICmdList, ComputeShaderOutputDesc, ComputeShaderOutput, TEXT("WhiteNoiseCS_Output_RenderTarget"));
}
//Unbind the previously bound render targets
//UnbindRenderTargets(RHICmdList);
//Specify the resource transition, we're executing this in post scene rendering so we set it to Graphics to Compute
RHICmdList.TransitionResource(EResourceTransitionAccess::ERWBarrier, EResourceTransitionPipeline::EGfxToCompute, ComputeShaderOutput->GetRenderTargetItem().UAV);
//Fill the shader parameters structure with tha cached data supplied by the client
FWhiteNoiseCS::FParameters PassParameters;
PassParameters.OutputTexture = ComputeShaderOutput->GetRenderTargetItem().UAV;
PassParameters.Dimensions = FVector2D(cachedParams.GetRenderTargetSize().X, cachedParams.GetRenderTargetSize().Y);
PassParameters.TimeStamp = cachedParams.TimeStamp;
//Get a reference to our shader type from global shader map
TShaderMapRef<FWhiteNoiseCS> whiteNoiseCS(GetGlobalShaderMap(GMaxRHIFeatureLevel));
//Dispatch the compute shader
FComputeShaderUtils::Dispatch(RHICmdList, whiteNoiseCS, PassParameters,
FIntVector(FMath::DivideAndRoundUp(cachedParams.GetRenderTargetSize().X, NUM_THREADS_PER_GROUP_DIMENSION),
FMath::DivideAndRoundUp(cachedParams.GetRenderTargetSize().Y, NUM_THREADS_PER_GROUP_DIMENSION), 1));
//Copy shader's output to the render target provided by the client
RHICmdList.CopyTexture(ComputeShaderOutput->GetRenderTargetItem().ShaderResourceTexture, cachedParams.RenderTarget->GetRenderTargetResource()->TextureRHI, FRHICopyTextureInfo());
}
================================================
FILE: Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h
================================================
#pragma once
#include "CoreMinimal.h"
#include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h"
//This struct act as a container for all the parameters that the client needs to pass to the Compute Shader Manager.
struct FWhiteNoiseCSParameters
{
UTextureRenderTarget2D* RenderTarget;
FIntPoint GetRenderTargetSize() const
{
return CachedRenderTargetSize;
}
FWhiteNoiseCSParameters() { }
FWhiteNoiseCSParameters(UTextureRenderTarget2D* IORenderTarget)
: RenderTarget(IORenderTarget)
{
CachedRenderTargetSize = RenderTarget ? FIntPoint(RenderTarget->SizeX, RenderTarget->SizeY) : FIntPoint::ZeroValue;
}
private:
FIntPoint CachedRenderTargetSize;
public:
uint32 TimeStamp;
};
/// <summary>
/// A singleton Shader Manager for our Shader Type
/// </summary>
class CUSTOMSHADERSDECLARATIONS_API FWhiteNoiseCSManager
{
public:
//Get the instance
static FWhiteNoiseCSManager* Get()
{
if (!instance)
instance = new FWhiteNoiseCSManager();
return instance;
};
// Call this when you want to hook onto the renderer and start executing the compute shader. The shader will be dispatched once per frame.
void BeginRendering();
// Stops compute shader execution
void EndRendering();
// Call this whenever you have new parameters to share.
void UpdateParameters(FWhiteNoiseCSParameters& DrawParameters);
private:
//Private constructor to prevent client from instanciating
FWhiteNoiseCSManager() = default;
//The singleton instance
static FWhiteNoiseCSManager* instance;
//The delegate handle to our function that will be executed each frame by the renderer
FDelegateHandle OnPostResolvedSceneColorHandle;
//Cached Shader Manager Parameters
FWhiteNoiseCSParameters cachedParams;
//Whether we have cached parameters to pass to the shader or not
volatile bool bCachedParamsAreValid;
//Reference to a pooled render target where the shader will write its output
TRefCountPtr<IPooledRenderTarget> ComputeShaderOutput;
public:
void Execute_RenderThread(FRHICommandListImmediate& RHICmdList, class FSceneRenderTargets& SceneContext);
};
================================================
FILE: Source/CustomShadersDeclarations/Private/CustomShadersDeclarations.cpp
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CustomShadersDeclarations.h"
#include "Modules/ModuleManager.h"
#include "Misc/Paths.h"
#include "GlobalShader.h"
IMPLEMENT_GAME_MODULE( FCustomShadersDeclarationsModule, CustomShadersDeclarations);
void FCustomShadersDeclarationsModule::StartupModule()
{
// Maps virtual shader source directory to actual shaders directory on disk.
FString ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders/Private"));
AddShaderSourceDirectoryMapping("/CustomShaders", ShaderDirectory);
}
void FCustomShadersDeclarationsModule::ShutdownModule()
{
}
================================================
FILE: Source/CustomShadersDeclarations/Public/CustomShadersDeclarations.h
================================================
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleInterface.h"
#include "Modules/ModuleManager.h"
class CUSTOMSHADERSDECLARATIONS_API FCustomShadersDeclarationsModule : public IModuleInterface
{
public:
static inline FCustomShadersDeclarationsModule& Get()
{
return FModuleManager::LoadModuleChecked<FCustomShadersDeclarationsModule>("CustomShadersDeclarations");
}
static inline bool IsAvailable()
{
return FModuleManager::Get().IsModuleLoaded("CustomShadersDeclarations");
}
public:
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
gitextract_pm01ti6p/
├── .gitignore
├── Config/
│ ├── DefaultEditor.ini
│ ├── DefaultEngine.ini
│ └── DefaultGame.ini
├── Content/
│ ├── Maps/
│ │ └── TestMap.umap
│ ├── Materials/
│ │ └── WhiteNoiseMat.uasset
│ ├── WhiteNoiseCS_Output.uasset
│ └── WhiteNoiseCS_RenderTarget.uasset
├── CustomComputeShader.uproject
├── LICENSE
├── README.md
├── Shaders/
│ └── Private/
│ └── WhiteNoiseCS.usf
└── Source/
├── CustomComputeShader/
│ ├── CustomComputeShader.Build.cs
│ ├── CustomComputeShader.cpp
│ ├── CustomComputeShader.h
│ ├── CustomComputeShaderGameModeBase.cpp
│ ├── CustomComputeShaderGameModeBase.h
│ ├── Private/
│ │ └── WhiteNoiseConsumer.cpp
│ └── Public/
│ └── WhiteNoiseConsumer.h
├── CustomComputeShader.Target.cs
├── CustomComputeShaderEditor.Target.cs
└── CustomShadersDeclarations/
├── CustomShadersDeclarations.Build.cs
├── Private/
│ ├── ComputeShaderDeclaration.cpp
│ ├── ComputeShaderDeclaration.h
│ └── CustomShadersDeclarations.cpp
└── Public/
└── CustomShadersDeclarations.h
SYMBOL INDEX (18 symbols across 9 files)
FILE: Source/CustomComputeShader.Target.cs
class CustomComputeShaderTarget (line 6) | public class CustomComputeShaderTarget : TargetRules
method CustomComputeShaderTarget (line 8) | public CustomComputeShaderTarget( TargetInfo Target) : base(Target)
FILE: Source/CustomComputeShader/CustomComputeShader.Build.cs
class CustomComputeShader (line 5) | public class CustomComputeShader : ModuleRules
method CustomComputeShader (line 7) | public CustomComputeShader(ReadOnlyTargetRules Target) : base(Target)
FILE: Source/CustomComputeShader/CustomComputeShaderGameModeBase.h
function CUSTOMCOMPUTESHADER_API (line 13) | CUSTOMCOMPUTESHADER_API ACustomComputeShaderGameModeBase : public AGameM...
FILE: Source/CustomComputeShader/Public/WhiteNoiseConsumer.h
function CUSTOMCOMPUTESHADER_API (line 8) | CUSTOMCOMPUTESHADER_API AWhiteNoiseConsumer : public APawn
FILE: Source/CustomComputeShaderEditor.Target.cs
class CustomComputeShaderEditorTarget (line 6) | public class CustomComputeShaderEditorTarget : TargetRules
method CustomComputeShaderEditorTarget (line 8) | public CustomComputeShaderEditorTarget( TargetInfo Target) : base(Target)
FILE: Source/CustomShadersDeclarations/CustomShadersDeclarations.Build.cs
class CustomShadersDeclarations (line 5) | public class CustomShadersDeclarations : ModuleRules
method CustomShadersDeclarations (line 7) | public CustomShadersDeclarations(ReadOnlyTargetRules Target) : base(Ta...
FILE: Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp
class FWhiteNoiseCS (line 16) | class FWhiteNoiseCS : public FGlobalShader
method BEGIN_SHADER_PARAMETER_STRUCT (line 28) | BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
method ModifyCompilationEnvironment (line 42) | static inline void ModifyCompilationEnvironment(const FGlobalShaderPer...
class FSceneRenderTargets (line 113) | class FSceneRenderTargets
FILE: Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h
function FWhiteNoiseCSParameters (line 7) | struct FWhiteNoiseCSParameters
function RenderTarget (line 19) | RenderTarget(IORenderTarget)
function class (line 34) | class CUSTOMSHADERSDECLARATIONS_API FWhiteNoiseCSManager
FILE: Source/CustomShadersDeclarations/Public/CustomShadersDeclarations.h
function IsAvailable (line 20) | static inline bool IsAvailable()
Condensed preview — 26 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (24K chars).
[
{
"path": ".gitignore",
"chars": 127,
"preview": "Binaries\nDerivedDataCache\nIntermediate\nSaved\n.vscode\n.vs\n*.VC.db\n*.opensdf\n*.opendb\n*.sdf\n*.sln\n*.suo\n*.xcodeproj\n*.xcwo"
},
{
"path": "Config/DefaultEditor.ini",
"chars": 4,
"preview": "\r\n\r\n"
},
{
"path": "Config/DefaultEngine.ini",
"chars": 667,
"preview": "[/Script/Engine.Engine]\r\n+ActiveGameNameRedirects=(OldGameName=\"TP_Blank\",NewGameName=\"/Script/CustomComputeShader\")\r\n+A"
},
{
"path": "Config/DefaultGame.ini",
"chars": 95,
"preview": "\r\n[/Script/EngineSettings.GeneralProjectSettings]\r\nProjectID=098D2E764A73895DFD1D5EB20AB18FA8\r\n"
},
{
"path": "CustomComputeShader.uproject",
"chars": 429,
"preview": "{\r\n\t\"FileVersion\": 3,\r\n\t\"EngineAssociation\": \"4.24\",\r\n\t\"Category\": \"\",\r\n\t\"Description\": \"\",\r\n\t\"Modules\": [\r\n\t\t{\r\n\t\t\t\"Nam"
},
{
"path": "LICENSE",
"chars": 1072,
"preview": "MIT License\n\nCopyright (c) 2020 Ayoub Khammassi\n\nPermission is hereby granted, free of charge, to any person obtaining a"
},
{
"path": "README.md",
"chars": 681,
"preview": "# CustomComputeShader\n\nA minimal Unreal Engine 4 porject for adding and using a compute shader. I published an article t"
},
{
"path": "Shaders/Private/WhiteNoiseCS.usf",
"chars": 1019,
"preview": "#include \"/Engine/Public/Platform.ush\"\r\nRWTexture2D<float> OutputTexture;\r\nfloat2 Dimensions;\r\nuint TimeStamp;\r\n\r\n\r\nfloa"
},
{
"path": "Source/CustomComputeShader/CustomComputeShader.Build.cs",
"chars": 845,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\nusing UnrealBuildTool;\r\n\r\npublic class CustomComputeShad"
},
{
"path": "Source/CustomComputeShader/CustomComputeShader.cpp",
"chars": 296,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\n#include \"CustomComputeShader.h\"\r\n#include \"Modules/Modu"
},
{
"path": "Source/CustomComputeShader/CustomComputeShader.h",
"chars": 106,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\n#pragma once\r\n\r\n#include \"CoreMinimal.h\"\r\n"
},
{
"path": "Source/CustomComputeShader/CustomComputeShaderGameModeBase.cpp",
"chars": 114,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\n\r\n#include \"CustomComputeShaderGameModeBase.h\"\r\n\r\n"
},
{
"path": "Source/CustomComputeShader/CustomComputeShaderGameModeBase.h",
"chars": 346,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\n#pragma once\r\n\r\n#include \"CoreMinimal.h\"\r\n#include \"Game"
},
{
"path": "Source/CustomComputeShader/Private/WhiteNoiseConsumer.cpp",
"chars": 1650,
"preview": "#include \"WhiteNoiseConsumer.h\"\r\n\r\n#include \"Kismet/GameplayStatics.h\"\r\n#include \"CustomShadersDeclarations/Private/Comp"
},
{
"path": "Source/CustomComputeShader/Public/WhiteNoiseConsumer.h",
"chars": 955,
"preview": "#pragma once\r\n\r\n#include \"CoreMinimal.h\"\r\n#include \"GameFramework/Pawn.h\"\r\n#include \"WhiteNoiseConsumer.generated.h\"\r\n\r\n"
},
{
"path": "Source/CustomComputeShader.Target.cs",
"chars": 442,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\nusing UnrealBuildTool;\r\nusing System.Collections.Generic"
},
{
"path": "Source/CustomComputeShaderEditor.Target.cs",
"chars": 456,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\nusing UnrealBuildTool;\r\nusing System.Collections.Generic"
},
{
"path": "Source/CustomShadersDeclarations/CustomShadersDeclarations.Build.cs",
"chars": 527,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\nusing UnrealBuildTool;\r\n\r\npublic class CustomShadersDecl"
},
{
"path": "Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp",
"chars": 6971,
"preview": "#include \"ComputeShaderDeclaration.h\"\r\n\r\n#include \"GlobalShader.h\"\r\n#include \"ShaderParameterStruct.h\"\r\n#include \"Render"
},
{
"path": "Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h",
"chars": 2159,
"preview": "#pragma once\r\n\r\n#include \"CoreMinimal.h\"\r\n#include \"Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h\"\r\n\r\n//This str"
},
{
"path": "Source/CustomShadersDeclarations/Private/CustomShadersDeclarations.cpp",
"chars": 654,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\n#include \"CustomShadersDeclarations.h\"\r\n#include \"Module"
},
{
"path": "Source/CustomShadersDeclarations/Public/CustomShadersDeclarations.h",
"chars": 688,
"preview": "// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.\r\n\r\n#pragma once\r\n\r\n#include \"CoreMinimal.h\"\r\n\r\n#include \"Mo"
}
]
// ... and 4 more files (download for full content)
About this extraction
This page contains the full source code of the AyoubKhammassi/CustomComputeShaders GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 26 files (19.8 KB), approximately 5.4k tokens, and a symbol index with 18 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.