ShaderToy Demo - Shader by Inigo Quilez
Built on top of the empty demo project below in a couple minutes.
You just need to convert GLSL to HLSL: https://docs.microsoft.com/en-us/win…hlsl-reference
[shaderproj.zip - Google Drive
](ShaderProject-Shadertoy.zip - Google Drive)
Inigo Quilez Youtube channel: https://www.youtube.com/channel/UCdmAhiG8HQDlz8uyekw4ENw
Inigo Quilez Shadertoy: Shader - Shadertoy BETA
DEMO - empty project Download for 4.24+
https://drive.google.com/open?id=1gz…_v00gJB1nH7nIA
Features fully commented code - Setup two shader files : library/final output
Full code example at end of post
Hello developers community,
I used to write custom shaders and store them locally in my game projects root/ “Shaders” directory, which used to be defined as a virtual shader source path by default until 4.21.
If you’re working in C++ an easy way to add it back - While initiating your C++ project, you’ll have a file implementing your project as a ‘game module’ :
IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, MyUE4Project, "MyUE4Project");
Instead of using ‘FDefaultGameModuleImpl’, you can create your own simple game module and override “StartupModule” and “ShutdownModule” (check ShooterGame project for reference).
If UE 4.21: Add "ShaderCore "as a dependency in your project “xxx.build.cs”, otherwise for UE 4.22+ add “RenderCore” :
4.21:
PublicDependencyModuleNames.AddRange(new string] { "RHI", "ShaderCore", ...}
4.22+:
PublicDependencyModuleNames.AddRange(new string] { "RHI", "RenderCore", ...}
And add back the project “shaders” directory as a potential source for shader files:
void FMyUE4ProjectModule::StartupModule()
{
FString ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders"));
AddShaderSourceDirectoryMapping("/Project", ShaderDirectory);
}
Now you can create a “Shaders” folder at the root of your game project and store your shaders in there !
Tutorial for custom HLSL shaders: https://www.raywenderlich.com/57-unr…aders-tutorial
http://i.imgur.com/MPDbwxBh.jpg
From your project root folder:
ILikeTrains/Source/ILikeTrains/Public/ILikeTrains.h :
```
#pragma once
#include "CoreMinimal.h"
#include "ModuleManager.h"
class FILikeTrainsModule
/* only IModuleInterface necessary if not hosting gamemode in this module */
: public FDefaultGameModuleImpl
{
public:
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
```
ILikeTrains/Source/ILikeTrains/Private/ILikeTrains.cpp :
```
#include "ILikeTrains.h"
#include "Interfaces/IPluginManager.h"
#include "Logging/LogMacros.h"
#include "Misc/Paths.h"
//#define LOCTEXT_NAMESPACE "FILikeTrainsModule"
void FILikeTrainsModule::StartupModule()
{
#if (ENGINE_MINOR_VERSION >= 21)
FString ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders"));
AddShaderSourceDirectoryMapping("/Project", ShaderDirectory);
#endif
}
void FILikeTrainsModule::ShutdownModule()
{
}
IMPLEMENT_PRIMARY_GAME_MODULE(FILikeTrainsModule, ILikeTrains, "ILikeTrains" );
```