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.
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.
To import an external Python module, Add its folder path to the sys.path list, Then import the wanted code.
In this example, there is a Python file: C:\Oded\GoogleDrive\CGL_Studio\CGL_Python\py\cgl_pixel_utils.py Containing a function: cgl_fill_int_range
The following Python code checks the path isn’t already found in sys.path, and if so adds the module path to sys.path, Imports the cgl_fill_int_range function for the cgl_pixel_utils module, And calls the cgl_fill_int_range function:
modulepath = r"C:\Oded\GoogleDrive\CGL_Studio\CGL_Python\py"
if modulepath not in sys.path:
from cgl_pixel_utils import cgl_fill_int_range
To force reloading of an external module, Use the reload function from the built-in imp module. Note that this works with importing full modules and not just specific functions:
modulepath = r"C:\Oded\GoogleDrive\CGL_Studio\CGL_Python\py"
if modulepath not in sys.path:
# Force reload of cgl_pixel_utils:
the function doesn’t return the numeric value of the price, but instead, creates a table (see image below):
This seems like a nice feature.. so what’s the problem? If you need to use the conversion rate within a larger scope calculation, the return value will be the string “Date” instead of a numeric value representing the conversion rate, and that will cause an error:
So.. what’s the solution? The solution is to use the index function to retrieve the wanted value from the table returned by GoogleFinance. In this case index(weird_surprising_tabel,2,2) returns the wanted value:
Separate a mesh to groups by continous parts (elements):
Use the Connectivity SOP node to assign each mesh primitive an integer attribute based on the continuous mesh element in belongs to. This attribute can be named “element” or “part” for example.
Use the GameDev Group by Attribute* node to assign each mesh primitive to a different group according to its “part” attribute (if you named it “part” that is..). Set a group name prefix, like “part_” or “element_”. the node will generate numbered groups per each mesh part like so: “element_0”, “element_1”, “element_1″….
Use this group separation as a filter to create whatever part-selective effect you need.
Note: The linked tutorial details additional ways to set this up. Honestly.. I don’t remember why I ended up using this specific method. If you think this method has disadvantages compared to other, I’ll be very grateful if you comment on this.
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 “Misk/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:
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.
Note: This material setup is using V-Ray 5, but will also work for V-Ray next, And in previous versions, not having the Metallic property, it can be implemented by unchecking Fresnel Reflections and setting the color through the Reflection color. This technique can also be implemented in V-Ray for other 3D software like V-Ray for Maya etc.
The idea is simple: Use a VRayBlendMtl to additively combine 3 anisotropic metallic materials, Each of which reflects a pure primary RGB color, but has a slightly different anisotropic angle. The additive combination creates an anisotropic reflection that “spreads” the color of the spectrum. Note that in this example we use Anisotropic Rotation values of 0, 8, 16, but this may change with different roughness and anisotropy values.
For the materials Diffuse Color property we set levels that will combine to create the general brightness and tint of the metal, and the materials Reflection Color is set to 100% so they will combine to pure white reflection at grazing view angle. For example, if you want the general metallic color to be a yellow RGB: 255, 186, 57, than the first red metallic component material would have a Diffuse Color of 255,0,0, the second green metallic component material would have a Diffuse Color of 0,186,0, and the third material, that adds the blue metallic component would have a Diffuse color of 0,0,57, so the combined blend will have the desired general color. More info about the VRayMtl Metalness parameter