When sampling textures using an HLSL custom node, The UE4 TextureObject input name, will automatically have a sampler object generated named:
<your TextureObject name>sampler
For example, if you named your TextureObject input “tex_in”, the available sampler will be named “tex_insampler”. So the code for sampling the texture will be:
Texture2DSample(tex_in, tex_inSampler, coords);
The following is an example of a simple u-blur custom node code, with 4 node inputs: 1. tex_in – TextureObject 2. coords – float2 3. size – float 4. sample – float
int blur_samples = int(samples * 0.5f);
float3 col = 0.0f;
float2 sample_coords = 0.0f;
for (int i = -blur_samples; i < blur_samples; i ++)
{
sample_coords.x = i * (size / blur_samples * 2);
col += Texture2DSample(tex_in, tex_inSampler, coords + sample_coords ) / (blur_samples * 2);
}
return col;
When having to develop a UE4 project that deals with a tiny world scale, like the whole level being less the 50cm size for example, The following steps may help make the project more easily navigate-able and convenient to work on.
Scale down the camera Icon: UE4 has by default a huge, bulky, opaque camera icon. For a tiny scale project, this camera icon may cover the whole level and be very inconvenient to work with. Select the relevant camera component and scale it down. In my tests, this modified camera matrix isn’t breaking the camera optics in any way, But if you want to have no such scale offsets in your project, you can also replace the camera icon with a suitable small one.
In Editor Preferences > Viewport: Decrease both: Mouse Scroll Camera Speed and Mouse Sensitivity To allow finer navigation at small scale
Note: A global scale conversion factor can be used instead of taking these measures, And in many cases this can be a more practical solution for managing a sub 50cm world, For example, building everything 100X size so that 1 meter will be representing 1 centimeter in your project’s world. But take into account, that if the project demands rendering realistic physical lighting and optics, extra conversions will have to be made to account for the scale conversion factor, so is such cases it may be better to setup a real-world scale project.
Note: This seems like an awkward workaround.. So if I missed something here, and there’s a better method to do this, I’ll be very grateful is you share it in the comments. Also, The following tip is only relevant for the CineCameraActor and won’t work with a regular CameraActor as it has a different built in offset (hopefully, I’ll have time to add this to the post later..)
Replacing the camera icon: Its fairly simple to replace the Camera component’s mesh icon, Just select the component and replace it’s Camera Mesh Static Mesh component with a different static mesh object:
So what’s the problem? The problem is that the default mesh used for the camera icon doesn’t have its natural pivot at the focal point of the camera, but at its bottom somewhere, And there is a hardcoded transform offset that compensates for that and places the icon mesh in a way that has the Icon lens roughly at the actual Camera actor pivot / focal point: * I haven’t found any exposed transform parameter that allows moving the icon itself without moving the camera. So in-order to replace the camera mesh with an alternative icon mesh, and have it be aligned properly to the camera’s pivot / focal point (without changing engine code and building it) the built-in offset must be negatively pre-added to the new mesh model: In this example in Blender, a new icon is modeled facing positive Y, with pre-built offset to compensate for the hardcoded offset in UE. The Camera actor with the alternative Icon:
Note: In this example, I’ve replaced the camera icon with a much smaller model, intentionally, to suite a tiny scale project, You can also scale the icon without replacing the model.
Software: Unreal Engine 4.25 *Also tested on Unreal Engine 5.0.1
Disclaimer: I’m probably the 10th guy that’s documenting these steps on the web, I didn’t come up with this solution myself, I learned it from the sources listed below. The reason I’m documenting this (again) myself is to have a clear source I can come back to for this issue because I’m absolutely incapable of remembering subjects like this…… :-\ If you find inaccuracies in the steps I’m detailing or my explanation, I’ll be very grateful if you share a comment.
In short: AFAIK since version 4.21 UE doesn’t load custom node shader code from your project/Shaders folder by default anymore, but only from the shaders folder in the engine installation, which makes it less practical for developing shaders for specific projects.
Steps for setting the UE project to load shaders from the project folder in UE 4.22:
> The examples here are for a project named: “Tech_Lab”
A. The project must be a C++ project:
So either create a new project, define as such or just create a new C++ class and compile the project with it to convert it to a C++ project. Notes: a. You may need to right click the .uproject file icon and and Generate Visual Studio Project Files for the project to load correctly into Visual Studio and compile. b. You can delete the unneeded C++ class you added after the new settings took place.
B. Create a folder for the shader files:
Typically, it will be called “Shaders” and will be placed in the project root folder.
C. Add the RenderCore module to the project:
This is done by adding string “RenderCore” to array of public dependency modules in the <project>.build.cs file:
Notes: a. In UE 4.21 it should be ShaderCore. b. This addition is needed in-order to compile a new primary project module (next step).
D. Define a custom primary module for your project:
In <project_name>.h file add a new module named F<project_name>Module, with a StartupModule function overrides. Notes: a. We have add an include statement for “Modules/ModuleManager”. b. The <project_name>.h file is located in the /Source/<project_name> folder. c. Some sources state that you also have to override the ShutdownModule function, with an empty override, it works for me without this (maybe its just a mistake..)
E. Implement the function override, and set the custom module as the project primary module:
In <project_name>.cpp file, add the StartupModule override, With the definition of the added shaders path: FString ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders"));
and mapping this new path as “/Project” for conveniently including it: AddShaderSourceDirectoryMapping("/Project", ShaderDirectory);
Last thing to do is to replace “FDefaultGameModuleImpl” with our custom module name in the IMPLEMENT_PRIMARY_GAME_MODULE macro: IMPLEMENT_PRIMARY_GAME_MODULE(FTech_LabModule, Tech_Lab, "Tech_Lab" );
Notes: a. We must include “Misc/Paths” b. Note that the addition of this folder mapping is restricted to versions 4.22 and higher via a compiler directive condition. for version 4.21, you should state “ENGINE_MINOR_VERSION >= 21: Note for UE5: Unreal Engine 5 supports this from the get go so this compiler directive condition should be deleted for this to work.
F. Wrapping up:
After taking these steps and compiling the project. You should be able to include .ush and .usf files stored in <your_ue_project>/Shaders with the “Project” path mapping: include "/Project/test.usf"
That’s it! 🙂
I hope you found this helpful, And if you encountered errors, or inaccuracies, I’ll be grateful if you’ll take the time to comment.
The following is a list of guidelines for preparation and export of 3D content from Blender to Unreal Engine 4 via the FBX file format.
Disclaimer: This is not a formal specification. It’s a list of tips I found to work well in my own experience. * Some of the issues listed here may have already been solved
Blender Scene and model settings:
System units in Blender: Define the scene units in Blender as: Metric unit with 0.01 scale (centimeters) And model your content correctly using centimeter units. * Modeling in 1 meter units may seem to be imported correctly into UE4 but will cause unsolvable problems like a skeletal mesh physics asset having incorrect auto-generated shapes, a problem that in my experience can’t be fixed manually.
Transform: Model your model in Blender facing the -Y world axis, +Z obviously being up (obviously for Blender). * This way the model is aligned to Blender’s views so the front view displays the model’s front etc. Make sure to apply your model’s transformations before export.
Armatures: Make sure the Armature object isn’t named “Armature”. naming or leaving the Blender skeleton named “Armature” will cause the UE4 importer to fail due to “multiple roots”. * Also remember some weird related bug with animation scale incorrectly imported, but can’t confirm this now.. No need for a dedicated root bone in the hierarchy. the Armature object is the root of the bone hierarchy. * See export option below
Texture baking: Set the normal map’s green channel to -Y. * This is not critical at all because if baked as +Y it can easily be fixed in UE4.
Metadata: Blender custom properties import as UE4 asset metadata that can be read by editor scripts for automation purposes. * See export option below
FBX Blender export and UE4 import settings:
I recommend saving an FBX export preset with these settings.
Optional: I prefer the export settings to include only selected objects. * It’s more efficient for me to select the specifics objects I want to export into a single FBX file prior to export, than to delete all the temp / reference / draft objects from the scene. If you want to export Blender custom properties with to the FBX check the “Custom Properties” option
Axes: Blender’s native model/world orientation is model’s forward facing the -Y axis, left side facing +X and of-course up facing +Z. UE4’s native model/world orientation is model’s forward facing the +X axis, left side facing -Y and up facing +Z. There are axis settings in Blender’s FBX export module, that theoretically, should be set like this:
However, in tests I did, The axis settings made no difference when importing to UE4, even when setting intentionally incorrect upside-down axes. Maybe the FBX exporter writes these settings to metadata that the UE4 importer doesn’t read.. From my experience, what’s important is to orient the model correctly in Blender (see above), apply the transformations, And in the UE4 import menu, check the “Force Front XAxis” option:
Geometry: Make sure either “Edge” or “Face” is chosen in the “Smoothing” option to import the mesh’s smooth shading correctly ans avoid a smoothing groups warning on import:
Optional: Depending on how much control you need over the mesh’s tangent space, You may want to check the “Tangent Space” export option, This will make Blender export the full tangent space to the FBX and make UE4 read it from FBX instead of generate it automatically. * For this option to be supported, the mesh geometry must have only triangle or quad polys. In the UE4 import settings, choose the “Import Normals and Tangents” option in “Normal Import Method”:
Armature: Set “Armature FBXNode Type” to “Root”. Uncheck the “Add Leaf Bones” option to avoid adding unneeded end bones. Set bones primary axis as X, and secondary axis as -Z.
Animation: Uncheck “All Actions” to avoid exporting actions that don’t actually belong to the skeleton. * Un-related animations in the FBX can also corrupt the character rest pose in UE. The “NLA Strips” option is useful for exporting a library of animations with the skeleton. * In Blender’s NLA editor, activate the actions you want exported to the FBX.
If you’re interested in taking the first step into Python for 3D software, Or simply would like to browse some script examples, your welcome to visit my Gist page, It contains a useful library of Python code example for Blender, Maya, 3ds max and Unreal engine: https://gist.github.com/CGLion
This post is a summary of the tips given by Epic Games technical-artist Min Oh in his GDC 2017 lecture about improving photo-realism in product visualization, more specifically, how to render high quality surfaces.
I recommend watching the full lecture:
Render sharper reflections by increasing the Cubemap resolution of reflection captures: Project Settings > Engine > Rendering > Reflection > Reflection Capture Resolution
* use powers of 2 values i.e. 256, 512, 1024….
Improve the accuracy of environment lighting by increasing the Cubemap resolution of the Skylight:
* use powers of 2 values i.e. 256, 512, 1024….
Improve screen space effects accuracy like screen space reflections by setting the engine to compute high precision normals for the GBuffer:
Set Project Settings > Engine > Rendering > Optimizations > GBuffer Format to: High Precision Normals
Use a high degree of tessellation (subdivision) for the models pre-import.
Simpy put: Use high quality models.
Improve the surfaces tangent space accuracy, and as a result also the shading/reflection accuracy by setting the model’s static mesh components to encode high precision tangent basis: Static Mesh Editor > Details > LOD 0 > Build Settings > Use High Precision Tangent basis
Creating materials with rich dual specular layers by enabling material clear coat separate normal input: Project Settings > Engine > Rendering > Materials > Clear Coat Enable Second Normal Set the material Shading Model to Clear Coat and use a ClearCoatBottomNormal input node to add a normal map for the underlying layer:
Steps for activating DXR Ray-tracing in a UE4 project:
Project Settings: Platforms > Windows > Targeted RHIs:
Set Default RHI to DirectX 12 * RHI = Rendering Hardware Interface
Project Settings: Engine > Rendering > Ray Tracing:
Check Ray Tracing
* Requires restarting the editor, and may take a while to load the project afterwards..
* I’m actually not sure if the reason for delay in re-launching the project is a full re-build of the lighting or compiling shaders..
Post Process Volume > Rendering Features > Reflections:
Set Type to: Ray Tracing
Post Process Volume > Rendering Features > Ray Tracing Reflections:
Set Max Bounces to more than 1 if needed