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.
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
The Static Lighting calculation in UE4 is performed by the Lightmass module (UE4’s integrated GI* engine), and the result of this calculation is stored in each object’s Lightmap, an extra texture map used for storing static light and shadow information.
This post provides a list of useful tips and techniques for improving your UE4 scene setup for an efficient light calculation.
Notes:
The following tips are aimed at achieving a good lighting calculation/solution but they don’t include optimization methods for high performance projects.
Namely, we don’t get into manual Lightmap UV optimizations here.
The following tips don’t take into account the now real-time ray-tracing options that have become available with Nvidia Geforce RTX / DirectX DXR.
Scene Setup:
Delete unseen polygons from your mesh, so they wont waste Lightmap resolution.
* For example, in an interior Archviz project, delete the outer polygons of the walls.
Set the architectural surfaces to cast shadows from both sides: Details > Lighting > Shadow Two Sided
Place “light blockers” around the structure to avoid light licks.
* Wrap the structure on all sides with scaled cubes that have an absolute black material:
Set the “light blockers” to be invisible in rendering:
Scale the Lightmass Importance Volume fit around the structure tightly.
Lightmap Resolution:
Optimize the architectural surfaces (static meshes) Light map resolution.
A higher resolution will allow the Light Map to store more detailed lighting.
The Static Mesh resolution setting is found in: Static Mesh Edior > Details > General Settings > Light Map Resolution:
* This setting can also be overriden at the actor settings by selecting the actor in the map/level and activating: Details > Lighting > Override Lightmap Res
Use the Lightmap Density optimization display mode to inspect the actual Lightmap texel density.
The Lightmap Density display mode also color codes the display to indicate the efficiency of the Lightmap resolution per object (green color being optimal, and warm colors being too dense)
* Note that in many cases of Archviz you may want a higher density than the editor displays as optimal.
Lighmass Settings:
The Lightmass setting are found in: World Settings > Lightmass
Decrease the Volumetric Lightmap Detail Cell Size to increase the light calculation accuracy:
* This will increase the calculation time
Decrease the Indirect Lighting smoothness to get more detailed shadows:
Disable Compress Lightmaps to avoid banding artifacts in the shadow gradient:
Use the Lighting Only display mode to evaluate the lighting solution:
For final quality, set the Light Quality to Production: Build menu > Lighting Quality > Production
* GI – “Global Illumination” is a term referring to indirect light simulation, namely a calculation of how light reflects and bounces between surfaces.
The UE4 First Person template is a good way to start an Architectural virtual tour project, but we first need to “clean” it up, namely, get rid of all the unnecessary objects and settings.
Start with the obvious:
Delete all the cubes and blocks. (Simply select them and press delete)
The quickest way to select all these objects is through the World Outliner window.
Select all the unneeded objects (see image below) and delete them. Note:
I’m intentionally keeping the 4 surrounding wall objects because I want them to serve as invisible barrier objects that will stop the player from wondering of the platform.
So now our level looks like this, with weird static shadows left by the “BigWall” objects that were deleted.
It’s not really critical to fix this at this stage, but if you want to get rid of the weird left-over shadows, simply press the Build button to re-build the lighting, and they will be gone.
Making the walls invisible:
Select the 4 wall objects, and in the Details window, in the Lighting Settings uncheck Cast Shadow,
And under Rendering uncheck Visible.
The level is now clear, and when we press play, we can free roam on the empty stage until we hit the invisible walls.
* You can re-build the lighting to get rid of the walls static shadow.
Time to get dirty!
We now have to get rid if the FPS rifle and shooting setup….
Select the FirstPersonCharacter actor, and in the World Outliner window click Edit FirstPersonCharacter to open the actors Blueprint:
In the FirstPersonCharacter Blueprint, navigate to the Viewport tab so you’l be able to see the mesh components clearly,
And in the actor Components Window on the left, select all the unneeded components, delete them and press the Compile button.
* make sure you don’t select the FirstPersonCamera or any of the inherited components
A list of reported errors will now be displayed in the Compile Results window, because we deleted objects that are referenced by the Blueprint, we will fix this in the next step:
Navigate to the Construction Script tab, Select the AttachComponentToComponent node (currently displaying an error) and delete it.
Navigate to the Event Graph tab, locate the first Event Graph at the top of the Blueprint, this is the Event BeginPlay graph.
Select the 2 Set Hidden in Game nodes (currently displaying an errors) and delete them:
Locate the Spawn projectile node graph at the bottom of the Event Graph,
Select this whole section, delete it and press Compile.
The Event Graph should now look like this, and compilation should be without errors because we deleted all the Blueprint parts that were referencing the deleted actor components:
Almost there..
It’s time to remove the small red targeting cross-hair icon displayed on the screen when playing.
The cross-hair icon is defined in the level’s HUD (Heads Up Display) Blueprint class.
The easiest way to remove it is to simply remove the HUD class from the level.
Note:
The FirstPersonHUD class can be useful to an Archviz project for displaying branding and architectural data on screen so it’s good to keep it in the project. it can later be modified to suit our needs used again (doing that is beyond the scope of this article).
If you wish to edit the HUD Blueprint instead of disconnecting it from the level, you’ll find it in Content > FirstPersonBP > Blueprints > FirstPersonHUD:
To remove the HUD from the level, navigate to the World Settings window,
If it isn’t displayed open it from Settings > World Settings:
In the World Settings window, under Game Mode > Selected GameMode, open the HUD Class drop-down and instead of FirstPersonHUD, choose None.
This will remove the HUD from the level but wont delete it from the project:
Creating HDRI environment backgruond and lighting* in UE4: Note:
Lighting using a panoramic HDRI background is also referred to as IBL – Image Based Lighting.
Import HDRI environment file. Note:
The file must be saved as a *.hdr file and not *.exr because AFAIK that’s the only way UE4 will recognize it as an HDRI environment and encode it as a Texture Cube (cube map)
Enable the HDRIBackdrop plugin:
Go to Edit > Plugins
Type “HDRI” in the search field to locate HDRIBackdrop and enable it.
* You’l have to restart the UE Editor before using the plugin
Drag a Lights > HDRI Backdrop object to your level:
In the HDRIBackdrop details, select the wanted Cubemap:
> Set the HDRIBackdrop‘s Intensity (self explanatory..).
> Rotate the HDRIBackdrop around its Z axis to set the environment’s direction.
> Set the HDRIBackdrop‘s Size.
* Make it larger than your whole scene,
And if Use Camera Projection is unchecked make it also large enough so that noticeable objects in the HDRI image will be distant enough as to not move incorrectly when you strife.
* When Use Camera Projection is activated the Size property has no effect.
> If Use Camera Projection is unchecked, set the Projection Center Z value to define the background image height below which it is projected as a flat ground.
> Lighting Distance Factor defines ground projection area that will appear to receive shadows from your scene objects.
* Set this attribute to 0 in-order to turn off the ground projection shadow.
> Use Camera Projection:
Activate this option to get a traditional infinitely far background with no flat ground surface projection.