├── .gitignore ├── .gitmodules ├── BuildPluginTools └── BuildPlugin │ ├── .gitignore │ ├── BuildOnly420.bat │ ├── Build_RPRPlugin.sh │ ├── Build_RPRPlugin_420.bat │ ├── Build_RPRPlugin_420_DebugGame.bat │ ├── Build_RPRPlugin_423.bat │ ├── Build_RPRPlugin_424.bat │ ├── Build_RPRPlugin_425.bat │ ├── Build_RPRPlugin_All.bat │ ├── Install_PluginToEngine_420.bat │ └── Internal │ ├── Build_RPRPlugin.bat │ ├── Build_RPRPlugin_4_25.bat │ └── Install_PluginToEngine.bat ├── CHANGELOG.md ├── Config ├── DefaultEditor.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── Content ├── .keepme └── Textures │ └── T_TextureNotSupported.uasset ├── Extras └── UpdateBuildVersion │ ├── .gitignore │ └── UpdateBuildVersion │ ├── App.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ └── UpdateBuildVersion.csproj ├── GenerateVisualStudioProject.bat ├── LICENSE.txt ├── Plugins └── RPRPlugin │ ├── Config │ └── FilterPlugin.ini │ ├── RPRPlugin.uplugin │ ├── Resources │ ├── ButtonIcon_40x.png │ └── Icon128.png │ └── Source │ ├── Compatibility │ ├── Private │ │ ├── RPRCompatibility.cpp │ │ ├── RPRCpMaterial.cpp │ │ ├── RPRCpMaterialEditor.cpp │ │ ├── RPRCpStaticMesh.cpp │ │ └── RPRCpTexture2DDynamic.cpp │ ├── Public │ │ ├── RPRCompatibility.h │ │ ├── RPRCpMaterial.h │ │ ├── RPRCpMaterialEditor.h │ │ ├── RPRCpStaticMesh.h │ │ ├── RPRCpStaticMeshMacros.h │ │ └── RPRCpTexture2DDynamic.h │ └── RPRCompatibility.Build.cs │ ├── RPRCore │ ├── Private │ │ ├── Assets │ │ │ └── RPRMaterial.cpp │ │ ├── ImageManager │ │ │ ├── RPRImageManager.cpp │ │ │ └── RPRImagesCache.cpp │ │ ├── Material │ │ │ ├── RPRMaterialHelpers.cpp │ │ │ ├── RPRMaterialMapUV.cpp │ │ │ ├── RPRUberMaterialParameters.cpp │ │ │ ├── RPRXMaterial.cpp │ │ │ ├── RPRXMaterialLibrary.cpp │ │ │ ├── Tools │ │ │ │ ├── MaterialCacheMaker │ │ │ │ │ ├── Factory │ │ │ │ │ │ ├── ParameterFactory.cpp │ │ │ │ │ │ └── ParameterFactory.h │ │ │ │ │ ├── MaterialCacheMaker.cpp │ │ │ │ │ ├── MaterialCacheMaker.h │ │ │ │ │ ├── ParameterArgs.cpp │ │ │ │ │ └── ParameterSetters │ │ │ │ │ │ ├── Bool │ │ │ │ │ │ ├── MaterialBoolParameterSetter.cpp │ │ │ │ │ │ └── MaterialBoolParameterSetter.h │ │ │ │ │ │ ├── Enum │ │ │ │ │ │ ├── MaterialEnumParameterSetter.cpp │ │ │ │ │ │ └── MaterialEnumParameterSetter.h │ │ │ │ │ │ ├── IMaterialParameter.h │ │ │ │ │ │ ├── MaterialCoM │ │ │ │ │ │ ├── MaterialCoMParameterSetter.cpp │ │ │ │ │ │ └── MaterialCoMParameterSetter.h │ │ │ │ │ │ ├── MaterialCoMChannel1 │ │ │ │ │ │ ├── MaterialCoMChannel1ParameterSetter.cpp │ │ │ │ │ │ └── MaterialCoMChannel1ParameterSetter.h │ │ │ │ │ │ ├── MaterialMap │ │ │ │ │ │ ├── MaterialMapParameterSetter.cpp │ │ │ │ │ │ └── MaterialMapParameterSetter.h │ │ │ │ │ │ └── NormalMap │ │ │ │ │ │ ├── NormalMapParameterSetter.cpp │ │ │ │ │ │ └── NormalMapParameterSetter.h │ │ │ │ └── UberMaterialPropertyHelper.cpp │ │ │ ├── TriPlanarSettings.cpp │ │ │ └── UberMaterialParameters │ │ │ │ ├── RPRMaterialBool.cpp │ │ │ │ ├── RPRMaterialCoM.cpp │ │ │ │ ├── RPRMaterialCoMChannel1.cpp │ │ │ │ ├── RPRMaterialEnum.cpp │ │ │ │ ├── RPRMaterialMap.cpp │ │ │ │ ├── RPRMaterialNormalMap.cpp │ │ │ │ └── RPRUberMaterialParameterBase.cpp │ │ ├── RPRCoreErrorHelper.cpp │ │ ├── RPRCoreModule.cpp │ │ ├── RPRCoreSystemResources.cpp │ │ └── RPRXVirtualNode.cpp │ ├── Public │ │ ├── Assets │ │ │ └── RPRMaterial.h │ │ ├── Cache │ │ │ └── RPRImagesCache.h │ │ ├── Enums │ │ │ └── RPRMaterialParameterEnums.h │ │ ├── ImageManager │ │ │ └── RPRImageManager.h │ │ ├── Material │ │ │ ├── MaterialContext.h │ │ │ ├── RPRMaterialHelpers.h │ │ │ ├── RPRMaterialMapUV.h │ │ │ ├── RPRUberMaterialParameters.h │ │ │ ├── RPRXMaterial.h │ │ │ ├── RPRXMaterialLibrary.h │ │ │ ├── Tools │ │ │ │ ├── MaterialCacheMaker │ │ │ │ │ └── ParameterArgs.h │ │ │ │ └── UberMaterialPropertyHelper.h │ │ │ ├── TriPlanarSettings.h │ │ │ └── UberMaterialParameters │ │ │ │ ├── RPRMaterialBool.h │ │ │ │ ├── RPRMaterialCoM.h │ │ │ │ ├── RPRMaterialCoMChannel1.h │ │ │ │ ├── RPRMaterialEnum.h │ │ │ │ ├── RPRMaterialMap.h │ │ │ │ ├── RPRMaterialMapMode.h │ │ │ │ ├── RPRMaterialNormalMap.h │ │ │ │ └── RPRUberMaterialParameterBase.h │ │ ├── RPRCoreErrorHelper.h │ │ ├── RPRCoreModule.h │ │ ├── RPRCoreSystemResources.h │ │ └── RPRXVirtualNode.h │ └── RPRCore.Build.cs │ ├── RPRPlugin │ ├── Private │ │ ├── ImageFilter │ │ │ └── ImageFilter.cpp │ │ ├── RPREditorStyle.cpp │ │ ├── RPRPlugin.cpp │ │ ├── Renderer │ │ │ ├── RPRRendererWorker.cpp │ │ │ └── RPRRendererWorker.h │ │ ├── Scene │ │ │ ├── RPRActor.cpp │ │ │ ├── RPRCameraComponent.cpp │ │ │ ├── RPRLightComponent.cpp │ │ │ ├── RPRScene.cpp │ │ │ ├── RPRSceneComponent.cpp │ │ │ ├── RPRStaticMeshComponent.cpp │ │ │ ├── RPRViewportCameraComponent.cpp │ │ │ ├── UMSControl.cpp │ │ │ ├── URadeonMaterialParser.cpp │ │ │ └── tinyxml2.cpp │ │ ├── Tools │ │ │ ├── FImageSaver.cpp │ │ │ └── FImageSaver.h │ │ └── Viewport │ │ │ ├── RPRViewportClient.cpp │ │ │ ├── RPRViewportClient.h │ │ │ ├── SRPRViewportTabContent.cpp │ │ │ └── SRPRViewportTabContent.h │ ├── Public │ │ ├── ImageFilter │ │ │ └── ImageFilter.h │ │ ├── RPREditorStyle.h │ │ ├── RPRPlugin.h │ │ ├── RPRStats.h │ │ └── Scene │ │ │ ├── RPRActor.h │ │ │ ├── RPRCameraComponent.h │ │ │ ├── RPRLightComponent.h │ │ │ ├── RPRScene.h │ │ │ ├── RPRSceneComponent.h │ │ │ ├── RPRStaticMeshComponent.h │ │ │ ├── RPRViewportCameraComponent.h │ │ │ ├── StaticMeshComponent │ │ │ ├── DelegateHandleManager.h │ │ │ ├── RPRCachedMesh.h │ │ │ └── RPRShape.h │ │ │ ├── UMSControl.h │ │ │ ├── URadeonMaterialParser.h │ │ │ └── tinyxml2.h │ └── RPRPlugin.Build.cs │ ├── RPRPluginVersion │ ├── Private │ │ ├── RPRDynamicLibraryLoader.cpp │ │ └── RPRPluginVersionModule.cpp │ ├── Public │ │ ├── RPRDynamicLibraryLoader.h │ │ ├── RPRPluginVersion.h │ │ └── RPRPluginVersionModule.h │ └── RPRPluginVersion.Build.cs │ ├── RPRTools │ ├── Private │ │ ├── FFrameBuffer.cpp │ │ ├── FPostEffect.cpp │ │ ├── Helpers │ │ │ ├── ContextHelper.cpp │ │ │ ├── GenericGetInfo.cpp │ │ │ ├── RPRCameraHelpers.cpp │ │ │ ├── RPRErrorsHelpers.cpp │ │ │ ├── RPRHelpers.cpp │ │ │ ├── RPRImageHelpers.cpp │ │ │ ├── RPRLightHelpers.cpp │ │ │ ├── RPRMeshHelper.cpp │ │ │ ├── RPRSceneHelpers.cpp │ │ │ ├── RPRSceneStandardizer.cpp │ │ │ ├── RPRShapeHelpers.cpp │ │ │ └── RPRTextureHelpers.cpp │ │ ├── RPRSettings.cpp │ │ └── RPRToolsModule.cpp │ ├── Public │ │ ├── Constants │ │ │ ├── RPRConstants.h │ │ │ └── RPRMaterialNodeParameterNames.h │ │ ├── Enums │ │ │ └── RPREnums.h │ │ ├── FFrameBuffer.h │ │ ├── FPostEffect.h │ │ ├── Helpers │ │ │ ├── ContextHelper.h │ │ │ ├── GenericGetInfo.h │ │ │ ├── RPRCameraHelpers.h │ │ │ ├── RPRErrorsHelpers.h │ │ │ ├── RPRHelpers.h │ │ │ ├── RPRImageHelpers.h │ │ │ ├── RPRLightHelpers.h │ │ │ ├── RPRMeshHelper.h │ │ │ ├── RPRSceneHelpers.h │ │ │ ├── RPRSceneStandardizer.h │ │ │ ├── RPRShapeHelpers.h │ │ │ └── RPRTextureHelpers.h │ │ ├── Miscs │ │ │ └── NumericRestriction.h │ │ ├── RPRSettings.h │ │ ├── RPRToolsModule.h │ │ └── Typedefs │ │ │ └── RPRTypedefs.h │ └── RPRTools.Build.cs │ └── SDK │ ├── Private │ ├── RPR_SDKModule.cpp │ └── RprTools.cpp │ ├── Public │ ├── RPR_SDKModule.h │ └── RprTools.h │ └── RPR_SDK.Build.cs ├── README.md ├── RPR.uproject └── Source ├── RPR.Target.cs ├── RPR ├── RPR.Build.cs ├── RPR.cpp ├── RPR.h ├── RPRGameModeBase.cpp ├── RPRGameModeBase.h ├── actorRPRHandler.cpp └── actorRPRHandler.h ├── RPREditor.Target.cs └── testimg.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Unreal Engine 2 | *.uasset 3 | *.umap 4 | *.COPY 5 | 6 | # Visual Studio 2015 user specific files 7 | .vs/ 8 | 9 | # Visual Studio 2015 database file 10 | *.VC.db 11 | 12 | # Compiled Object files 13 | *.slo 14 | *.lo 15 | *.o 16 | *.obj 17 | 18 | # Precompiled Headers 19 | *.gch 20 | *.pch 21 | 22 | # Compiled Dynamic libraries 23 | *.so 24 | *.dylib 25 | # *.dll 26 | 27 | # Fortran module files 28 | *.mod 29 | 30 | # Compiled Static libraries 31 | *.lai 32 | *.la 33 | *.a 34 | # *.lib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | *.ipa 41 | 42 | # These project files can be generated by the engine 43 | *.xcodeproj 44 | *.xcworkspace 45 | *.sln 46 | *.suo 47 | *.opensdf 48 | *.sdf 49 | *.VC.db 50 | *.VC.opendb 51 | 52 | # Binary Files 53 | RprsImporter/Binaries/* 54 | Plugins/RPRPlugin/Binaries/* 55 | 56 | # Compiled source files for the engine to use 57 | Intermediate/* 58 | Plugins/RPRPlugin/Intermediate/* 59 | 60 | # Don't need duplicate sources or binaries from the packaged plugin 61 | bin/* 62 | Binaries/* 63 | 64 | Saved/ 65 | /BuildPluginTools/PluginStaging/ 66 | 67 | # ignore linux generated files 68 | .kdev4/ 69 | .vscode/ 70 | CMakeLists.txt 71 | Makefile 72 | RPR.code-workspace 73 | RPR.kdev4 74 | RPR.pro 75 | RPR.workspace 76 | RPRCodeCompletionFolders.txt 77 | RPRCodeLitePreProcessor.txt 78 | RPRConfig.pri 79 | RPRDefines.pri 80 | RPRHeader.pri 81 | RPRIncludes.pri 82 | RPRSource.pri 83 | 84 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Plugins/RPRPlugin/ThirdParty/RadeonProRenderSDK"] 2 | path = Plugins/RPRPlugin/ThirdParty/RadeonProRenderSDK 3 | url = git@github.com:GPUOpen-LibrariesAndSDKs/RadeonProRenderSDK 4 | [submodule "Plugins/RPRPlugin/ThirdParty/gli"] 5 | path = Plugins/RPRPlugin/ThirdParty/gli 6 | url = git@github.com:feniksa/gli.git 7 | branch = master 8 | [submodule "Plugins/RPRPlugin/ThirdParty/glm"] 9 | path = Plugins/RPRPlugin/ThirdParty/glm 10 | url = git@github.com:g-truc/glm.git 11 | branch = master 12 | [submodule "Plugins/RPRPlugin/ThirdParty/RadeonProImageProcessingSDK"] 13 | path = Plugins/RPRPlugin/ThirdParty/RadeonProImageProcessingSDK 14 | url = git@github.com:GPUOpen-LibrariesAndSDKs/RadeonImageFilter.git 15 | branch = master 16 | [submodule "Plugins/RPRPlugin/ThirdParty/RadeonProRenderSharedComponents"] 17 | path = Plugins/RPRPlugin/ThirdParty/RadeonProRenderSharedComponents 18 | url = git@github.com:GPUOpen-LibrariesAndSDKs/RadeonProRenderSharedComponents.git 19 | branch = master 20 | -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/.gitignore: -------------------------------------------------------------------------------- 1 | Stage/ 2 | output_log.txt -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/BuildOnly420.bat: -------------------------------------------------------------------------------- 1 | "c:\Program Files\Epic Games\UE_4.20\Engine\Binaries\DotNET\UnrealBuildTool.exe" UE4Editor Win64 Development -plugin=c:\workspace\RadeonProRenderUE\BuildPluginTools\BuildPlugin\Stage\UE4_4.20\Shipping\RPRPlugin\HostProject\Plugins\RPRPlugin\RPRPlugin.uplugin -iwyu -precompile -nosharedpch -noubtmakefiles -receipt=c:\workspace\RadeonProRenderUE\BuildPluginTools\BuildPlugin\Stage\UE4_4.20\Shipping\RPRPlugin\HostProject\Plugins\RPRPlugin\Binaries\Win64\UE4Editor.target -NoHotReload -log="c:\log\uebuild.log" -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ue4version=418 4 | 5 | echo Build... 6 | echo Use UnrealEngine UE4_PATH environment variable : $UE4_Path 7 | "$UE4_Path\Engine\Build\BatchFiles\RunUAT.bat" BuildPlugin -Plugin="$PWD\..\Plugins\RPRPlugin\RPRPlugin.uplugin" -nop4 -utf8output -pak -distribution -compile -package="$PWD\PluginStaging\UE4_$ue4version\RPRPlugin" -Rocket 8 | echo Build completed. -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin_420.bat: -------------------------------------------------------------------------------- 1 | Internal\Build_RPRPlugin.bat 4.20 -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin_420_DebugGame.bat: -------------------------------------------------------------------------------- 1 | call Internal\Build_RPRPlugin.bat 4.20 -debug -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin_423.bat: -------------------------------------------------------------------------------- 1 | Internal\Build_RPRPlugin.bat 4.23 -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin_424.bat: -------------------------------------------------------------------------------- 1 | Internal\Build_RPRPlugin.bat 4.24 -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin_425.bat: -------------------------------------------------------------------------------- 1 | Internal\Build_RPRPlugin_4_25.bat 4.25 -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Build_RPRPlugin_All.bat: -------------------------------------------------------------------------------- 1 | Build_RPRPlugin_420.bat 2 | Build_RPRPlugin_423.bat 3 | Build_RPRPlugin_424.bat 4 | Build_RPRPlugin_425.bat -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Install_PluginToEngine_420.bat: -------------------------------------------------------------------------------- 1 | call Internal\Install_PluginToEngine.bat 4.20 2 | pause -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Internal/Build_RPRPlugin.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | if not "%2"=="" ( 5 | if "%2" == "-debug" ( 6 | goto :SetDebugMode 7 | ) 8 | ) 9 | goto :SetShippingMode 10 | 11 | 12 | :SetDebugMode 13 | echo Make Debug build 14 | set Mode=Debug 15 | set UATArgs=-clientconfig=DebugGame 16 | goto :FindUE4InstallationDirectory 17 | 18 | :SetShippingMode 19 | echo Make Shipping build 20 | set Mode=Shipping 21 | set UATArgs=-distribution 22 | goto :FindUE4InstallationDirectory 23 | 24 | 25 | :FindUE4InstallationDirectory 26 | rem Find UE4 installation directory 27 | set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%1" 28 | set VALUE_NAME=InstalledDirectory 29 | 30 | echo Search in Windows Register for : %KEY_NAME% 31 | 32 | set UE4Path="" 33 | 34 | FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`reg query %KEY_NAME% /v %VALUE_NAME%`) DO ( 35 | 36 | echo %%C 37 | echo Installation found at : %%C 38 | CALL :LabelStartBuild "%%C" %1 39 | ) 40 | goto :LabelExit 41 | 42 | rem Build! 43 | :LabelStartBuild 44 | echo. 45 | echo == Start Build %2... == 46 | echo. 47 | echo Use UnrealEngine UE4_PATH environment variable : %1 48 | set OutputPath=%CD%\Stage\UE4_%2\%Mode%\RPRPlugin 49 | CALL %1\Engine\Build\BatchFiles\RunUAT.bat BuildPlugin -Plugin="%CD%\..\..\Plugins\RPRPlugin\RPRPlugin.uplugin" -nop4 -utf8output -pak -compile -package="%OutputPath%" -Rocket -TargetPlatforms=Win64 %UATArgs% 50 | if not %errorlevel% == 0 goto :LabelExit 51 | echo. 52 | echo == Build completed == 53 | echo. 54 | 55 | 56 | :Clean 57 | echo == Clean == 58 | del /f /s /q "%OutputPath%\Intermediate" 1>nul 59 | rmdir /s /q "%OutputPath%\Intermediate" 60 | goto :PostBuild 61 | 62 | :PostBuild 63 | echo == Post build == 64 | if %Mode%=="Shipping" ( 65 | rem echo Delete PDB files... 66 | rem del "%OutputPath%\Binaries\Win64\*.pdb" 67 | echo Delete library files... 68 | del "%OutputPath%\RPRPlugin\Binaries\Win64\*.lib" 69 | echo Delete sources... 70 | del /f /s /q "%OutputPath%\Sources" 1>nul 71 | rmdir /s /q "%OutputPath%\Sources" 72 | echo Deletes completed. 73 | ) 74 | goto :LabelExit 75 | 76 | :LabelExit 77 | ENDLOCAL 78 | 79 | pause -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Internal/Build_RPRPlugin_4_25.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | if not "%2"=="" ( 5 | if "%2" == "-debug" ( 6 | goto :SetDebugMode 7 | ) 8 | ) 9 | goto :SetShippingMode 10 | 11 | 12 | :SetDebugMode 13 | echo Make Debug build 14 | set Mode=Debug 15 | set UATArgs=-clientconfig=DebugGame 16 | goto :FindUE4InstallationDirectory 17 | 18 | :SetShippingMode 19 | echo Make Shipping build 20 | set Mode=Shipping 21 | set UATArgs=-distribution 22 | goto :FindUE4InstallationDirectory 23 | 24 | 25 | :FindUE4InstallationDirectory 26 | rem Find UE4 installation directory 27 | set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%1" 28 | set VALUE_NAME=InstalledDirectory 29 | 30 | echo Search in Windows Register for : %KEY_NAME% 31 | 32 | set UE4Path="" 33 | 34 | FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`reg query %KEY_NAME% /v %VALUE_NAME%`) DO ( 35 | 36 | echo %%C 37 | echo Installation found at : %%C 38 | CALL :LabelStartBuild "%%C" %1 39 | ) 40 | goto :LabelExit 41 | 42 | rem Build! 43 | :LabelStartBuild 44 | echo. 45 | echo == Start Build %2... == 46 | echo. 47 | echo Use UnrealEngine UE4_PATH environment variable : %1 48 | set OutputPath=%CD%\Stage\UE4_%2\%Mode%\RPRPlugin 49 | CALL %1\Engine\Build\BatchFiles\RunUAT.bat BuildPlugin -Plugin="%CD%\..\..\Plugins\RPRPlugin\RPRPlugin.uplugin" -nop4 -utf8output -pak -package="%OutputPath%" -Rocket -TargetPlatforms=Win64 %UATArgs% 50 | if not %errorlevel% == 0 goto :LabelExit 51 | echo. 52 | echo == Build completed == 53 | echo. 54 | 55 | 56 | :Clean 57 | echo == Clean == 58 | del /f /s /q "%OutputPath%\Intermediate" 1>nul 59 | rmdir /s /q "%OutputPath%\Intermediate" 60 | goto :PostBuild 61 | 62 | :PostBuild 63 | echo == Post build == 64 | if %Mode%=="Shipping" ( 65 | rem echo Delete PDB files... 66 | rem del "%OutputPath%\Binaries\Win64\*.pdb" 67 | echo Delete library files... 68 | del "%OutputPath%\RPRPlugin\Binaries\Win64\*.lib" 69 | echo Delete sources... 70 | del /f /s /q "%OutputPath%\Sources" 1>nul 71 | rmdir /s /q "%OutputPath%\Sources" 72 | echo Deletes completed. 73 | ) 74 | goto :LabelExit 75 | 76 | :LabelExit 77 | ENDLOCAL 78 | 79 | pause -------------------------------------------------------------------------------- /BuildPluginTools/BuildPlugin/Internal/Install_PluginToEngine.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :FindUE4InstallationDirectory 4 | rem Find UE4 installation directory 5 | set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%1" 6 | set VALUE_NAME=InstalledDirectory 7 | 8 | echo Search in Windows Register for : %KEY_NAME% 9 | 10 | set UE4Path="" 11 | 12 | FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`reg query %KEY_NAME% /v %VALUE_NAME%`) DO ( 13 | 14 | echo %%C 15 | echo Installation found at : %%C 16 | CALL :StartInstallation "%%C" %1 17 | ) 18 | goto :EOF 19 | 20 | :StartInstallation 21 | set "UE4Path=%1" 22 | set "Mode=%2" 23 | set "PluginPath=%CD%\..\..\Plugins\RPRPlugin" 24 | set "EnginePluginPath=%UE4Path%\Engine\Plugins\Experimental" 25 | set "EngineRPRPluginDirectory=%EnginePluginPath%\RPRPlugin" 26 | 27 | echo Delete existing files... 28 | rmdir /S /Q %EngineRPRPluginDirectory% 29 | 30 | echo Copy Binaries... 31 | xcopy /syik %PluginPath%\Binaries\*.dll %EngineRPRPluginDirectory%\Binaries\ 32 | xcopy /syik %PluginPath%\Binaries\*.pdb %EngineRPRPluginDirectory%\Binaries\ 33 | xcopy /syik %PluginPath%\Binaries\*.modules %EngineRPRPluginDirectory%\Binaries\ 34 | 35 | echo Copy Config... 36 | xcopy /syik %PluginPath%\Config %EngineRPRPluginDirectory%\Config\ 37 | 38 | echo Copy Content... 39 | xcopy /syik %PluginPath%\Content %EngineRPRPluginDirectory%\Content\ 40 | 41 | echo Copy Resources... 42 | xcopy /syik %PluginPath%\Resources %EngineRPRPluginDirectory%\Resources\ 43 | 44 | echo Copy ThirdParties 45 | xcopy /syik %PluginPath%\ThirdParty\*.dll %EngineRPRPluginDirectory%\ThirdParty\ 46 | 47 | echo Copy Plugin descriptor 48 | xcopy /yk %PluginPath%\RPRPlugin.uplugin %EngineRPRPluginDirectory%\RPRPlugin.uplugin* 49 | 50 | echo Copies completed. 51 | 52 | echo Explorer to %EngineRPRPluginDirectory% 53 | call explorer "%EngineRPRPluginDirectory%" -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Version 1.0 2 | 3 | ## New Features: 4 | 5 | - The Plug-in has been completely rewritten with support for Unreal Engine 4.20–4.23 and 4.24. The Plug-in for 4.24 is separate because of API changes in Unreal Engine. 6 | 7 | - This Plug-in is intended for higher quality rendering of Unreal Engine scenes with native lights and materials. The lights and materials are translated during the render time to Radeon ProRender. Please use it with your existing Unreal Engine scenes. 8 | 9 | - Rendering uses OpenCL path tracing or Vulkan for Low, Medium, and High quality view modes. 10 | 11 | - Machine Learning Denoising is now available to be enabled in the render view 12 | 13 | - Adaptive sampling now automatically focuses render samples on areas of noise in the rendered image. -------------------------------------------------------------------------------- /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | [/Script/EngineSettings.GeneralProjectSettings] 2 | ProjectID=2A2CDBDF461E9F057001FFA6534A5616 3 | -------------------------------------------------------------------------------- /Content/.keepme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderUE/f9cf8d32fad1e7bb157c3ff63aa14cc5a8bd00df/Content/.keepme -------------------------------------------------------------------------------- /Content/Textures/T_TextureNotSupported.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderUE/f9cf8d32fad1e7bb157c3ff63aa14cc5a8bd00df/Content/Textures/T_TextureNotSupported.uasset -------------------------------------------------------------------------------- /Extras/UpdateBuildVersion/.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | UpdateBuildVersion/obj 3 | UpdateBuildVersion/bin -------------------------------------------------------------------------------- /Extras/UpdateBuildVersion/UpdateBuildVersion/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Extras/UpdateBuildVersion/UpdateBuildVersion/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | using System.Reflection; 18 | using System.Runtime.CompilerServices; 19 | using System.Runtime.InteropServices; 20 | 21 | // General Information about an assembly is controlled through the following 22 | // set of attributes. Change these attribute values to modify the information 23 | // associated with an assembly. 24 | [assembly: AssemblyTitle("UpdateBuildVersion")] 25 | [assembly: AssemblyDescription("")] 26 | [assembly: AssemblyConfiguration("")] 27 | [assembly: AssemblyCompany("")] 28 | [assembly: AssemblyProduct("UpdateBuildVersion")] 29 | [assembly: AssemblyCopyright("Copyright © 2018")] 30 | [assembly: AssemblyTrademark("")] 31 | [assembly: AssemblyCulture("")] 32 | 33 | // Setting ComVisible to false makes the types in this assembly not visible 34 | // to COM components. If you need to access a type in this assembly from 35 | // COM, set the ComVisible attribute to true on that type. 36 | [assembly: ComVisible(false)] 37 | 38 | // The following GUID is for the ID of the typelib if this project is exposed to COM 39 | [assembly: Guid("3df6eb3b-9b4a-4ab0-a83f-16229061112a")] 40 | 41 | // Version information for an assembly consists of the following four values: 42 | // 43 | // Major Version 44 | // Minor Version 45 | // Build Number 46 | // Revision 47 | // 48 | // You can specify all the values or you can default the Build and Revision Numbers 49 | // by using the '*' as shown below: 50 | // [assembly: AssemblyVersion("1.0.*")] 51 | [assembly: AssemblyVersion("1.0.0.0")] 52 | [assembly: AssemblyFileVersion("1.0.0.0")] 53 | -------------------------------------------------------------------------------- /GenerateVisualStudioProject.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET LOCAL 3 | 4 | :FindUE4InstallationDirectory 5 | rem Find UE4 installation directory 6 | set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\4.20" 7 | set VALUE_NAME=InstalledDirectory 8 | 9 | echo Search in Windows Register for : %KEY_NAME% 10 | 11 | set UE4Path="" 12 | 13 | FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`reg query %KEY_NAME% /v %VALUE_NAME%`) DO ( 14 | 15 | echo %%C 16 | echo Installation found at : %%C 17 | call :GenerateVisualStudioProject "%%C" 18 | ) 19 | goto :LabelExit 20 | 21 | :GenerateVisualStudioProject 22 | call %1\Engine\Binaries\DotNET\UnrealBuildTool.exe -projectfiles -project="%CD%\RPR.uproject" -game 23 | 24 | :LabelExit 25 | ENDLOCAL 26 | 27 | pause -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Config/FilterPlugin.ini: -------------------------------------------------------------------------------- 1 | [FilterPlugin] 2 | ; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and 3 | ; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. 4 | ; 5 | ; Examples: 6 | ; /README.txt 7 | ; /Extras/... 8 | ; /Binaries/ThirdParty/*.dll 9 | 10 | /ThirdParty/.../*.dll 11 | /Documentations/... -------------------------------------------------------------------------------- /Plugins/RPRPlugin/RPRPlugin.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "0.7", 5 | "FriendlyName": "RPRPlugin", 6 | "Description": "Radeon Pro Renderer plugin for Unreal Engine 4", 7 | "Category": "Rendering", 8 | "CreatedBy": "AMD Inc.", 9 | "CreatedByURL": "https://pro.radeon.com/en/software/prorender/", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "https://support.amd.com/en-us", 13 | "CanContainContent": false, 14 | "IsBetaVersion": true, 15 | "Installed": false, 16 | "PreBuildSteps": 17 | { 18 | "Win64": [ 19 | "echo Pre build step...", 20 | "if exist \"$(PluginDir)\\Build\\$(TargetPlatform)\\UpdateBuildVersion.exe\" (\"$(PluginDir)\\Build\\$(TargetPlatform)\\UpdateBuildVersion.exe\" \"$(PluginDir)\\Source\\RPRPluginVersion\\Public\\RPRPluginVersion.h\")" 21 | ] 22 | }, 23 | "Modules": [ 24 | { 25 | "Name": "RPRPluginVersion", 26 | "Type": "Runtime", 27 | "LoadingPhase": "PostConfigInit" 28 | }, 29 | { 30 | "Name": "RPRCompatibility", 31 | "Type": "Runtime", 32 | "LoadingPhase": "Default", 33 | "WhitelistPlatforms": [ "Win64", "Linux" ] 34 | }, 35 | { 36 | "Name": "RPR_SDK", 37 | "Type": "Runtime", 38 | "LoadingPhase": "Default", 39 | "WhitelistPlatforms": [ "Win64", "Linux" ] 40 | }, 41 | { 42 | "Name": "RPRTools", 43 | "Type": "Runtime", 44 | "LoadingPhase": "Default", 45 | "WhitelistPlatforms": [ "Win64", "Linux" ] 46 | }, 47 | { 48 | "Name": "RPRCore", 49 | "Type": "Runtime", 50 | "LoadingPhase": "Default", 51 | "WhitelistPlatforms": [ "Win64", "Linux" ] 52 | }, 53 | { 54 | "Name": "RPRPlugin", 55 | "Type": "Runtime", 56 | "LoadingPhase": "Default", 57 | "WhitelistPlatforms": [ "Win64", "Linux" ] 58 | }, 59 | ] 60 | } 61 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Resources/ButtonIcon_40x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderUE/f9cf8d32fad1e7bb157c3ff63aa14cc5a8bd00df/Plugins/RPRPlugin/Resources/ButtonIcon_40x.png -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderUE/f9cf8d32fad1e7bb157c3ff63aa14cc5a8bd00df/Plugins/RPRPlugin/Resources/Icon128.png -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Private/RPRCompatibility.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRCompatibility.h" 18 | 19 | void FRPRCompatibility::StartupModule() {} 20 | void FRPRCompatibility::ShutdownModule() {} 21 | 22 | IMPLEMENT_MODULE(FRPRCompatibility, RPRCompatibility); 23 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Private/RPRCpMaterial.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRCpMaterial.h" 18 | 19 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Private/RPRCpMaterialEditor.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #if WITH_EDITOR 18 | 19 | #include "RPRCpMaterialEditor.h" 20 | 21 | #if ENGINE_MINOR_VERSION == 18 22 | 23 | FName FRPRCpMaterialEditor::GetMaterialExpressionInputName(UMaterialExpression* MaterialExpression, int32 InputIndex) 24 | { 25 | return (*MaterialExpression->GetInputName(InputIndex)); 26 | } 27 | 28 | 29 | #elif ENGINE_MINOR_VERSION >= 19 30 | 31 | 32 | FName FRPRCpMaterialEditor::GetMaterialExpressionInputName(UMaterialExpression* MaterialExpression, int32 InputIndex) 33 | { 34 | return (MaterialExpression->GetInputName(InputIndex)); 35 | } 36 | 37 | 38 | #endif // ENGINE_MINOR_VERSIOn 39 | 40 | #endif // WITH_EDITOR 41 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Private/RPRCpTexture2DDynamic.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRCpTexture2DDynamic.h" 18 | #include "Engine/Texture2DDynamic.h" 19 | 20 | #if ENGINE_MINOR_VERSION < 20 21 | 22 | UTexture2DDynamic* FRPRCpTexture2DDynamic::Create(int32 SizeX, int32 SizeY, const FCreateInfo& CreateInfo) 23 | { 24 | return (UTexture2DDynamic::Create(SizeX, SizeY, CreateInfo.Format, CreateInfo.bIsResolveTarget)); 25 | } 26 | 27 | #elif ENGINE_MINOR_VERSION >= 20 28 | 29 | UTexture2DDynamic* FRPRCpTexture2DDynamic::Create(int32 SizeX, int32 SizeY, const FCreateInfo& CreateInfo) 30 | { 31 | FTexture2DDynamicCreateInfo nativeCreateInfo( 32 | CreateInfo.Format, 33 | CreateInfo.bIsResolveTarget, 34 | CreateInfo.bSRGB, 35 | CreateInfo.Filter, 36 | CreateInfo.SamplerAddressMode 37 | ); 38 | return (UTexture2DDynamic::Create(SizeX, SizeY, nativeCreateInfo)); 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Public/RPRCompatibility.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Modules/ModuleManager.h" 20 | #include "Runtime/Launch/Resources/Version.h" 21 | 22 | class FRPRCompatibility : public IModuleInterface 23 | { 24 | public: 25 | 26 | virtual ~FRPRCompatibility() {} 27 | 28 | /** IModuleInterface implementation */ 29 | virtual void StartupModule() override; 30 | virtual void ShutdownModule() override; 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Public/RPRCpMaterial.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "RPRCompatibility.h" 19 | 20 | class RPRCOMPATIBILITY_API FRPRCpMaterial 21 | { 22 | public: 23 | 24 | template 25 | static const FName& GetParameterName(const TEditorParam& ParameterValue); 26 | 27 | }; 28 | 29 | 30 | #if ENGINE_MINOR_VERSION == 18 31 | 32 | template 33 | const FName& FRPRCpMaterial::GetParameterName(const TEditorParam& ParameterValue) 34 | { 35 | return (ParameterValue.ParameterName); 36 | } 37 | 38 | #elif ENGINE_MINOR_VERSION >= 19 39 | 40 | template 41 | const FName& FRPRCpMaterial::GetParameterName(const TEditorParam& ParameterValue) 42 | { 43 | return (ParameterValue.ParameterInfo.Name); 44 | } 45 | 46 | #endif // ENGINE_MINOR_VERSION 47 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Public/RPRCpMaterialEditor.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #if WITH_EDITOR 20 | 21 | #include "RPRCompatibility.h" 22 | #include "Runtime/Launch/Resources/Version.h" 23 | #include "Materials/MaterialExpression.h" 24 | 25 | class RPRCOMPATIBILITY_API FRPRCpMaterialEditor 26 | { 27 | public: 28 | 29 | static FName GetMaterialExpressionInputName(UMaterialExpression* MaterialExpression, int32 InputIndex); 30 | 31 | }; 32 | 33 | 34 | 35 | #endif // WITH_EDITOR 36 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Public/RPRCpStaticMesh.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "RPRCompatibility.h" 19 | #include "StaticMeshResources.h" 20 | #include "Math/TransformCalculus2D.h" 21 | #include "Rendering/PositionVertexBuffer.h" 22 | #include "Rendering/StaticMeshVertexBuffer.h" 23 | 24 | class RPRCOMPATIBILITY_API FRPRCpStaticMesh 25 | { 26 | public: 27 | 28 | static FPositionVertexBuffer& GetPositionVertexBuffer(const FStaticMeshLODResources& StaticMeshLODResource); 29 | static const FPositionVertexBuffer& GetPositionVertexBufferConst(const FStaticMeshLODResources& StaticMeshLODResource); 30 | 31 | static FStaticMeshVertexBuffer& GetStaticMeshVertexBuffer(const FStaticMeshLODResources& StaticMeshLODResource); 32 | static const FStaticMeshVertexBuffer& GetStaticMeshVertexBufferConst(const FStaticMeshLODResources& StaticMeshLODResource); 33 | 34 | static FColorVertexBuffer& GetColorVertexBuffer(const FStaticMeshLODResources& StaticMeshLODResource); 35 | static const FColorVertexBuffer& GetColorVertexBufferConst(const FStaticMeshLODResources& StaticMeshLODResource); 36 | 37 | static FVertexBufferRHIRef& GetTexCoordVertexBufferRHI(FStaticMeshVertexBuffer& VertexBuffer); 38 | static int32 GetTexCoordBufferSize(FStaticMeshVertexBuffer& VertexBuffer); 39 | 40 | static uint8* AllocateAndCopyTexCoordDatas(FStaticMeshVertexBuffer& VertexBuffer); 41 | static void TransformUV_RenderThread(const FTransform2D& NewTransform, int32 UVChannel, FStaticMeshVertexBuffer& VertexBuffer, uint8* InitialDatas); 42 | }; 43 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Public/RPRCpStaticMeshMacros.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Runtime/Launch/Resources/Version.h" 20 | 21 | #if ENGINE_MINOR_VERSION == 18 22 | 23 | #define SELECT_UV_TYPE(bIsHighPrecisionTangentBais, bIsHigPrecisionUVs, NumTexCoords, ...) \ 24 | SELECT_STATIC_MESH_VERTEX_TYPE(bIsHighPrecisionTangentBais, bIsHigPrecisionUVs, NumTexCoords, { typedef VertexType UVType; __VA_ARGS__ }) \ 25 | 26 | #elif ENGINE_MINOR_VERSION >= 19 27 | 28 | // Macro to select the UVType according to the precisions of UV in a FStaticMeshVertexBuffer 29 | #define SELECT_UV_TYPE(bIsHighPrecisionTangentBais, bIsHigPrecisionUVs, NumTexCoords, ...) \ 30 | { \ 31 | if (bIsHigPrecisionUVs) \ 32 | { \ 33 | typedef TStaticMeshVertexUVsDatum::UVsTypeT> UVType; \ 34 | __VA_ARGS__ \ 35 | } \ 36 | else \ 37 | { \ 38 | typedef TStaticMeshVertexUVsDatum::UVsTypeT> UVType; \ 39 | __VA_ARGS__ \ 40 | } \ 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/Public/RPRCpTexture2DDynamic.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "RPRCompatibility.h" 19 | #include "PixelFormat.h" 20 | #include "Engine/Texture.h" 21 | #include "RHIDefinitions.h" 22 | 23 | class RPRCOMPATIBILITY_API FRPRCpTexture2DDynamic 24 | { 25 | public: 26 | 27 | struct FCreateInfo 28 | { 29 | EPixelFormat Format; 30 | bool bIsResolveTarget; 31 | bool bSRGB; 32 | TextureFilter Filter; 33 | ESamplerAddressMode SamplerAddressMode; 34 | }; 35 | 36 | public: 37 | 38 | static UTexture2DDynamic* Create(int32 SizeX, int32 SizeY, const FCreateInfo& CreateInfo); 39 | 40 | }; 41 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/Compatibility/RPRCompatibility.Build.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | using UnrealBuildTool; 18 | 19 | public class RPRCompatibility : ModuleRules 20 | { 21 | public RPRCompatibility(ReadOnlyTargetRules Target) : base(Target) 22 | { 23 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 24 | DefineIncludesAndDependencies(Target); 25 | } 26 | 27 | void DefineIncludesAndDependencies(ReadOnlyTargetRules Target) 28 | { 29 | PrivateIncludePaths.AddRange( 30 | new string[] { 31 | "Compatibility/Public", 32 | // ... add public include paths required here ... 33 | } 34 | ); 35 | 36 | 37 | PrivateIncludePaths.AddRange( 38 | new string[] { 39 | "Compatibility/Private" 40 | // ... add other private include paths required here ... 41 | } 42 | ); 43 | 44 | PublicDependencyModuleNames.AddRange( 45 | new string[] 46 | { 47 | "Core", 48 | // "Launch", 49 | // ... add other public dependencies that you statically link with here ... 50 | } 51 | ); 52 | 53 | 54 | PrivateDependencyModuleNames.AddRange( 55 | new string[] 56 | { 57 | "CoreUObject", 58 | "Engine", 59 | "RHI", 60 | // ... add private dependencies that you statically link with here ... 61 | } 62 | ); 63 | 64 | if (Target.bBuildEditor) 65 | { 66 | PublicDependencyModuleNames.AddRange( 67 | new string[] 68 | { 69 | "UnrealEd" 70 | } 71 | ); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Assets/RPRMaterial.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Assets/RPRMaterial.h" 18 | 19 | URPRMaterial::URPRMaterial() 20 | : bShouldCacheBeRebuild(true) 21 | { 22 | 23 | } 24 | 25 | #if WITH_EDITOR 26 | 27 | void URPRMaterial::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) 28 | { 29 | Super::PostEditChangeProperty(PropertyChangedEvent); 30 | 31 | UProperty* memberProperty = PropertyChangedEvent.MemberProperty; 32 | if (memberProperty != nullptr && memberProperty->GetName() == GET_MEMBER_NAME_STRING_CHECKED(URPRMaterial, MaterialParameters)) 33 | { 34 | MarkMaterialDirty(); 35 | } 36 | } 37 | 38 | #endif 39 | 40 | void URPRMaterial::MarkMaterialDirty() 41 | { 42 | bShouldCacheBeRebuild = true; 43 | OnRPRMaterialChangedEvent.Broadcast(this); 44 | } 45 | 46 | void URPRMaterial::ResetMaterialDirtyFlag() 47 | { 48 | bShouldCacheBeRebuild = false; 49 | } 50 | 51 | bool URPRMaterial::IsMaterialDirty() const 52 | { 53 | return (bShouldCacheBeRebuild); 54 | } 55 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/ImageManager/RPRImagesCache.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Cache/RPRImagesCache.h" 18 | #include "Typedefs/RPRTypedefs.h" 19 | #include "Helpers/RPRHelpers.h" 20 | 21 | namespace RPR 22 | { 23 | FImagesCache::~FImagesCache() 24 | { 25 | ReleaseAll(); 26 | } 27 | 28 | void FImagesCache::Add(UTexture* Texture, FImagePtr Image) 29 | { 30 | RemoveDeprecatedImages(); 31 | 32 | loadedImages.Add(Texture, Image); 33 | } 34 | 35 | void FImagesCache::Release(UTexture* Texture) 36 | { 37 | RemoveDeprecatedImages(); 38 | 39 | FImagePtr image = Get(Texture); 40 | if (image.IsValid()) 41 | { 42 | image.Reset(); 43 | } 44 | } 45 | 46 | void FImagesCache::ReleaseAll() 47 | { 48 | loadedImages.Empty(); 49 | } 50 | 51 | RPR::FImagePtr FImagesCache::Get(UTexture* Texture) 52 | { 53 | RPR::FImagePtr* imgPtr = loadedImages.Find(Texture); 54 | return imgPtr != nullptr ? *imgPtr : nullptr; 55 | } 56 | 57 | void FImagesCache::RemoveDeprecatedImages() 58 | { 59 | for (auto it = loadedImages.CreateIterator() ; it ; ++it) 60 | { 61 | if (!it.Key().IsValid() || !it.Value().IsValid()) 62 | { 63 | loadedImages.Remove(it.Key()); 64 | } 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/RPRMaterialMapUV.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/RPRMaterialMapUV.h" 18 | #include "RadeonProRender.h" 19 | 20 | TMap FRPRMaterialMapUV::TextureUVModeToRPRValue({ 21 | {ETextureUVMode::None, 0}, 22 | {ETextureUVMode::Planar, RPR_MATERIAL_NODE_UVTYPE_PLANAR}, 23 | {ETextureUVMode::Cylindrical, RPR_MATERIAL_NODE_UVTYPE_CYLINDICAL}, 24 | {ETextureUVMode::Spherical, RPR_MATERIAL_NODE_UVTYPE_SPHERICAL}, 25 | {ETextureUVMode::Projection, RPR_MATERIAL_NODE_UVTYPE_PROJECT}, 26 | {ETextureUVMode::Triplanar, RPR_MATERIAL_NODE_UV_TRIPLANAR} 27 | }); 28 | 29 | FRPRMaterialMapUV::FRPRMaterialMapUV() 30 | : UVMode(ETextureUVMode::None) 31 | , Rotation(0.0f) 32 | , UVWeight(0.0f) 33 | , Threshold(0.5f, 0.5f, 0.5f) 34 | , XAxis(1.0f, 0.0f, 0.0f) 35 | , ZAxis(0.0f, 0.0f, 1.0f) 36 | , Scale(1.0f, 1.0f) 37 | { 38 | } 39 | 40 | uint8 FRPRMaterialMapUV::GetRPRValueFromTextureUVMode() const 41 | { 42 | return TextureUVModeToRPRValue[UVMode]; 43 | } 44 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/Factory/ParameterFactory.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/Factory/ParameterFactory.h" 18 | #include "Material/Tools/UberMaterialPropertyHelper.h" 19 | 20 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoMChannel1/MaterialCoMChannel1ParameterSetter.h" 21 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoM/MaterialCoMParameterSetter.h" 22 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialMap/MaterialMapParameterSetter.h" 23 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/NormalMap/NormalMapParameterSetter.h" 24 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/Enum/MaterialEnumParameterSetter.h" 25 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/Bool/MaterialBoolParameterSetter.h" 26 | 27 | namespace RPRX 28 | { 29 | namespace MaterialParameter 30 | { 31 | TMap FFactory::Map; 32 | 33 | void FFactory::InitializeMap() 34 | { 35 | #define ADD_TO_FACTORY_CHECK_CLASS(ClassName, ParameterSetterClass) \ 36 | static_assert(TIsClass::Value, "Class doesn't exist!"); \ 37 | RegisterParameterSetter(#ClassName); 38 | 39 | ADD_TO_FACTORY_CHECK_CLASS(FRPRMaterialCoMChannel1, FMaterialCoMChannel1ParameterSetter); 40 | ADD_TO_FACTORY_CHECK_CLASS(FRPRMaterialCoM, FMaterialCoMParameterSetter); 41 | ADD_TO_FACTORY_CHECK_CLASS(FRPRMaterialNormalMap, FNormalMapParameterSetter); 42 | ADD_TO_FACTORY_CHECK_CLASS(FRPRMaterialMap, FMaterialMapParameterSetter); 43 | ADD_TO_FACTORY_CHECK_CLASS(FRPRMaterialEnum, FMaterialEnumParameterSetter); 44 | ADD_TO_FACTORY_CHECK_CLASS(FRPRMaterialBool, FMaterialBoolParameterSetter); 45 | } 46 | 47 | void FFactory::InitializeMapIfRequired() 48 | { 49 | if (Map.Num() == 0) 50 | { 51 | InitializeMap(); 52 | } 53 | } 54 | 55 | TSharedPtr FFactory::Create(UProperty* Property) 56 | { 57 | InitializeMapIfRequired(); 58 | 59 | FString propertyNameType = FUberMaterialPropertyHelper::GetPropertyTypeName(Property); 60 | 61 | FParameterCreator* creator = Map.Find(*propertyNameType); 62 | return (creator != nullptr ? (*creator)() : nullptr); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/Factory/ParameterFactory.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "UObject/UnrealType.h" 20 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/IMaterialParameter.h" 21 | 22 | namespace RPRX 23 | { 24 | namespace MaterialParameter 25 | { 26 | class FFactory 27 | { 28 | 29 | typedef TSharedPtr(*FParameterCreator)(); 30 | 31 | public: 32 | 33 | static TSharedPtr Create(UProperty* Property); 34 | 35 | template 36 | static void RegisterParameterSetter(const FName& PropertyTypeName); 37 | 38 | private: 39 | 40 | static void InitializeMap(); 41 | static void InitializeMapIfRequired(); 42 | 43 | template 44 | static TSharedPtr InstantiateParameterType(); 45 | 46 | private: 47 | 48 | static TMap Map; 49 | }; 50 | 51 | 52 | template 53 | void FFactory::RegisterParameterSetter(const FName& PropertyTypeName) 54 | { 55 | Map.Add(PropertyTypeName, &FFactory::InstantiateParameterType); 56 | } 57 | 58 | template 59 | TSharedPtr FFactory::InstantiateParameterType() 60 | { 61 | return MakeShareable(new ParameterSetterType()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/MaterialCacheMaker.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Assets/RPRMaterial.h" 20 | #include "Typedefs/RPRTypedefs.h" 21 | #include "Material/MaterialContext.h" 22 | #include "Material/Tools/MaterialCacheMaker/ParameterArgs.h" 23 | 24 | namespace RPRX 25 | { 26 | DECLARE_DELEGATE_RetVal_FourParams(RPR::FResult, FUberMaterialParametersPropertyVisitor, FRPRUberMaterialParameters&, UScriptStruct*, UProperty*, RPR::FRPRXMaterialPtr) 27 | 28 | class FMaterialCacheMaker 29 | { 30 | public: 31 | 32 | FMaterialCacheMaker(RPR::FMaterialContext InMaterialContent, URPRMaterial* InRPRMaterial); 33 | 34 | RPR::FRPRXMaterialPtr CacheUberMaterial(); 35 | bool UpdateUberMaterialParameters(RPR::FRPRXMaterialPtr InOutMaterial); 36 | 37 | private: 38 | 39 | RPR::FResult BrowseUberMaterialParameters(FUberMaterialParametersPropertyVisitor Visitor, RPR::FRPRXMaterialPtr OutMaterial); 40 | RPR::FResult ApplyUberMaterialParameter(FRPRUberMaterialParameters& Parameters, UScriptStruct* ParametersStruct, 41 | UProperty* ParameterProperty, RPR::FRPRXMaterialPtr InOutMaterial); 42 | 43 | private: 44 | 45 | RPR::FMaterialContext MaterialContext; 46 | URPRMaterial* RPRMaterial; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterArgs.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/ParameterArgs.h" 18 | #include "Material/RPRUberMaterialParameters.h" 19 | #include "Material/Tools/UberMaterialPropertyHelper.h" 20 | #include "Assets/RPRMaterial.h" 21 | 22 | namespace RPRX 23 | { 24 | namespace MaterialParameter 25 | { 26 | 27 | FArgs::FArgs( 28 | FRPRUberMaterialParameters& InParameters, 29 | UProperty* InProperty, 30 | RPR::FImageManagerPtr InImageManager, 31 | URPRMaterial* InOwnerMaterial, 32 | RPR::FMaterialContext& InMaterialContext, 33 | RPR::FRPRXMaterialPtr InMaterial) 34 | : Parameters(InParameters) 35 | , Property(InProperty) 36 | , OwnerMaterial(InOwnerMaterial) 37 | , MaterialContext(InMaterialContext) 38 | , Material(InMaterial) 39 | , ImageManager(InImageManager) 40 | {} 41 | 42 | FRPRUberMaterialParameterBase* FArgs::GetMaterialParameterBase() 43 | { 44 | return FUberMaterialPropertyHelper::GetParameterBaseFromProperty(&Parameters, Property); 45 | } 46 | 47 | uint32 FArgs::GetRprxParam() 48 | { 49 | const FRPRUberMaterialParameterBase* materialParameter = GetMaterialParameterBase(); 50 | return (materialParameter->GetRprxParamType()); 51 | } 52 | 53 | bool FArgs::CanUseParam() 54 | { 55 | const FRPRUberMaterialParameterBase* materialParameter = GetMaterialParameterBase(); 56 | return (materialParameter->CanUseParameter()); 57 | } 58 | 59 | bool FArgs::HasCustomParameterApplier() 60 | { 61 | const FRPRUberMaterialParameterBase* materialParameter = GetMaterialParameterBase(); 62 | return (materialParameter->HasCustomParameterApplier()); 63 | } 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/Bool/MaterialBoolParameterSetter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/Bool/MaterialBoolParameterSetter.h" 18 | #include "Material/UberMaterialParameters/RPRMaterialBool.h" 19 | #include "RPRCoreModule.h" 20 | 21 | namespace RPRX 22 | { 23 | 24 | void FMaterialBoolParameterSetter::ApplyParameterX(MaterialParameter::FArgs& SetterParameters) 25 | { 26 | const FRPRMaterialBool* materialBool = SetterParameters.GetDirectParameter(); 27 | if (!materialBool) 28 | return; 29 | 30 | SetterParameters.Material->SetMaterialParameterBool(SetterParameters.GetRprxParam(), materialBool->bIsEnabled); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/Bool/MaterialBoolParameterSetter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/IMaterialParameter.h" 20 | 21 | namespace RPRX 22 | { 23 | class FMaterialBoolParameterSetter : public IMaterialParameter 24 | { 25 | public: 26 | virtual void ApplyParameterX(MaterialParameter::FArgs& SetterParameters) override; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/Enum/MaterialEnumParameterSetter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/Enum/MaterialEnumParameterSetter.h" 18 | #include "Material/UberMaterialParameters/RPRMaterialEnum.h" 19 | #include "RPRCoreModule.h" 20 | 21 | namespace RPRX 22 | { 23 | 24 | void FMaterialEnumParameterSetter::ApplyParameterX(MaterialParameter::FArgs& SetterParameters) 25 | { 26 | const FRPRMaterialEnum* materialEnum = SetterParameters.GetDirectParameter(); 27 | SetterParameters.Material->SetMaterialParameterUInt(SetterParameters.GetRprxParam(), materialEnum->EnumValue); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/Enum/MaterialEnumParameterSetter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/IMaterialParameter.h" 20 | 21 | namespace RPRX 22 | { 23 | class FMaterialEnumParameterSetter : public IMaterialParameter 24 | { 25 | public: 26 | virtual void ApplyParameterX(MaterialParameter::FArgs& SetterParameters) override; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/IMaterialParameter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterArgs.h" 20 | 21 | namespace RPRX 22 | { 23 | class IMaterialParameter 24 | { 25 | public: 26 | virtual ~IMaterialParameter() {} 27 | virtual void ApplyParameterX(MaterialParameter::FArgs& SetterParameters) = 0; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoM/MaterialCoMParameterSetter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoM/MaterialCoMParameterSetter.h" 18 | #include "Material/RPRMaterialHelpers.h" 19 | #include "Material/MaterialContext.h" 20 | #include "Material/UberMaterialParameters/RPRMaterialMap.h" 21 | #include "Material/UberMaterialParameters/RPRMaterialCoM.h" 22 | #include "RPRCoreModule.h" 23 | 24 | namespace RPRX 25 | { 26 | 27 | void FMaterialCoMParameterSetter::ApplyParameterX(MaterialParameter::FArgs& SetterParameters) 28 | { 29 | const FRPRMaterialCoM* materialMap = SetterParameters.GetDirectParameter(); 30 | 31 | if (materialMap->Mode == ERPRMaterialMapMode::Texture) 32 | { 33 | ApplyTextureParameter(SetterParameters); 34 | } 35 | else 36 | { 37 | RPR::FMaterialContext& materialContext = SetterParameters.MaterialContext; 38 | 39 | SetterParameters.Material->SetMaterialParameterColor(SetterParameters.GetRprxParam(), materialMap->Constant); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoM/MaterialCoMParameterSetter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialMap/MaterialMapParameterSetter.h" 20 | 21 | namespace RPRX 22 | { 23 | 24 | class FMaterialCoMParameterSetter : public FMaterialMapParameterSetter 25 | { 26 | public: 27 | virtual void ApplyParameterX(MaterialParameter::FArgs& SetterParameters); 28 | }; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoMChannel1/MaterialCoMChannel1ParameterSetter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoMChannel1/MaterialCoMChannel1ParameterSetter.h" 18 | #include "Material/UberMaterialParameters/RPRMaterialCoMChannel1.h" 19 | #include "RPRCoreModule.h" 20 | 21 | namespace RPRX 22 | { 23 | 24 | void FMaterialCoMChannel1ParameterSetter::ApplyParameterX(MaterialParameter::FArgs& SetterParameters) 25 | { 26 | const FRPRMaterialCoMChannel1* materialMap = SetterParameters.GetDirectParameter(); 27 | 28 | if (materialMap->Mode == ERPRMaterialMapMode::Texture) 29 | { 30 | ApplyTextureParameter(SetterParameters); 31 | } 32 | else 33 | { 34 | RPR::FMaterialContext& materialContext = SetterParameters.MaterialContext; 35 | 36 | switch (materialMap->RPRInterpretationMode) 37 | { 38 | case ERPRMCoMapC1InterpretationMode::AsFloat: 39 | SetterParameters.Material->SetMaterialParameterFloat(SetterParameters.GetRprxParam(), materialMap->Constant); 40 | break; 41 | 42 | case ERPRMCoMapC1InterpretationMode::AsFloat4: 43 | SetterParameters.Material->SetMaterialParameterFloats( 44 | SetterParameters.GetRprxParam(), 45 | materialMap->Constant, 46 | materialMap->Constant, 47 | materialMap->Constant, 48 | materialMap->Constant); 49 | break; 50 | 51 | default: 52 | break; 53 | } 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoMChannel1/MaterialCoMChannel1ParameterSetter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialMap/MaterialMapParameterSetter.h" 20 | 21 | 22 | namespace RPRX 23 | { 24 | 25 | class FMaterialCoMChannel1ParameterSetter : public FMaterialMapParameterSetter 26 | { 27 | public: 28 | virtual void ApplyParameterX(MaterialParameter::FArgs& SetterParameters) override; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialMap/MaterialMapParameterSetter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/IMaterialParameter.h" 20 | #include "Material/RPRMaterialMapUV.h" 21 | #include "Typedefs/RPRTypedefs.h" 22 | 23 | namespace RPRX 24 | { 25 | 26 | class FMaterialMapParameterSetter : public IMaterialParameter 27 | { 28 | public: 29 | void ApplyParameterX(MaterialParameter::FArgs& SetterParameters) override; 30 | 31 | protected: 32 | 33 | bool ApplyTextureParameter(MaterialParameter::FArgs& SetterParameters); 34 | bool ApplyUVSettings(MaterialParameter::FArgs& SetterParameters, RPR::FMaterialNode ImageMaterialNode); 35 | bool CreateSimpleUVNodeData(MaterialParameter::FArgs& SetterParameters, const FRPRMaterialMapUV& UVSettings, RPR::FMaterialNode& OutMaterialNode); 36 | 37 | virtual RPR::FResult CreateImageNodeFromTexture(MaterialParameter::FArgs& SetterParameters, RPR::FImagePtr& OutImage, RPR::FMaterialNode& OutMaterialNode, RPR::FMaterialNode& OutImageNode); 38 | 39 | }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/NormalMap/NormalMapParameterSetter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/NormalMap/NormalMapParameterSetter.h" 18 | #include "Material/RPRMaterialHelpers.h" 19 | #include "Material/MaterialContext.h" 20 | #include "Typedefs/RPRTypedefs.h" 21 | #include "RPRCoreModule.h" 22 | #include "Material/UberMaterialParameters/RPRMaterialMap.h" 23 | #include "Material/UberMaterialParameters/RPRMaterialNormalMap.h" 24 | 25 | namespace RPRX 26 | { 27 | RPR::FResult FNormalMapParameterSetter::CreateImageNodeFromTexture(MaterialParameter::FArgs& SetterParameters, RPR::FImagePtr& OutImage, RPR::FMaterialNode& OutMaterialNode, RPR::FMaterialNode& OutImageNode) 28 | { 29 | RPR::FMaterialContext& materialContext = SetterParameters.MaterialContext; 30 | 31 | RPR::FMaterialNode materialNode = nullptr; 32 | RPR::FMaterialNode imageNode = nullptr; 33 | 34 | const FRPRMaterialNormalMap* materialMap = SetterParameters.GetDirectParameter(); 35 | if (materialMap->Texture == nullptr || !SetterParameters.ImageManager.IsValid()) 36 | { 37 | OutImage.Reset(); 38 | OutMaterialNode = nullptr; 39 | OutImageNode = nullptr; 40 | return RPR_SUCCESS; 41 | } 42 | 43 | RPR::FResult status = RPR_SUCCESS; 44 | 45 | switch (materialMap->Mode) 46 | { 47 | case ENormalMapMode::Bump: 48 | { 49 | status = RPR::FMaterialHelpers::CreateBumpMap( 50 | materialContext.RPRContext, 51 | materialContext.MaterialSystem, 52 | *SetterParameters.ImageManager.Get(), 53 | materialMap->Texture, materialMap->BumpScale, 54 | OutImage, OutMaterialNode, OutImageNode); 55 | } 56 | break; 57 | 58 | case ENormalMapMode::Normal: 59 | default: 60 | { 61 | status = RPR::FMaterialHelpers::CreateNormalMap( 62 | materialContext.RPRContext, 63 | materialContext.MaterialSystem, 64 | *SetterParameters.ImageManager.Get(), 65 | materialMap->Texture, 66 | OutImage, OutMaterialNode, OutImageNode); 67 | } 68 | break; 69 | } 70 | 71 | return status; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/NormalMap/NormalMapParameterSetter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialMap/MaterialMapParameterSetter.h" 20 | 21 | namespace RPRX 22 | { 23 | 24 | class FNormalMapParameterSetter : public FMaterialMapParameterSetter 25 | { 26 | protected: 27 | virtual RPR::FResult CreateImageNodeFromTexture(MaterialParameter::FArgs& SetterParameters, RPR::FImagePtr& OutImage, RPR::FMaterialNode& OutMaterialNode, RPR::FMaterialNode& OutImageNode) override; 28 | }; 29 | 30 | } -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/Tools/UberMaterialPropertyHelper.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/Tools/UberMaterialPropertyHelper.h" 18 | #include "Templates/UnrealTypeTraits.h" 19 | #include "UObject/EnumProperty.h" 20 | #include "UObject/UnrealType.h" 21 | 22 | FString FUberMaterialPropertyHelper::GetPropertyTypeName(const UProperty* Property) 23 | { 24 | if (Property->IsA()) 25 | { 26 | return (TNameOf::GetName()); 27 | } 28 | 29 | return (Property->GetCPPType()); 30 | } 31 | 32 | FRPRUberMaterialParameterBase* FUberMaterialPropertyHelper::GetParameterBaseFromProperty(FRPRUberMaterialParameters* MaterialParameters, const UProperty* Property) 33 | { 34 | if (!IsPropertyValidUberParameterProperty(Property)) 35 | return nullptr; 36 | 37 | return (Property->ContainerPtrToValuePtr(MaterialParameters)); 38 | } 39 | 40 | bool FUberMaterialPropertyHelper::IsPropertyValidUberParameterProperty(const UProperty* Property) 41 | { 42 | const UStructProperty* structPropertyPtr = Cast(Property); 43 | if (structPropertyPtr != nullptr) 44 | { 45 | const UStruct* topStruct = GetTopStructProperty(structPropertyPtr->Struct); 46 | return (topStruct == FRPRUberMaterialParameterBase::StaticStruct()); 47 | } 48 | return (false); 49 | } 50 | 51 | const UStruct* FUberMaterialPropertyHelper::GetTopStructProperty(const UStruct* Struct) 52 | { 53 | return ( 54 | Struct->GetSuperStruct() == nullptr ? 55 | Struct : 56 | GetTopStructProperty(Struct->GetSuperStruct()) 57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/TriPlanarSettings.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/TriPlanarSettings.h" 18 | 19 | FTriPlanarSettings::FTriPlanarSettings() 20 | : bUseTriPlanar(false) 21 | , Scale(100.0f) 22 | , Angle(0.0f) 23 | {} 24 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRMaterialBool.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRMaterialBool.h" 18 | 19 | FRPRMaterialBool::FRPRMaterialBool( 20 | const FString& InXmlParamName, 21 | uint32 InRprxParamID, 22 | ESupportMode InPreviewSupportMode, 23 | bool DefaultValue, 24 | FCanUseParameter InCanUseParameter) 25 | : FRPRUberMaterialParameterBase(InXmlParamName, InRprxParamID, InPreviewSupportMode, InCanUseParameter) 26 | , bIsEnabled(DefaultValue) 27 | {} 28 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRMaterialCoM.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRMaterialCoM.h" 18 | 19 | FRPRMaterialCoM::FRPRMaterialCoM(const FString& InXmlParamName, uint32 InRprxParamID, ESupportMode InPreviewSupportMode, float UniformConstant, FCanUseParameter InCanUseParameter) 20 | : FRPRMaterialMap(InXmlParamName, InRprxParamID, InPreviewSupportMode, InCanUseParameter) 21 | , Constant(FLinearColor(UniformConstant, UniformConstant, UniformConstant, UniformConstant)) 22 | , Mode(ERPRMaterialMapMode::Constant) 23 | { 24 | } 25 | 26 | FRPRMaterialCoM::FRPRMaterialCoM() 27 | : Mode(ERPRMaterialMapMode::Constant) 28 | {} 29 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRMaterialCoMChannel1.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRMaterialCoMChannel1.h" 18 | 19 | FRPRMaterialCoMChannel1::FRPRMaterialCoMChannel1( 20 | const FString& InXmlParamName, 21 | uint32 InRprxParamID, 22 | ESupportMode InPreviewSupportMode, 23 | float InConstantValue, 24 | ERPRMCoMapC1InterpretationMode InMode, 25 | FCanUseParameter InCanUseParameter) 26 | : FRPRMaterialMap(InXmlParamName, InRprxParamID, InPreviewSupportMode, InCanUseParameter) 27 | , Constant(InConstantValue) 28 | , Mode(ERPRMaterialMapMode::Constant) 29 | , RPRInterpretationMode(InMode) 30 | { 31 | } 32 | 33 | #if WITH_EDITOR 34 | 35 | FNumericRestriction& FRPRMaterialCoMChannel1::GetConstantRestriction() 36 | { 37 | return (ConstantRestriction); 38 | } 39 | 40 | const FNumericRestriction& FRPRMaterialCoMChannel1::GetConstantRestriction() const 41 | { 42 | return (ConstantRestriction); 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRMaterialEnum.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRMaterialEnum.h" 18 | 19 | FRPRMaterialEnum::FRPRMaterialEnum(const FString& InXmlParamName, uint32 InRprxParamID, ESupportMode InPreviewSupportMode, FCanUseParameter InCanUseParameter) 20 | : FRPRUberMaterialParameterBase(InXmlParamName, InRprxParamID, InPreviewSupportMode, InCanUseParameter) 21 | {} 22 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRMaterialMap.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRMaterialMap.h" 18 | 19 | FRPRMaterialMap::FRPRMaterialMap( 20 | const FString& InXmlParamName, 21 | uint32 InRprxParamID, 22 | ESupportMode InPreviewSupportMode, 23 | FCanUseParameter InCanUseParameter, 24 | FApplyParameter InApplyParameterDelegate) 25 | : FRPRUberMaterialParameterBase( 26 | InXmlParamName, 27 | InRprxParamID, 28 | InPreviewSupportMode, 29 | InCanUseParameter, 30 | InApplyParameterDelegate 31 | ) 32 | {} 33 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRMaterialNormalMap.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRMaterialNormalMap.h" 18 | 19 | FRPRMaterialNormalMap::FRPRMaterialNormalMap( 20 | const FString& InXmlParamName, 21 | uint32 InRprxParamID, 22 | ESupportMode InPreviewSupportMode, 23 | FCanUseParameter InCanUseParameter /*= FCanUseParameter()*/, 24 | FApplyParameter InApplyParameterDelegate /*= FApplyParameter()*/) 25 | : FRPRMaterialMap(InXmlParamName, InRprxParamID, InPreviewSupportMode, InCanUseParameter, InApplyParameterDelegate) 26 | , Mode(ENormalMapMode::Normal) 27 | , BumpScale(1.0f) 28 | { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/Material/UberMaterialParameters/RPRUberMaterialParameterBase.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Material/UberMaterialParameters/RPRUberMaterialParameterBase.h" 18 | 19 | FRPRUberMaterialParameterBase::FRPRUberMaterialParameterBase() 20 | : RprxParamType(INDEX_NONE) 21 | {} 22 | 23 | FRPRUberMaterialParameterBase::FRPRUberMaterialParameterBase( 24 | const FString& InParamName, 25 | unsigned int InRprxParamType, 26 | ESupportMode InPreviewSupportMode, 27 | FCanUseParameter InCanUseParameter, 28 | FApplyParameter InApplyParameterDelegate) 29 | : ParamName(InParamName) 30 | , RprxParamType(InRprxParamType) 31 | , SupportMode(InPreviewSupportMode) 32 | , CanUseParameterDelegate(InCanUseParameter) 33 | , ApplyParameterDelegate(InApplyParameterDelegate) 34 | {} 35 | 36 | unsigned int FRPRUberMaterialParameterBase::GetRprxParamType() const 37 | { 38 | return (RprxParamType); 39 | } 40 | 41 | const FString& FRPRUberMaterialParameterBase::GetParameterName() const 42 | { 43 | return (ParamName); 44 | } 45 | 46 | FString FRPRUberMaterialParameterBase::GetPropertyName(UProperty* Property) const 47 | { 48 | return (Property->GetName()); 49 | } 50 | 51 | FString FRPRUberMaterialParameterBase::GetPropertyTypeName(UProperty* Property) const 52 | { 53 | return (Property->GetCPPType()); 54 | } 55 | 56 | bool FRPRUberMaterialParameterBase::CanUseParameter() const 57 | { 58 | return (CanUseParameterDelegate.IsBound() ? CanUseParameterDelegate.Execute(this) : true); 59 | } 60 | 61 | bool FRPRUberMaterialParameterBase::HasCustomParameterApplier() const 62 | { 63 | return ApplyParameterDelegate.IsBound(); 64 | } 65 | 66 | void FRPRUberMaterialParameterBase::ApplyParameter(RPRX::MaterialParameter::FArgs& SetterParameters) 67 | { 68 | ApplyParameterDelegate.ExecuteIfBound(SetterParameters); 69 | } 70 | 71 | bool FRPRUberMaterialParameterBase::IsPreviewSupported() const 72 | { 73 | return (SupportMode == ESupportMode::FullySupported); 74 | } 75 | 76 | bool FRPRUberMaterialParameterBase::IsPropertySupported() const 77 | { 78 | return (SupportMode != ESupportMode::NotSupported); 79 | } 80 | 81 | void FRPRUberMaterialParameterBase::SetAdditionalInfoText(const FText& Text) 82 | { 83 | AdditionalInfoText = Text; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/RPRCoreErrorHelper.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRCoreErrorHelper.h" 18 | #include "Helpers/RPRErrorsHelpers.h" 19 | #include "RPRCoreSystemResources.h" 20 | #include "RPRCoreModule.h" 21 | 22 | void FRPRCoreErrorHelper::LogLastError() 23 | { 24 | RPR::FContext rprContext = IRPRCore::GetResources()->GetRPRContext(); 25 | RPR::Error::LogLastError(rprContext); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/RPRCoreModule.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRCoreModule.h" 18 | #include "Modules/ModuleManager.h" 19 | #include "RPR_SDKModule.h" 20 | 21 | DEFINE_LOG_CATEGORY(LogRPRCore) 22 | DEFINE_LOG_CATEGORY(LogRPRCore_Steps) 23 | 24 | void IRPRCore::StartupModule() 25 | { 26 | check(FRPR_SDKModule::IsLoaded()); 27 | if (FRPR_SDKModule::IsSDKLoadValid()) 28 | { 29 | Resources = MakeShareable(new FRPRCoreSystemResources); 30 | } 31 | } 32 | 33 | void IRPRCore::ShutdownModule() 34 | { 35 | if (Resources.IsValid()) 36 | { 37 | Resources->Shutdown(); 38 | Resources.Reset(); 39 | } 40 | } 41 | 42 | IMPLEMENT_MODULE( IRPRCore, RPRCore ) 43 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Private/RPRXVirtualNode.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRXVirtualNode.h" 18 | #include "Math/Color.h" 19 | 20 | namespace RPR 21 | { 22 | 23 | VirtualNode::VirtualNode(FString aID, EVirtualNode aType) 24 | : id(aID) 25 | , type(aType) 26 | , rprNode(nullptr) 27 | , constant{} 28 | , vectorSize(3) 29 | , isTextureLoaded(false) 30 | {} 31 | 32 | void VirtualNode::SetData(float r, float g, float b, float a) 33 | { 34 | constant.R = r; 35 | constant.G = g; 36 | constant.B = b; 37 | constant.A = a; 38 | } 39 | 40 | bool VirtualNode::EqualsToValue(const float value) const 41 | { 42 | return constant.R == value && 43 | constant.G == value && 44 | constant.B == value && 45 | constant.A == value; 46 | } 47 | 48 | bool VirtualNode::EqualsToValue(const FLinearColor value) const 49 | { 50 | return constant.R == value.R && 51 | constant.G == value.G && 52 | constant.B == value.B && 53 | constant.A == value.A; 54 | } 55 | 56 | bool VirtualNode::IsType(const EVirtualNode aType) const 57 | { 58 | return type == aType; 59 | } 60 | 61 | EVirtualNode VirtualNode::GetType() const 62 | { 63 | return type; 64 | } 65 | 66 | int VirtualNode::GetVectorSize() const 67 | { 68 | return vectorSize; 69 | } 70 | 71 | bool VirtualNode::IsTextureLoaded() const 72 | { 73 | return isTextureLoaded; 74 | } 75 | 76 | void VirtualNode::SetTextureIsLoaded() 77 | { 78 | isTextureLoaded = true; 79 | } 80 | 81 | void VirtualNode::SetVectorSize(const int32 vs) 82 | { 83 | vectorSize = vs; 84 | } 85 | 86 | }//namespace RPR -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Assets/RPRMaterial.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Materials/MaterialInstanceConstant.h" 20 | #include "Material/RPRUberMaterialParameters.h" 21 | #include "Material/TriPlanarSettings.h" 22 | #include "RPRMaterial.generated.h" 23 | 24 | DECLARE_MULTICAST_DELEGATE_OneParam(FRPRMaterialChanged, class URPRMaterial*) 25 | 26 | /* 27 | * Asset representing a RPR Uber material 28 | */ 29 | UCLASS(BlueprintType) 30 | class RPRCORE_API URPRMaterial : public UMaterialInstanceConstant 31 | { 32 | GENERATED_BODY() 33 | 34 | friend class FRPRXMaterialLibrary; 35 | 36 | public: 37 | 38 | URPRMaterial(); 39 | 40 | void MarkMaterialDirty(); 41 | bool IsMaterialDirty() const; 42 | FRPRMaterialChanged& OnRPRMaterialChanged() { return OnRPRMaterialChangedEvent; } 43 | 44 | #if WITH_EDITOR 45 | virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; 46 | #endif 47 | 48 | private: 49 | 50 | void ResetMaterialDirtyFlag(); 51 | 52 | public: 53 | 54 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Material) 55 | FRPRUberMaterialParameters MaterialParameters; 56 | 57 | private: 58 | 59 | FRPRMaterialChanged OnRPRMaterialChangedEvent; 60 | bool bShouldCacheBeRebuild; 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Cache/RPRImagesCache.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Typedefs/RPRTypedefs.h" 19 | #include "Engine/Texture.h" 20 | #include "Containers/Map.h" 21 | 22 | namespace RPR 23 | { 24 | /* 25 | * Cache for the RPR Image. 26 | * Once the image is added, the cache becomes owner of the image and will delete it when resources will be released. 27 | */ 28 | class FImagesCache 29 | { 30 | public: 31 | 32 | virtual ~FImagesCache(); 33 | 34 | void Add(UTexture* Texture, FImagePtr Image); 35 | void Release(UTexture* Texture); 36 | 37 | // Free each image resources and clear the cache 38 | void ReleaseAll(); 39 | 40 | FImagePtr Get(UTexture* Texture); 41 | 42 | private: 43 | 44 | void RemoveDeprecatedImages(); 45 | 46 | private: 47 | 48 | TMap, FImagePtr> loadedImages; 49 | 50 | }; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Enums/RPRMaterialParameterEnums.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Templates/UnrealTypeTraits.h" 19 | #include "RadeonProRender.h" 20 | 21 | UENUM(BlueprintType) 22 | enum class ERPRReflectionMode : uint8 23 | { 24 | DEFAULT = 0, 25 | PBR = RPR_UBER_MATERIAL_IOR_MODE_PBR, 26 | Metalness = RPR_UBER_MATERIAL_IOR_MODE_METALNESS, 27 | }; 28 | 29 | UENUM(BlueprintType) 30 | enum class ERPRCoatingMode : uint8 31 | { 32 | DEFAULT = 0, 33 | PBR = RPR_UBER_MATERIAL_IOR_MODE_PBR, 34 | //Metalness = RPRX_UBER_MATERIAL_COATING_MODE_METALNESS, 35 | }; 36 | 37 | UENUM(BlueprintType) 38 | enum class ERPREmissionMode : uint8 39 | { 40 | DEFAULT = 0, 41 | SingleSided = RPR_UBER_MATERIAL_EMISSION_MODE_SINGLESIDED, 42 | DoubleSided = RPR_UBER_MATERIAL_EMISSION_MODE_DOUBLESIDED 43 | }; 44 | 45 | template<> 46 | struct TNameOf 47 | { 48 | FORCEINLINE static TCHAR const* GetName() 49 | { 50 | return TEXT("ERPRReflectionMode"); 51 | } 52 | }; 53 | 54 | template<> 55 | struct TNameOf 56 | { 57 | FORCEINLINE static TCHAR const* GetName() 58 | { 59 | return TEXT("ERPRCoatingMode"); 60 | } 61 | }; 62 | 63 | template<> 64 | struct TNameOf 65 | { 66 | FORCEINLINE static TCHAR const* GetName() 67 | { 68 | return TEXT("ERPREmissionMode"); 69 | } 70 | }; 71 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/MaterialContext.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Typedefs/RPRTypedefs.h" 20 | 21 | namespace RPR 22 | { 23 | /* 24 | * Group of overused variables that are all required everywhere in the code 25 | * So, this is easier to pass them as one parameter. 26 | */ 27 | struct FMaterialContext 28 | { 29 | RPR::FContext RPRContext; 30 | FMaterialSystem MaterialSystem; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/RPRMaterialMapUV.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "CoreMinimal.h" 19 | #include "RPRMaterialMapUV.generated.h" 20 | 21 | UENUM(BlueprintType) 22 | enum class ETextureUVMode : uint8 23 | { 24 | None, 25 | Planar, 26 | Cylindrical, 27 | Spherical, 28 | Projection, 29 | Triplanar 30 | }; 31 | 32 | /* 33 | * UV settings of a RPRMaterialMap 34 | */ 35 | USTRUCT(BlueprintType) 36 | struct RPRCORE_API FRPRMaterialMapUV 37 | { 38 | GENERATED_BODY() 39 | 40 | // Only 2 UV channels supported 41 | UPROPERTY(EditAnywhere, meta = (DisplayName = "UV Channel", UIMin = 0, UIMax = 1, ClampMin = 0, ClampMax = 1), BlueprintReadWrite, Category = Material) 42 | int32 UVChannel; 43 | 44 | UPROPERTY(EditAnywhere, meta = (DisplayName = "UV Mode"), BlueprintReadWrite, Category = Material) 45 | ETextureUVMode UVMode; 46 | 47 | UPROPERTY(EditAnywhere, meta = (ToolTip = "In degrees", UIMin = 0, UIMax = 360, ClampMin = 0, ClampMax = 360), BlueprintReadWrite, Category = Material) 48 | float Rotation; 49 | 50 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 51 | float UVWeight; 52 | 53 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 54 | FVector Threshold; 55 | 56 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 57 | FVector2D Origin; 58 | 59 | UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "Right axis"), Category = Material) 60 | FVector XAxis; 61 | 62 | UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "Up axis"), Category = Material) 63 | FVector ZAxis; 64 | 65 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 66 | FVector2D Scale; 67 | 68 | 69 | public: 70 | 71 | FRPRMaterialMapUV(); 72 | 73 | uint8 GetRPRValueFromTextureUVMode() const; 74 | 75 | private: 76 | 77 | static TMap TextureUVModeToRPRValue; 78 | 79 | }; -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/Tools/MaterialCacheMaker/ParameterArgs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Containers/UnrealString.h" 20 | #include "Typedefs/RPRTypedefs.h" 21 | #include "Material/MaterialContext.h" 22 | #include "ImageManager/RPRImageManager.h" 23 | #include "Material/RPRXMaterial.h" 24 | 25 | struct FRPRUberMaterialParameters; 26 | struct FRPRUberMaterialParameterBase; 27 | class URPRMaterial; 28 | 29 | namespace RPRX 30 | { 31 | namespace MaterialParameter 32 | { 33 | struct FArgs 34 | { 35 | FRPRUberMaterialParameters& Parameters; 36 | UProperty* Property; 37 | URPRMaterial* OwnerMaterial; 38 | 39 | RPR::FMaterialContext& MaterialContext; 40 | RPR::FRPRXMaterialPtr Material; 41 | RPR::FImageManagerPtr ImageManager; 42 | 43 | FArgs(FRPRUberMaterialParameters& InParameters, 44 | UProperty* InProperty, 45 | RPR::FImageManagerPtr InImageManager, 46 | URPRMaterial* OwnerMaterial, 47 | RPR::FMaterialContext& InMaterialContext, 48 | RPR::FRPRXMaterialPtr InMaterial); 49 | 50 | template 51 | const ParameterType* GetDirectParameter(); 52 | 53 | FRPRUberMaterialParameterBase* GetMaterialParameterBase(); 54 | 55 | uint32 GetRprxParam(); 56 | bool CanUseParam(); 57 | bool HasCustomParameterApplier(); 58 | }; 59 | 60 | template 61 | const ParameterType* FArgs::GetDirectParameter() 62 | { 63 | return (Property->ContainerPtrToValuePtr(&Parameters)); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/Tools/UberMaterialPropertyHelper.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "UObject/UnrealType.h" 20 | #include "Containers/UnrealString.h" 21 | #include "Material/RPRUberMaterialParameters.h" 22 | 23 | struct FRPRUberMaterialParameters; 24 | 25 | class RPRCORE_API FUberMaterialPropertyHelper 26 | { 27 | public: 28 | 29 | /* 30 | * Returns the most appropriate type name for a property. 31 | * - Convert any enum property to uint8. 32 | * - Get c++ type for the others properties 33 | */ 34 | static FString GetPropertyTypeName(const UProperty* Property); 35 | static FRPRUberMaterialParameterBase* GetParameterBaseFromProperty(FRPRUberMaterialParameters* MaterialParameters, 36 | const UProperty* Property); 37 | 38 | static bool IsPropertyValidUberParameterProperty(const UProperty* Property); 39 | static const UStruct* GetTopStructProperty(const UStruct* Struct); 40 | }; 41 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/TriPlanarSettings.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "UObject/ObjectMacros.h" 20 | #include "TriPlanarSettings.generated.h" 21 | 22 | /** 23 | * Describes the settings of the tri planar mode 24 | */ 25 | USTRUCT(BlueprintType) 26 | struct RPRCORE_API FTriPlanarSettings 27 | { 28 | GENERATED_BODY() 29 | 30 | public: 31 | 32 | FTriPlanarSettings(); 33 | 34 | public: 35 | 36 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Material) 37 | bool bUseTriPlanar; 38 | 39 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Material) 40 | float Scale; 41 | 42 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Material) 43 | float Angle; 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialBool.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/UberMaterialParameters/RPRUberMaterialParameterBase.h" 20 | #include "RPRMaterialBool.generated.h" 21 | 22 | /* 23 | * Represents a parameter that is a boolean 24 | */ 25 | USTRUCT(BlueprintType) 26 | struct RPRCORE_API FRPRMaterialBool : public FRPRUberMaterialParameterBase 27 | { 28 | GENERATED_BODY() 29 | 30 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 31 | bool bIsEnabled; 32 | 33 | FRPRMaterialBool() {} 34 | FRPRMaterialBool( 35 | const FString& InXmlParamName, 36 | uint32 InRprxParamID, 37 | ESupportMode InPreviewSupportMode, 38 | bool DefaultValue, 39 | FCanUseParameter InCanUseParameter = FCanUseParameter()); 40 | }; 41 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialCoM.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/UberMaterialParameters/RPRMaterialMap.h" 20 | #include "Material/UberMaterialParameters/RPRMaterialMapMode.h" 21 | #include "RPRMaterialCoM.generated.h" 22 | 23 | /* 24 | * Represents a parameter that can be a Constant (color) or a Map 25 | * "CoM" stands for "Constant or Map" 26 | */ 27 | USTRUCT(BlueprintType) 28 | struct RPRCORE_API FRPRMaterialCoM : public FRPRMaterialMap 29 | { 30 | GENERATED_BODY() 31 | 32 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 33 | FLinearColor Constant; 34 | 35 | UPROPERTY(EditAnywhere, Category = Material) 36 | ERPRMaterialMapMode Mode; 37 | 38 | 39 | FRPRMaterialCoM(); 40 | FRPRMaterialCoM( 41 | const FString& InXmlParamName, 42 | uint32 InRprxParamID, 43 | ESupportMode InPreviewSupportMode, 44 | float UniformConstant = 1.0f, 45 | FCanUseParameter InCanUseParameter = FCanUseParameter()); 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialCoMChannel1.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Containers/UnrealString.h" 20 | #include "Miscs/NumericRestriction.h" 21 | #include "Material/UberMaterialParameters/RPRMaterialMapMode.h" 22 | #include "Material/UberMaterialParameters/RPRMaterialMap.h" 23 | #include "RPRMaterialCoMChannel1.generated.h" 24 | 25 | enum class ERPRMCoMapC1InterpretationMode 26 | { 27 | AsFloat, 28 | AsFloat4 29 | }; 30 | 31 | /* 32 | * Represents a parameter that can be a map or a float 33 | */ 34 | USTRUCT(BlueprintType) 35 | struct RPRCORE_API FRPRMaterialCoMChannel1 : public FRPRMaterialMap 36 | { 37 | GENERATED_BODY() 38 | 39 | public: 40 | 41 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 42 | float Constant; 43 | 44 | UPROPERTY(EditAnywhere, Category = Material) 45 | ERPRMaterialMapMode Mode; 46 | 47 | ERPRMCoMapC1InterpretationMode RPRInterpretationMode; 48 | 49 | public: 50 | 51 | FRPRMaterialCoMChannel1() {} 52 | FRPRMaterialCoMChannel1( 53 | const FString& InXmlParamName, 54 | uint32 InRprxParamID, 55 | ESupportMode InPreviewSupportMode, 56 | float InConstantValue = 1.0f, 57 | ERPRMCoMapC1InterpretationMode InMode = ERPRMCoMapC1InterpretationMode::AsFloat, 58 | FCanUseParameter InCanUseParameter = FCanUseParameter()); 59 | 60 | #if WITH_EDITOR 61 | 62 | FNumericRestriction& GetConstantRestriction(); 63 | const FNumericRestriction& GetConstantRestriction() const; 64 | 65 | #endif 66 | 67 | private: 68 | 69 | #if WITH_EDITORONLY_DATA 70 | 71 | FNumericRestriction ConstantRestriction; 72 | 73 | #endif 74 | 75 | 76 | }; 77 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialEnum.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/UberMaterialParameters/RPRUberMaterialParameterBase.h" 20 | #include "RPRMaterialEnum.generated.h" 21 | 22 | /* 23 | * Represents a parameter that is an enum 24 | */ 25 | USTRUCT(BlueprintType) 26 | struct RPRCORE_API FRPRMaterialEnum : public FRPRUberMaterialParameterBase 27 | { 28 | friend struct FRPRUberMaterialParameters; 29 | 30 | GENERATED_BODY() 31 | 32 | UPROPERTY(EditAnywhere, Category = Material) 33 | uint8 EnumValue; 34 | 35 | UPROPERTY(VisibleAnywhere, Category = Material) 36 | UEnum* EnumType; 37 | 38 | 39 | FRPRMaterialEnum() {} 40 | FRPRMaterialEnum(const FString& InXmlParamName, uint32 InRprxParamID, ESupportMode InPreviewSupportMode, FCanUseParameter InCanUseParameter = FCanUseParameter()); 41 | 42 | template 43 | void SetValue(TEnumType InEnumValue) 44 | { 45 | EnumValue = StaticCast(InEnumValue); 46 | } 47 | 48 | void SetRawValue(uint8 RawValue) 49 | { 50 | EnumValue = RawValue; 51 | } 52 | 53 | template 54 | static FRPRMaterialEnum Create(const FString& InXmlParamName, uint32 InRprxParamID, ESupportMode InPreviewSupportMode, TEnumType InEnumValue, FCanUseParameter InCanUseParameter = FCanUseParameter()); 55 | 56 | }; 57 | 58 | template 59 | FRPRMaterialEnum FRPRMaterialEnum::Create(const FString& InXmlParamName, uint32 InRprxParamID, ESupportMode InPreviewSupportMode, TEnumType InEnumValue, FCanUseParameter InCanUseParameter) 60 | { 61 | FRPRMaterialEnum materialEnum(InXmlParamName, InRprxParamID, InPreviewSupportMode, InCanUseParameter); 62 | materialEnum.SetValue(InEnumValue); 63 | 64 | const TCHAR* enumTypeName = TNameOf::GetName(); 65 | materialEnum.EnumType = FindObject((UObject*)ANY_PACKAGE, enumTypeName, true); 66 | 67 | checkf(materialEnum.EnumType, TEXT("Enum %s cannot be found!"), enumTypeName); 68 | 69 | return (materialEnum); 70 | } 71 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialMap.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Material/UberMaterialParameters/RPRUberMaterialParameterBase.h" 20 | #include "Engine/Texture2D.h" 21 | #include "Containers/UnrealString.h" 22 | #include "Containers/Map.h" 23 | #include "Material/RPRMaterialMapUV.h" 24 | #include "RPRMaterialMap.generated.h" 25 | 26 | /* 27 | * Base class for parameters that represents a map 28 | */ 29 | USTRUCT(BlueprintType) 30 | struct RPRCORE_API FRPRMaterialMap : public FRPRUberMaterialParameterBase 31 | { 32 | GENERATED_BODY() 33 | 34 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 35 | UTexture2D* Texture; 36 | 37 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 38 | FRPRMaterialMapUV UVSettings; 39 | 40 | 41 | FRPRMaterialMap() {} 42 | FRPRMaterialMap( 43 | const FString& InXmlParamName, 44 | uint32 InRprxParamID, 45 | ESupportMode InPreviewSupportMode, 46 | FCanUseParameter InCanUseParameter = FCanUseParameter(), 47 | FApplyParameter InApplyParameterDelegate = FApplyParameter()); 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialMapMode.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Templates/UnrealTypeTraits.h" 19 | #include "UObject/ObjectMacros.h" 20 | 21 | UENUM(BlueprintType) 22 | enum class ERPRMaterialMapMode : uint8 23 | { 24 | Constant, 25 | Texture 26 | }; 27 | 28 | 29 | #define GET_ENUM_NAME_CHECKED(EnumName) ((void)sizeof(EnumName), TEXT(#EnumName)) 30 | 31 | /* 32 | * Make it possible to get the enum name using TNameOf::GetName() 33 | */ 34 | template<> 35 | struct TNameOf 36 | { 37 | FORCEINLINE static TCHAR const* GetName() 38 | { 39 | return GET_ENUM_NAME_CHECKED(ERPRMaterialMapMode); 40 | } 41 | }; 42 | 43 | #undef GET_ENUM_NAME_CHECKED 44 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/Material/UberMaterialParameters/RPRMaterialNormalMap.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Material/UberMaterialParameters/RPRMaterialMap.h" 19 | #include "UObject/ObjectMacros.h" 20 | #include "RPRMaterialNormalMap.generated.h" 21 | 22 | UENUM(BlueprintType) 23 | enum class ENormalMapMode : uint8 24 | { 25 | Normal, 26 | Bump 27 | }; 28 | 29 | /* 30 | * Represents a normal map 31 | */ 32 | USTRUCT(BlueprintType) 33 | struct RPRCORE_API FRPRMaterialNormalMap : public FRPRMaterialMap 34 | { 35 | GENERATED_BODY() 36 | 37 | 38 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 39 | ENormalMapMode Mode; 40 | 41 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Material) 42 | float BumpScale; 43 | 44 | 45 | FRPRMaterialNormalMap() {} 46 | 47 | FRPRMaterialNormalMap( 48 | const FString& InXmlParamName, 49 | uint32 InRprxParamID, 50 | ESupportMode InPreviewSupportMode, 51 | FCanUseParameter InCanUseParameter = FCanUseParameter(), 52 | FApplyParameter InApplyParameterDelegate = FApplyParameter()); 53 | 54 | }; -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/RPRCoreErrorHelper.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | class RPRCORE_API FRPRCoreErrorHelper 20 | { 21 | public: 22 | static void LogLastError(); 23 | }; 24 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/RPRCoreModule.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Modules/ModuleInterface.h" 21 | #include "Modules/ModuleManager.h" 22 | #include "RPRCoreSystemResources.h" 23 | 24 | DECLARE_LOG_CATEGORY_EXTERN(LogRPRCore, All, All); 25 | 26 | // Used to trace rendering steps 27 | DECLARE_LOG_CATEGORY_EXTERN(LogRPRCore_Steps, Verbose, Verbose); 28 | 29 | class RPRCORE_API IRPRCore : public IModuleInterface 30 | { 31 | 32 | public: 33 | void StartupModule() override; 34 | void ShutdownModule() override; 35 | 36 | static IRPRCore& Get() 37 | { 38 | return FModuleManager::GetModuleChecked("RPRCore"); 39 | } 40 | 41 | static bool IsAvailable() 42 | { 43 | return FModuleManager::Get().IsModuleLoaded("RPRCore"); 44 | } 45 | 46 | static FRPRCoreSystemResourcesPtr GetResources() 47 | { 48 | return FModuleManager::GetModuleChecked("RPRCore").Resources; 49 | } 50 | 51 | private: 52 | FRPRCoreSystemResourcesPtr Resources; 53 | 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/Public/RPRXVirtualNode.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Typedefs/RPRTypedefs.h" 20 | 21 | struct FLinearColor; 22 | 23 | /** 24 | * In case of a constant nodes, we don't create a RPR real node and use a virtual node to hold the data. 25 | */ 26 | namespace RPR 27 | { 28 | 29 | enum class EVirtualNode 30 | { 31 | OTHER, 32 | TEXTURE, 33 | CONSTANT 34 | }; 35 | 36 | class RPRCORE_API VirtualNode 37 | { 38 | public: 39 | const FString id; 40 | const EVirtualNode type; 41 | RPR::FMaterialNode rprNode; 42 | FLinearColor constant; 43 | int32 vectorSize; 44 | bool isTextureLoaded; 45 | 46 | public: 47 | VirtualNode(FString aID = "", EVirtualNode aType = EVirtualNode::OTHER); 48 | void SetData(float r, float g, float b, float a); 49 | 50 | bool EqualsToValue(const float value) const; 51 | bool EqualsToValue(const FLinearColor value) const; 52 | 53 | bool IsType(const EVirtualNode aType) const; 54 | EVirtualNode GetType() const; 55 | 56 | bool IsTextureLoaded() const; 57 | void SetTextureIsLoaded(); 58 | 59 | void SetVectorSize(const int32 vs); 60 | int GetVectorSize() const; 61 | 62 | VirtualNode(const VirtualNode&) = delete; 63 | VirtualNode& operator=(const VirtualNode&) = delete; 64 | }; 65 | }//namespace RPR 66 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRCore/RPRCore.Build.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | namespace UnrealBuildTool.Rules 18 | { 19 | public class RPRCore : ModuleRules 20 | { 21 | public RPRCore(ReadOnlyTargetRules Target) : base(Target) 22 | { 23 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 24 | bEnableExceptions = true; 25 | 26 | PrivateIncludePaths.AddRange( 27 | new string[] { 28 | "RPRCore/Public/Material/Tools/MaterialCacheMaker", 29 | 30 | "RPRCore/Private/Material", 31 | "RPRCore/Private/Material/Tools/MaterialCacheMaker", 32 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/Factory", 33 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters", 34 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/Bool", 35 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/Enum", 36 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialMap", 37 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoM", 38 | "RPRCore/Private/Material/Tools/MaterialCacheMaker/ParameterSetters/MaterialCoMChannel1", 39 | 40 | } 41 | ); 42 | 43 | PublicDependencyModuleNames.AddRange( 44 | new string[] 45 | { 46 | "RPRPluginVersion", 47 | "RPR_SDK", 48 | "RPRTools", 49 | } 50 | ); 51 | 52 | PrivateDependencyModuleNames.AddRange( 53 | new string[] 54 | { 55 | "Core", 56 | "RenderCore", 57 | "CoreUObject", 58 | "Engine", 59 | } 60 | ); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Private/Scene/RPRActor.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Scene/RPRActor.h" 18 | 19 | ARPRActor::ARPRActor() 20 | : Component(NULL) 21 | , SrcComponent(NULL) 22 | { 23 | PrimaryActorTick.bCanEverTick = true; 24 | } 25 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Private/Tools/FImageSaver.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "FImageSaver.h" 18 | 19 | #ifdef TEXT 20 | #undef TEXT 21 | #endif 22 | 23 | #ifdef DLLEXPORT 24 | #undef DLLEXPORT 25 | #endif 26 | 27 | #include "imageio.h" 28 | 29 | namespace 30 | { 31 | bool WriteImageToFile(const FString& filename, const OIIO::TypeDesc type, const void* imdata, const int width, const int height) 32 | { 33 | OIIO::ImageOutput* outImage = OIIO::ImageOutput::create(TCHAR_TO_ANSI(*filename)); 34 | 35 | if (outImage) 36 | { 37 | OIIO::ImageSpec imgSpec(width, height, 4, type); 38 | 39 | outImage->open(TCHAR_TO_ANSI(*filename), imgSpec); 40 | outImage->write_image(type, imdata); 41 | outImage->close(); 42 | delete outImage; 43 | 44 | return true; 45 | } 46 | 47 | return false; 48 | } 49 | } 50 | 51 | bool FImageSaver::WriteUint8ImageToFile(const FString& filename, const void* imdata, const int width, const int height) 52 | { 53 | return WriteImageToFile(filename, OIIO::TypeDesc::UINT8, imdata, width, height); 54 | } 55 | 56 | bool FImageSaver::WriteFloatImageToFile(const FString& filename, const void* imdata, const int width, const int height) 57 | { 58 | return WriteImageToFile(filename, OIIO::TypeDesc::FLOAT, imdata, width, height); 59 | } 60 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Private/Tools/FImageSaver.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | 21 | class FImageSaver 22 | { 23 | public: 24 | bool WriteFloatImageToFile(const FString& filename, const void* imdata, const int width, const int height); 25 | bool WriteUint8ImageToFile(const FString& filename, const void* imdata, const int width, const int height); 26 | }; 27 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Private/Viewport/RPRViewportClient.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "InputCoreTypes.h" 21 | #include "UObject/GCObject.h" 22 | #include "UnrealClient.h" 23 | 24 | class FRPRViewportClient : public FViewportClient 25 | { 26 | public: 27 | FRPRViewportClient(class FRPRPluginModule *plugin); 28 | ~FRPRViewportClient(); 29 | 30 | /** FViewportClient interface */ 31 | virtual void Draw(FViewport *viewport, class FCanvas *canvas) override; 32 | virtual bool InputKey(FViewport *viewport, int32 controllerId, FKey key, EInputEvent e, float amountDepressed = 1.0f, bool bGamepad = false) override; 33 | virtual UWorld *GetWorld() const override { return NULL; } 34 | virtual void CapturedMouseMove(FViewport *inViewport, int32 inMouseX, int32 inMouseY) override; 35 | 36 | FVector2D CalculateTextureDimensions(const class UTexture2DDynamic *renderTexture, const FVector2D &viewportDimensions) const; 37 | private: 38 | class FRPRPluginModule *m_Plugin; 39 | 40 | FIntPoint m_PrevMousePos; 41 | bool m_StartOrbit; 42 | bool m_StartPanning; 43 | }; 44 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/RPREditorStyle.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #if WITH_EDITOR 20 | 21 | #include "EditorStyleSet.h" 22 | 23 | class FRPREditorStyle : public FEditorStyle 24 | { 25 | public: 26 | static void Initialize(); 27 | 28 | static void Shutdown(); 29 | 30 | private: 31 | static TSharedRef Create(); 32 | 33 | private: 34 | static TSharedPtr RPRStyleInstance; 35 | 36 | static FString InContent(const FString& RelativePath, const ANSICHAR* Extension); 37 | 38 | private: 39 | FRPREditorStyle() {} 40 | }; 41 | 42 | #endif // WITH_EDITOR 43 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/RPRStats.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Stats/Stats.h" 20 | 21 | DECLARE_STATS_GROUP(TEXT("ProRender"), STATGROUP_ProRender, STATCAT_Advanced); 22 | 23 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Copy framebuffer"), STAT_ProRender_CopyFramebuffer, STATGROUP_ProRender, ); 24 | 25 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Update cameras"), STAT_ProRender_UpdateCameras, STATGROUP_ProRender, ); 26 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Update viewport camera"), STAT_ProRender_UpdateViewportCamera, STATGROUP_ProRender, ); 27 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Update lights"), STAT_ProRender_UpdateLights, STATGROUP_ProRender, ); 28 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Update meshes"), STAT_ProRender_UpdateMeshes, STATGROUP_ProRender, ); 29 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Update scene"), STAT_ProRender_UpdateScene, STATGROUP_ProRender, ); 30 | DECLARE_CYCLE_STAT_EXTERN(TEXT("Game Thread: Viewport draw"), STAT_ProRender_DrawViewport, STATGROUP_ProRender, ); 31 | 32 | DECLARE_CYCLE_STAT_EXTERN(TEXT("RPR Thread: Pre-render"), STAT_ProRender_PreRender, STATGROUP_ProRender, ); 33 | DECLARE_CYCLE_STAT_EXTERN(TEXT("RPR Thread: Rebuild scene"), STAT_ProRender_RebuildScene, STATGROUP_ProRender, ); 34 | DECLARE_CYCLE_STAT_EXTERN(TEXT("RPR Thread: Render"), STAT_ProRender_Render, STATGROUP_ProRender, ); 35 | DECLARE_CYCLE_STAT_EXTERN(TEXT("RPR Thread: Resolve"), STAT_ProRender_Resolve, STATGROUP_ProRender, ); 36 | DECLARE_CYCLE_STAT_EXTERN(TEXT("RPR Thread: Readback framebuffer"), STAT_ProRender_Readback, STATGROUP_ProRender, ); 37 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/RPRActor.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "GameFramework/Actor.h" 21 | #include "RPRActor.generated.h" 22 | 23 | UCLASS(Transient) 24 | class ARPRActor : public AActor 25 | { 26 | GENERATED_BODY() 27 | public: 28 | UPROPERTY() 29 | class URPRSceneComponent *Component; 30 | 31 | UPROPERTY() 32 | class USceneComponent *SrcComponent; 33 | public: 34 | ARPRActor(); 35 | }; 36 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/RPRCameraComponent.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Components/SceneComponent.h" 21 | #include "Scene/RPRSceneComponent.h" 22 | #include "Camera/CameraTypes.h" 23 | #include "RadeonProRender.h" 24 | #include "RPRCameraComponent.generated.h" 25 | 26 | enum 27 | { 28 | PROPERTY_REBUILD_PROJECTION_MODE = 0x02, 29 | PROPERTY_REBUILD_FOCAL_LENGTH = 0x04, 30 | PROPERTY_REBUILD_FOCUS_DISTANCE = 0x08, 31 | PROPERTY_REBUILD_APERTURE = 0x10, 32 | PROPERTY_REBUILD_SENSOR_SIZE = 0x20, 33 | PROPERTY_REBUILD_ACTIVE_CAMERA = 0x40, 34 | }; 35 | 36 | UCLASS(Transient) 37 | class URPRCameraComponent : public URPRSceneComponent 38 | { 39 | GENERATED_BODY() 40 | public: 41 | URPRCameraComponent(); 42 | 43 | void SetAsActiveCamera(); 44 | void SetOrbit(bool orbit); 45 | void StartOrbitting(const FIntPoint &mousePos); 46 | FString GetCameraName() const; 47 | FVector GetCameraPosition() const; 48 | 49 | private: 50 | virtual bool Build() override; 51 | virtual bool RebuildTransforms() override; 52 | virtual void TickComponent(float deltaTime, ELevelTick tickType, FActorComponentTickFunction *tickFunction) override; 53 | virtual bool RPRThread_Update() override; 54 | virtual void ReleaseResources() override; 55 | 56 | void UpdateOrbitCamera(); 57 | void RefreshProperties(bool force); 58 | 59 | private: 60 | rpr_camera m_RprCamera; 61 | 62 | ECameraProjectionMode::Type m_CachedProjectionMode; 63 | float m_CachedFocalLength; 64 | float m_CachedFocusDistance; 65 | float m_CachedAperture; 66 | float m_CachedAspectRatio; 67 | FVector2D m_CachedSensorSize; 68 | 69 | bool m_Orbit; 70 | FVector m_OrbitLocation; 71 | FVector m_OrbitCenter; 72 | }; 73 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/RPRLightComponent.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Components/SceneComponent.h" 21 | #include "RadeonProRender.h" 22 | #include "Scene/RPRSceneComponent.h" 23 | #include "Engine/Scene.h" 24 | #include "Components/SkyLightComponent.h" 25 | #include "Typedefs/RPRTypedefs.h" 26 | #include "RPRLightComponent.generated.h" 27 | 28 | enum ERPRLightType 29 | { 30 | Point, 31 | Spot, 32 | Directional, 33 | IES, 34 | Environment, 35 | }; 36 | 37 | UCLASS(Transient) 38 | class URPRLightComponent : public URPRSceneComponent 39 | { 40 | GENERATED_BODY() 41 | 42 | public: 43 | 44 | URPRLightComponent(); 45 | 46 | virtual bool Build() override; 47 | 48 | private: 49 | 50 | virtual void ReleaseResources() override; 51 | virtual void TickComponent(float deltaTime, ELevelTick tickType, FActorComponentTickFunction *tickFunction) override; 52 | virtual bool RebuildTransforms() override; 53 | virtual bool PostBuild() override; 54 | virtual bool RPRThread_Update() override; 55 | 56 | int BuildIESLight(const class UPointLightComponent *lightComponent); 57 | int BuildPointLight(const class UPointLightComponent *pointLightComponent); 58 | int BuildSpotLight(const class USpotLightComponent *spotLightComponent); 59 | int BuildDirectionalLight(const class UDirectionalLightComponent *dirLightComponent); 60 | int BuildSkyLight(const class USkyLightComponent *skyLightComponent); 61 | 62 | private: 63 | 64 | RPR::FImagePtr m_RprImage; 65 | rpr_light m_RprLight; 66 | 67 | ERPRLightType m_LightType; 68 | 69 | bool m_CachedAffectsWorld; 70 | float m_CachedShadowSharpness; 71 | float m_CachedIntensity; 72 | ELightUnits m_CachedIntensityUnits; 73 | FColor m_CachedLightColor; 74 | FVector2D m_CachedConeAngles; 75 | 76 | UTextureCube *m_CachedCubemap; 77 | ESkyLightSourceType m_CachedSourceType; 78 | }; 79 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/RPRSceneComponent.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Components/SceneComponent.h" 21 | #include "RPRCoreErrorHelper.h" 22 | #include "RPRSceneComponent.generated.h" 23 | 24 | enum 25 | { 26 | PROPERTY_REBUILD_TRANSFORMS = 0x01, 27 | }; 28 | 29 | #define RPR_PROPERTY_REBUILD(LogClass, ErrorMessage, flag, function, ... ) \ 30 | if (m_RebuildFlags & flag) \ 31 | { \ 32 | if (function(__VA_ARGS__) != RPR_SUCCESS) \ 33 | { \ 34 | UE_LOG(LogClass, Warning, TEXT(ErrorMessage)); \ 35 | FRPRCoreErrorHelper::LogLastError(); \ 36 | } \ 37 | } 38 | 39 | #define RPR_PROPERTY_CHECK(value, cachedValue, flag) \ 40 | if (force || value != cachedValue) \ 41 | { \ 42 | cachedValue = value; \ 43 | m_RebuildFlags |= flag; \ 44 | } 45 | 46 | /** 47 | * Root of all RPR component, representation of an UE object 48 | */ 49 | UCLASS(Abstract, Transient) 50 | class URPRSceneComponent : public USceneComponent 51 | { 52 | GENERATED_BODY() 53 | public: 54 | UPROPERTY(Transient) 55 | USceneComponent *SrcComponent; 56 | 57 | class ARPRScene *Scene; 58 | public: 59 | URPRSceneComponent(); 60 | 61 | /* Build the RPR object based on the UE4 component */ 62 | virtual bool Build() { return false; }; 63 | 64 | /* Called on the Game thread, after the object has been built */ 65 | virtual bool PostBuild(); 66 | 67 | /* Rebuild the RPR transforms */ 68 | virtual bool RebuildTransforms() { return false; } 69 | 70 | /* Called on the RPR Thread, execute rpr calls to refresh object properties */ 71 | virtual bool RPRThread_Update(); 72 | 73 | /** Safe call to release resources */ 74 | virtual void ReleaseResources(); 75 | 76 | bool IsSrcComponentValid() const; 77 | protected: 78 | void TickComponent(float deltaTime, ELevelTick tickType, FActorComponentTickFunction *tickFunction) override; 79 | void TriggerRebuildTransforms(); 80 | 81 | virtual void BeginDestroy() override; 82 | protected: 83 | bool m_Built; 84 | bool m_Sync; 85 | class FRPRPluginModule *m_Plugin; 86 | 87 | uint32 m_RebuildFlags; 88 | 89 | FCriticalSection m_RefreshLock; 90 | private: 91 | FTransform m_CachedTransforms; 92 | }; 93 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/RPRViewportCameraComponent.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "RadeonProRender.h" 20 | #include "CoreMinimal.h" 21 | #include "Components/SceneComponent.h" 22 | #include "Scene/RPRSceneComponent.h" 23 | #include "Camera/CameraTypes.h" 24 | #include "RPRViewportCameraComponent.generated.h" 25 | 26 | UCLASS(Transient) 27 | class URPRViewportCameraComponent : public URPRSceneComponent 28 | { 29 | GENERATED_BODY() 30 | public: 31 | URPRViewportCameraComponent(); 32 | 33 | void SetAsActiveCamera(); 34 | 35 | void SetOrbit(bool orbit); 36 | void StartOrbitting(const FIntPoint &mousePos); 37 | 38 | virtual bool RPRThread_Update() override; 39 | virtual bool Build() override; 40 | virtual void ReleaseResources() override; 41 | 42 | FVector GetViewLocation() const; 43 | FVector GetViewRightVector() const; 44 | FVector GetLookAtLocation() const; 45 | FVector GetCameraPosition() const; 46 | float GetAspectRatio() const; 47 | 48 | private: 49 | virtual void RebuildCameraProperties(bool force); 50 | virtual void TickComponent(float deltaTime, ELevelTick tickType, FActorComponentTickFunction *tickFunction) override; 51 | virtual bool RebuildTransforms() override; 52 | 53 | void UpdateOrbitCamera(); 54 | 55 | private: 56 | rpr_camera m_RprCamera; 57 | 58 | FVector m_CachedCameraPos; 59 | FVector m_CachedCameraLookAt; 60 | 61 | bool m_CachedIsLocked; 62 | ECameraProjectionMode::Type m_CachedProjectionMode; 63 | float m_CachedFocalLength; 64 | float m_CachedFocusDistance; 65 | float m_CachedAperture; 66 | float m_CachedAspectRatio; 67 | FVector2D m_CachedSensorSize; 68 | 69 | bool m_Orbit; 70 | FVector m_OrbitLocation; 71 | FVector m_OrbitCenter; 72 | 73 | class APlayerCameraManager *m_PlayerCameraManager; 74 | 75 | // Editor only 76 | class FLevelEditorViewportClient *m_EditorViewportClient; 77 | }; 78 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/StaticMeshComponent/RPRCachedMesh.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreTypes.h" 20 | #include "RadeonProRender.h" 21 | 22 | struct FRPRCachedMesh 23 | { 24 | rpr_shape m_RprShape; 25 | int32 m_UEMaterialIndex; 26 | 27 | FRPRCachedMesh(rpr_shape shape, int32 materialIndex) 28 | : m_RprShape(shape) 29 | , m_UEMaterialIndex(materialIndex) { } 30 | 31 | FRPRCachedMesh(int32 materialIndex) 32 | : m_UEMaterialIndex(materialIndex) { } 33 | }; 34 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/StaticMeshComponent/RPRShape.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "RadeonProRender.h" 20 | #include "Scene/StaticMeshComponent/RPRCachedMesh.h" 21 | #include "Material/RPRXMaterial.h" 22 | 23 | struct FRPRShape 24 | { 25 | rpr_shape m_RprShape; 26 | rpr_material_node m_RprMaterial; 27 | RPR::FRPRXMaterialPtr m_RprxMaterial; 28 | RPR::FRPRXMaterialNodePtr m_RprxNodeMaterial; 29 | int32 m_UEMaterialIndex; 30 | uint32 m_InstanceIndex; 31 | 32 | FRPRShape(const FRPRCachedMesh &cached, uint32 iInstance) 33 | : m_RprShape(cached.m_RprShape) 34 | , m_RprMaterial(nullptr) 35 | , m_UEMaterialIndex(cached.m_UEMaterialIndex) 36 | , m_InstanceIndex(iInstance) { } 37 | }; 38 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPlugin/Public/Scene/UMSControl.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace rpr 26 | { 27 | class UMSControl 28 | { 29 | public: 30 | UMSControl(); 31 | 32 | ~UMSControl(); 33 | 34 | void Clear(); 35 | 36 | void LoadControlData(const std::string& filename); 37 | 38 | bool IsMaterialUMSEnabled(const std::string& name); 39 | 40 | private: 41 | 42 | bool matchAll = false; 43 | std::unordered_map materialEnables; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPluginVersion/Private/RPRDynamicLibraryLoader.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRDynamicLibraryLoader.h" 18 | #include "HAL/PlatformProcess.h" 19 | #include "Misc/Paths.h" 20 | #include "Misc/MessageDialog.h" 21 | #include "Internationalization/Text.h" 22 | 23 | #define LOCTEXT_NAMESPACE "RPRDynamicLibraryLoader" 24 | 25 | TArray FRPRDynamicLibraryLoader::LoadLibraries(const FString& DllDirectory, const TArray& DllNames) 26 | { 27 | TArray unloadableDLLs; 28 | TArray dllHandles; 29 | 30 | FPlatformProcess::PushDllDirectory(*DllDirectory); 31 | { 32 | for (int32 i = 0; i < DllNames.Num(); ++i) 33 | { 34 | FDLLHandle handle = FPlatformProcess::GetDllHandle(*DllNames[i]); 35 | 36 | if (handle != nullptr) 37 | { 38 | dllHandles.Add(handle); 39 | } 40 | else 41 | { 42 | unloadableDLLs.Add(FPaths::Combine(DllDirectory, DllNames[i])); 43 | } 44 | } 45 | } 46 | FPlatformProcess::PopDllDirectory(*DllDirectory); 47 | 48 | if (unloadableDLLs.Num() > 0) 49 | { 50 | OpenDLLNotFoundMessageBox(unloadableDLLs); 51 | UnloadLibraries(dllHandles); 52 | 53 | dllHandles.Empty(); 54 | } 55 | 56 | return (dllHandles); 57 | } 58 | 59 | void FRPRDynamicLibraryLoader::UnloadLibraries(const TArray& DllHandles) 60 | { 61 | for (int32 i = 0; i < DllHandles.Num(); ++i) 62 | { 63 | FPlatformProcess::FreeDllHandle(DllHandles[i]); 64 | } 65 | } 66 | 67 | void FRPRDynamicLibraryLoader::OpenDLLNotFoundMessageBox(const TArray& DllPaths) 68 | { 69 | FString paths; 70 | for (int32 i = 0; i < DllPaths.Num(); ++i) 71 | { 72 | paths += TEXT("- ") + DllPaths[i]; 73 | if (i + 1 < DllPaths.Num()) 74 | { 75 | paths += TEXT("\n"); 76 | } 77 | } 78 | 79 | FFormatNamedArguments args; 80 | args.Add(TEXT("Paths"), FText::FromString(paths)); 81 | FText message = FText::Format(LOCTEXT("CannotLoadFilesMessage", "Cannot load files :\n{Paths}\n\nRPR won't be able to work correctly."), args); 82 | 83 | FText titleBox = FText::FromString("Cannot load RPR files"); 84 | FMessageDialog::Open(EAppMsgType::Ok, message, &titleBox); 85 | } 86 | 87 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPluginVersion/Public/RPRDynamicLibraryLoader.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | 21 | class RPRPLUGINVERSION_API FRPRDynamicLibraryLoader 22 | { 23 | public: 24 | 25 | using FDLLHandle = void*; 26 | 27 | static TArray LoadLibraries(const FString& DllDirectory, const TArray& DllNames); 28 | static void UnloadLibraries(const TArray& DllHandles); 29 | 30 | private: 31 | 32 | static void OpenDLLNotFoundMessageBox(const TArray& DllPaths); 33 | 34 | 35 | }; -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPluginVersion/Public/RPRPluginVersion.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | /* Set by RPRPluginVersion.Build.cs */ 20 | 21 | #define RPR_PLUGIN_MAJOR_VERSION 0 22 | #define RPR_PLUGIN_MINOR_VERSION 8 23 | 24 | #define RPR_PLUGIN_BUILD_VERSION 1841 25 | #define RPR_PLUGIN_BUILD_GUID TEXT("04886790-afd5-47dc-86bb-fcb6e278aa54") 26 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRPluginVersion/Public/RPRPluginVersionModule.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Modules/ModuleManager.h" 21 | 22 | DECLARE_LOG_CATEGORY_EXTERN(LogRPRPluginVersion, All, All); 23 | 24 | class RPRPLUGINVERSION_API FRPRPluginVersionModule : public IModuleInterface 25 | { 26 | public: 27 | virtual void StartupModule() override; 28 | virtual void ShutdownModule() override; 29 | 30 | static FRPRPluginVersionModule& Get(); 31 | static bool IsLoaded(); 32 | 33 | static const FString& GetRPRPluginPath(); 34 | static bool IsPluginSetupValid(); 35 | 36 | private: 37 | 38 | void DumpPluginVersion(); 39 | void CachePluginPath(); 40 | 41 | private: 42 | 43 | FString RPRPluginPath; 44 | bool bIsPluginSetupValid; 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Private/FFrameBuffer.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "FFrameBuffer.h" 18 | #include 19 | 20 | #ifdef CHECK_ERROR 21 | #undef CHECK_ERROR 22 | #endif 23 | #ifdef CHECK_WARNING 24 | #undef CHECK_WARNING 25 | #endif 26 | 27 | DEFINE_LOG_CATEGORY_STATIC(LogFFrameBufferFilter, Log, All); 28 | 29 | #define CHECK_ERROR(status, msg) \ 30 | CA_CONSTANT_IF(status != RPR_SUCCESS) { \ 31 | UE_LOG(LogFFrameBufferFilter, Error, msg); \ 32 | return status; \ 33 | } 34 | 35 | #define CHECK_WARNING(status, msg) \ 36 | CA_CONSTANT_IF(status != RPR_SUCCESS) { \ 37 | UE_LOG(LogFFrameBufferFilter, Warning, msg); \ 38 | } 39 | 40 | namespace RPR 41 | { 42 | 43 | FFrameBuffer::FFrameBuffer() 44 | : FrameBuffer(nullptr) 45 | { 46 | } 47 | 48 | FFrameBuffer::~FFrameBuffer() 49 | { 50 | int status; 51 | 52 | status = Destroy(); 53 | CHECK_WARNING(status, TEXT("FFramebuffer destructor failure")); 54 | } 55 | 56 | int FFrameBuffer::Create(rpr_context context, rpr_framebuffer_format const format, rpr_framebuffer_desc const* fb_desc) 57 | { 58 | int status; 59 | 60 | if (!context) { 61 | CHECK_ERROR(RPR_ERROR_INVALID_CONTEXT, TEXT("nullptr context")); 62 | } 63 | 64 | status = Destroy(); 65 | CHECK_WARNING(status, TEXT("destroy has some problem")); 66 | 67 | status = rprContextCreateFrameBuffer(context, format, fb_desc, &FrameBuffer); 68 | CHECK_ERROR(status, TEXT("can't create framebuffer")); 69 | 70 | return RPR_SUCCESS; 71 | } 72 | 73 | int FFrameBuffer::Destroy() 74 | { 75 | if (!FrameBuffer) 76 | return RPR_SUCCESS; 77 | 78 | int status; 79 | status = rprObjectDelete(FrameBuffer); 80 | CHECK_WARNING(status, TEXT("framebuffer object delete error")); 81 | 82 | FrameBuffer = nullptr; 83 | 84 | return status; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Private/Helpers/GenericGetInfo.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Helpers/GenericGetInfo.h" 18 | 19 | RPR::FResult RPR::Generic::GetObjectName(RPR::Generic::FGetInfoFunction GetInfoFunction, void* Source, FString& OutName) 20 | { 21 | TArray buffer; 22 | RPR::FResult status = GetInfoToArray(GetInfoFunction, Source, RPR_OBJECT_NAME, buffer); 23 | if (RPR::IsResultSuccess(status)) 24 | { 25 | OutName = FString((char*) buffer.GetData()); 26 | } 27 | return status; 28 | } -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Private/Helpers/RPRCameraHelpers.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Helpers/RPRCameraHelpers.h" 18 | #include "Helpers/GenericGetInfo.h" 19 | 20 | namespace RPR 21 | { 22 | namespace Camera 23 | { 24 | 25 | template 26 | RPR::FResult GetInfoNoAlloc(RPR::FCamera Camera, RPR::ECameraInfo Info, T& OutValue) 27 | { 28 | return RPR::Generic::GetInfoNoAlloc(rprCameraGetInfo, Camera, Info, &OutValue); 29 | } 30 | 31 | template 32 | RPR::FResult GetInfoToArray(RPR::FCamera Camera, RPR::ECameraInfo Info, TArray& OutValue) 33 | { 34 | return RPR::Generic::GetInfoToArray(rprCameraGetInfo, Camera, Info, OutValue); 35 | } 36 | 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | RPR::FResult GetObjectName(RPR::FCamera Camera, FString& OutObjectName) 40 | { 41 | return RPR::Generic::GetObjectName(rprCameraGetInfo, Camera, OutObjectName); 42 | } 43 | 44 | RPR::FResult GetTransform(RPR::FCamera Camera, FTransform& OutTransform) 45 | { 46 | return RPR::Generic::GetObjectTransform(rprCameraGetInfo, Camera, ECameraInfo::Transform, OutTransform); 47 | } 48 | 49 | RPR::FResult GetCameraMode(RPR::FCamera Camera, RPR::ECameraMode& OutCameraMode) 50 | { 51 | return GetInfoNoAlloc(Camera, ECameraInfo::Mode, OutCameraMode); 52 | } 53 | 54 | RPR::FResult GetOrthoSize(RPR::FCamera Camera, FVector2D& OrthoSize) 55 | { 56 | RPR::FResult status; 57 | 58 | float width; 59 | status = GetInfoNoAlloc(Camera, ECameraInfo::OrthoWidth, width); 60 | if (RPR::IsResultFailed(status)) 61 | { 62 | return status; 63 | } 64 | 65 | float height; 66 | status = GetInfoNoAlloc(Camera, ECameraInfo::OrthoWidth, height); 67 | if (RPR::IsResultFailed(status)) 68 | { 69 | return status; 70 | } 71 | 72 | OrthoSize = FVector2D(width, height); 73 | return status; 74 | } 75 | 76 | RPR::FResult GetNearPlane(RPR::FCamera Camera, float& NearPlane) 77 | { 78 | return GetInfoNoAlloc(Camera, ECameraInfo::NearPlane, NearPlane); 79 | } 80 | 81 | RPR::FResult GetFarPlane(RPR::FCamera Camera, float& FarPlane) 82 | { 83 | return GetInfoNoAlloc(Camera, ECameraInfo::FarPlane, FarPlane); 84 | } 85 | 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Private/Helpers/RPRErrorsHelpers.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "Helpers/RPRErrorsHelpers.h" 18 | #include "Logging/LogMacros.h" 19 | #include "Helpers/RPRHelpers.h" 20 | #include "RadeonProRender.h" 21 | #include 22 | 23 | DEFINE_LOG_CATEGORY_STATIC(LogRPRErrors, Log, All) 24 | 25 | namespace RPR 26 | { 27 | namespace Error 28 | { 29 | 30 | FString GetLastError(FContext Context) 31 | { 32 | FString errorMessage; 33 | 34 | size_t sizeParamA = 0; 35 | RPR::FResult result = rprContextGetInfo(Context, RPR_CONTEXT_LAST_ERROR_MESSAGE, 0, 0, &sizeParamA); 36 | if (RPR::IsResultSuccess(result) && sizeParamA > 1) 37 | { 38 | std::vector buffer(sizeParamA); 39 | result = rprContextGetInfo(Context, RPR_CONTEXT_LAST_ERROR_MESSAGE, buffer.size(), buffer.data(), 0); 40 | if (RPR::IsResultSuccess(result)) 41 | { 42 | errorMessage = ANSI_TO_TCHAR(buffer.data()); 43 | } 44 | } 45 | 46 | return (errorMessage); 47 | } 48 | 49 | void LogLastError(FContext Context) 50 | { 51 | FString errorMessage = GetLastError(Context); 52 | if (!errorMessage.IsEmpty()) 53 | { 54 | UE_LOG(LogRPRErrors, Error, TEXT("%s"), *errorMessage); 55 | } 56 | } 57 | 58 | void LogLastErrorIfResultFailed(FContext Context, FResult Result) 59 | { 60 | if (RPR::IsResultFailed(Result)) 61 | { 62 | LogLastError(Context); 63 | } 64 | } 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Private/RPRToolsModule.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRToolsModule.h" 18 | 19 | DEFINE_LOG_CATEGORY(LogRPRTools) 20 | DEFINE_LOG_CATEGORY(LogRPRTools_Step) 21 | 22 | void FRPRToolsModule::StartupModule() 23 | { 24 | 25 | } 26 | 27 | void FRPRToolsModule::ShutdownModule() 28 | { 29 | 30 | } 31 | 32 | IMPLEMENT_MODULE(FRPRToolsModule, RPRTools) 33 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Constants/RPRConstants.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | namespace RPR 20 | { 21 | namespace Constants 22 | { 23 | const float CentimetersInMeter = 100; 24 | const float SceneTranslationScaleFromUE4ToRPR = 0.1f; 25 | const float SceneTranslationScaleFromRPRToUE4 = 1.0f / SceneTranslationScaleFromUE4ToRPR; 26 | } 27 | } -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Constants/RPRMaterialNodeParameterNames.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | namespace RPR 20 | { 21 | namespace Constants 22 | { 23 | namespace MaterialNode 24 | { 25 | static const unsigned int Color = RPR_MATERIAL_INPUT_COLOR; 26 | static const unsigned int Color0 = RPR_MATERIAL_INPUT_COLOR0; 27 | static const unsigned int Color1 = RPR_MATERIAL_INPUT_COLOR1; 28 | static const unsigned int BumpScale = RPR_MATERIAL_INPUT_SCALE; 29 | 30 | namespace Arithmetic 31 | { 32 | static const unsigned int Operation = RPR_MATERIAL_INPUT_OP; 33 | } 34 | 35 | namespace Lookup 36 | { 37 | static const unsigned int Value = RPR_MATERIAL_INPUT_VALUE; 38 | } 39 | 40 | namespace ImageTexture 41 | { 42 | static const unsigned int ImageData = RPR_MATERIAL_INPUT_DATA; 43 | static const unsigned int UV = RPR_MATERIAL_INPUT_UV; 44 | static const unsigned int UV2 = RPR_MATERIAL_INPUT_UV; 45 | } 46 | 47 | namespace UV 48 | { 49 | static const unsigned int XAxis = RPR_MATERIAL_INPUT_XAXIS; 50 | static const unsigned int ZAxis = RPR_MATERIAL_INPUT_ZAXIS; 51 | static const unsigned int UVScale = RPR_MATERIAL_INPUT_UV_SCALE; 52 | 53 | namespace Procedural 54 | { 55 | static const unsigned int Origin = RPR_MATERIAL_INPUT_ORIGIN; 56 | static const unsigned int Threshold = RPR_MATERIAL_INPUT_THRESHOLD; 57 | static const unsigned int UVType = RPR_MATERIAL_INPUT_UV_TYPE; 58 | } 59 | 60 | namespace Triplanar 61 | { 62 | static const unsigned int Weight = RPR_MATERIAL_INPUT_WEIGHT; 63 | static const unsigned int Offset = RPR_MATERIAL_INPUT_OFFSET; 64 | } 65 | } 66 | 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/FFrameBuffer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #ifdef RPRTOOLS_API 22 | #define FRAMBUFFER_DLL_API __declspec( dllexport ) 23 | #else 24 | #define FRAMBUFFER_DLL_API __declspec( dllimport ) 25 | #endif 26 | 27 | namespace RPR 28 | { 29 | 30 | class FRAMBUFFER_DLL_API FFrameBuffer 31 | { 32 | public: 33 | FFrameBuffer(); 34 | ~FFrameBuffer(); 35 | 36 | int Create(rpr_context context, rpr_framebuffer_format const format, rpr_framebuffer_desc const* fb_desc); 37 | int Destroy(); 38 | 39 | operator bool() const { return FrameBuffer != nullptr; } 40 | 41 | operator rpr_framebuffer() { return FrameBuffer; } 42 | rpr_framebuffer get() { return FrameBuffer; } 43 | 44 | FFrameBuffer(const FFrameBuffer&) = delete; 45 | FFrameBuffer& operator=(const FFrameBuffer&) = delete; 46 | private: 47 | rpr_framebuffer FrameBuffer; 48 | }; 49 | 50 | inline int ContextCreateFrameBuffer(rpr_context context, rpr_framebuffer_format const format, rpr_framebuffer_desc const* fb_desc, FFrameBuffer* out_fb) 51 | { 52 | return out_fb->Create(context, format, fb_desc); 53 | } 54 | 55 | inline int DestroyFrameBuffer(FFrameBuffer* buffer) 56 | { 57 | return buffer->Destroy(); 58 | } 59 | 60 | } // namespace RPR 61 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/FPostEffect.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #ifdef RPRTOOLS_API 22 | #define POSTEFFECT_DLL_API __declspec( dllexport ) 23 | #else 24 | #define POSTEFFECT_DLL_API __declspec( dllimport ) 25 | #endif 26 | 27 | namespace RPR 28 | { 29 | 30 | class POSTEFFECT_DLL_API FPostEffect 31 | { 32 | public: 33 | FPostEffect(); 34 | ~FPostEffect(); 35 | 36 | int Create(rpr_context context, rpr_post_effect_type type); 37 | int Destroy(); 38 | 39 | int Attach(rpr_context context); 40 | int Detach(rpr_context context); 41 | 42 | int SetFloat(const char* key, float value); 43 | int SetUInt(const char* key, unsigned int value); 44 | 45 | operator bool() const { return PostEffect != nullptr; } 46 | 47 | FPostEffect(const FPostEffect&) = delete; 48 | FPostEffect& operator=(const FPostEffect&) = delete; 49 | private: 50 | rpr_post_effect PostEffect; 51 | }; 52 | 53 | inline int ContextCreatePostEffect(rpr_context context, rpr_post_effect_type type, FPostEffect* out_post_effect) 54 | { 55 | return out_post_effect->Create(context, type); 56 | } 57 | 58 | inline int ContextAttachPostEffect(rpr_context context, FPostEffect* postEffect) 59 | { 60 | return postEffect->Attach(context); 61 | } 62 | 63 | inline int ContextDetachPostEffect(rpr_context context, FPostEffect* postEffect) 64 | { 65 | return postEffect->Detach(context); 66 | } 67 | 68 | inline int DestroyPostEffect(FPostEffect* postEffect) 69 | { 70 | return postEffect->Destroy(); 71 | } 72 | 73 | } // namespace RPR -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRCameraHelpers.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "RPRToolsModule.h" 19 | #include "Typedefs/RPRTypedefs.h" 20 | #include "Enums/RPREnums.h" 21 | 22 | namespace RPR 23 | { 24 | namespace Camera 25 | { 26 | 27 | RPRTOOLS_API RPR::FResult GetObjectName(RPR::FCamera Camera, FString& OutObjectName); 28 | RPRTOOLS_API RPR::FResult GetTransform(RPR::FCamera Camera, FTransform& OutTransform); 29 | RPRTOOLS_API RPR::FResult GetCameraMode(RPR::FCamera Camera, RPR::ECameraMode& OutCameraMode); 30 | RPRTOOLS_API RPR::FResult GetOrthoSize(RPR::FCamera Camera, FVector2D& OrthoSize); 31 | RPRTOOLS_API RPR::FResult GetNearPlane(RPR::FCamera Camera, float& NearPlane); 32 | RPRTOOLS_API RPR::FResult GetFarPlane(RPR::FCamera Camera, float& FarPlane); 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRErrorsHelpers.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Typedefs/RPRTypedefs.h" 19 | #include "Containers/UnrealString.h" 20 | 21 | namespace RPR 22 | { 23 | namespace Error 24 | { 25 | RPRTOOLS_API FString GetLastError(FContext Context); 26 | RPRTOOLS_API void LogLastError(FContext Context); 27 | RPRTOOLS_API void LogLastErrorIfResultFailed(FContext Context, FResult Result); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRImageHelpers.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Typedefs/RPRTypedefs.h" 19 | #include "Enums/RPREnums.h" 20 | #include "Containers/Array.h" 21 | #include "PixelFormat.h" 22 | #include "Engine/Texture.h" 23 | 24 | namespace RPR 25 | { 26 | namespace Image 27 | { 28 | RPRTOOLS_API RPR::FResult GetFormat(RPR::FImage Image, EPixelFormat& OutFormat); 29 | RPRTOOLS_API RPR::FResult GetDescription(RPR::FImage Image, FImageDesc& OutDescription); 30 | RPRTOOLS_API RPR::FResult GetBufferData(RPR::FImage Image, TArray& OutBuffer); 31 | RPRTOOLS_API RPR::FResult GetWrapMode(RPR::FImage Image, RPR::EImageWrapType& OutWrapMode); 32 | RPRTOOLS_API RPR::FResult GetFilterMode(RPR::FImage Image, RPR::EImageFilterType& OutFilterMode); 33 | RPRTOOLS_API RPR::FResult GetGammaValue(RPR::FImage Image, float& GammaValue); 34 | RPRTOOLS_API RPR::FResult IsMipMapEnabled(RPR::FImage Image, bool& bIsMipMapEnabled); 35 | 36 | RPRTOOLS_API bool ConvertRPRImageFormatToUE4PixelFormat(RPR::FImageFormat ImageFormat, EPixelFormat& OutPixelFormat); 37 | 38 | RPRTOOLS_API TextureAddress ConvertRPRImageWrapToUE4TextureAddress(RPR::EImageWrapType WrapType); 39 | RPRTOOLS_API RPR::EImageWrapType ConvertUE4TextureAddressToRPRImageWrap(TextureAddress InTextureAddress); 40 | }; 41 | } -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRLightHelpers.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "RPRToolsModule.h" 19 | #include "Typedefs/RPRTypedefs.h" 20 | #include "Enums/RPREnums.h" 21 | 22 | namespace RPR 23 | { 24 | namespace Light 25 | { 26 | 27 | RPRTOOLS_API RPR::FResult GetName(RPR::FLight Light, FString& OutObjectName); 28 | RPRTOOLS_API FString GetName(RPR::FLight Light); 29 | RPRTOOLS_API RPR::FResult GetWorldTransform(RPR::FLight Light, FTransform& OutTransform); 30 | RPRTOOLS_API RPR::FResult SetWorldTransform(RPR::FLight Light, FTransform Transform); 31 | RPRTOOLS_API RPR::FResult GetLightType(RPR::FLight Light, RPR::ELightType& OutLightType); 32 | RPRTOOLS_API bool IsLightPowerSupportedByLightType(RPR::ELightType LightType); 33 | RPRTOOLS_API RPR::FResult GetLightPower(RPR::FLight Light, RPR::ELightType LightType, FLinearColor& OutColor); 34 | RPRTOOLS_API RPR::FResult GetLightConeShape(RPR::FLight Light, float& OutInnerAngle, float& OutOuterAngle); 35 | RPRTOOLS_API RPR::FResult GetEnvironmentLightIntensityScale(RPR::FLight Light, float& OutLightIntensityScale); 36 | RPRTOOLS_API RPR::FResult GetEnvironmentLightImage(RPR::FLight Light, RPR::FImage& OutImage); 37 | RPRTOOLS_API RPR::FResult GetDirectionalShadowSoftness(RPR::FLight Light, float& OutShadowSoftness); 38 | 39 | namespace Constants 40 | { 41 | const float kLumensToW = 1.0f / 17.0f; 42 | const float kW = 100.0f; 43 | const float kDirLightIntensityMultiplier = 1.0f; 44 | 45 | const float kIESLightIntensityScale = 0.01f; 46 | const float kPointLightIntensityScale = 10.0f; 47 | const float kSpotLightIntensityScale = 10.0f; 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRMeshHelper.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Typedefs/RPRTypedefs.h" 19 | #include "Enums/RPREnums.h" 20 | #include "Containers/Array.h" 21 | #include "Templates/Function.h" 22 | 23 | namespace RPR 24 | { 25 | namespace Mesh 26 | { 27 | RPRTOOLS_API RPR::FResult GetVertices(RPR::FShape Shape, TArray& OutVertices); 28 | RPRTOOLS_API RPR::FResult GetVerticesCount(RPR::FShape Shape, uint32& OutVerticesCount); 29 | RPRTOOLS_API RPR::FResult GetVertexIndexes(RPR::FShape Shape, TArray& OutVerticesIndexes); 30 | RPRTOOLS_API RPR::FResult GetVerticesIndexesStride(RPR::FShape Shape, uint32& OutStride); 31 | 32 | RPRTOOLS_API RPR::FResult GetNormals(RPR::FShape Shape, TArray& OutNormals); 33 | RPRTOOLS_API RPR::FResult GetNormalsCount(RPR::FShape Shape, uint32& OutNormalsCount); 34 | RPRTOOLS_API RPR::FResult GetNormalsIndexes(RPR::FShape Shape, TArray& OutNormalsIndexes); 35 | RPRTOOLS_API RPR::FResult GetNormalsIndexesStride(RPR::FShape Shape, uint32& OutStride); 36 | 37 | RPRTOOLS_API RPR::FResult GetUV(RPR::FShape Shape, uint32 UVChannel, TArray& OutUVs); 38 | RPRTOOLS_API RPR::FResult GetUVCount(RPR::FShape Shape, uint32 UVChannel, uint32& OutUVsCount); 39 | RPRTOOLS_API RPR::FResult GetNumUV(RPR::FShape Shape, uint32& OutNumUVChannels); 40 | RPRTOOLS_API RPR::FResult GetUVsIndexesStride(RPR::FShape Shape, uint32& OutStride); 41 | 42 | RPRTOOLS_API RPR::FResult GetNumFaceVertices(RPR::FShape, TArray& OutNumFaceVertices); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRSceneHelpers.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Typedefs/RPRTypedefs.h" 19 | 20 | namespace RPR 21 | { 22 | namespace Scene 23 | { 24 | RPRTOOLS_API RPR::FResult AttachShape(FScene Scene, FShape Shape); 25 | RPRTOOLS_API RPR::FResult DetachShape(FScene Scene, FShape Shape); 26 | 27 | RPRTOOLS_API RPR::FResult AttachLight(FScene Scene, FLight Light); 28 | RPRTOOLS_API RPR::FResult DetachLight(FScene Scene, FLight Light); 29 | 30 | RPRTOOLS_API RPR::FResult GetShapes(RPR::FScene Scene, TArray& OutShapes); 31 | RPRTOOLS_API RPR::FResult GetLights(RPR::FScene Scene, TArray& OutLights); 32 | 33 | RPRTOOLS_API RPR::FResult GetShapesCount(RPR::FScene Scene, int32& OutShapesNum); 34 | RPRTOOLS_API RPR::FResult GetLightsCount(RPR::FScene Scene, int32& OutLightsNum); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRSceneStandardizer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Typedefs/RPRTypedefs.h" 19 | #include "Containers/Array.h" 20 | 21 | namespace RPR 22 | { 23 | class RPRTOOLS_API FSceneStandardizer 24 | { 25 | private: 26 | 27 | // Data struct to cache mesh data from mesh instance and re-use it for every instance 28 | struct FMeshData 29 | { 30 | TArray Vertices; 31 | TArray Normals; 32 | TArray Indices; 33 | TArray TexCoords; 34 | TArray NumFacesVertices; 35 | RPR::FMaterialNode Material; 36 | }; 37 | 38 | public: 39 | static RPR::FResult CreateStandardizedScene(RPR::FContext Context, RPR::FScene Scene, RPR::FScene& OutNormalizedScene); 40 | 41 | // Delete all resources that could have been created during the standardized scene creation 42 | static RPR::FResult ReleaseStandardizedScene(RPR::FScene Scene); 43 | 44 | private: 45 | 46 | // Copy shapes and transform shape instances into shape meshes 47 | static void StandardizeShapes(RPR::FContext Context, RPR::FScene SrcScene, RPR::FScene DstScene); 48 | 49 | static FMeshData* FindOrCacheMeshShape(TMap& MeshDataCache, FShape ShapeInstance, FShape MeshShape); 50 | 51 | static void CopyAllLights(RPR::FContext Context, RPR::FScene SrcScene, RPR::FScene DstScene); 52 | 53 | static void ScaleVectors(TArray& Vectors, float Scale); 54 | 55 | }; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Helpers/RPRShapeHelpers.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "Modules/ModuleManager.h" 19 | #include "Typedefs/RPRTypedefs.h" 20 | #include "Enums/RPREnums.h" 21 | #include "Helpers/RPRHelpers.h" 22 | #include "Helpers/GenericGetInfo.h" 23 | 24 | DECLARE_LOG_CATEGORY_EXTERN(LogRPRShapeHelpers, Log, All); 25 | 26 | namespace RPR 27 | { 28 | namespace Shape 29 | { 30 | RPRTOOLS_API RPR::FResult GetName(RPR::FShape Shape, FString& OutName); 31 | RPRTOOLS_API FString GetName(RPR::FShape Shape); 32 | RPRTOOLS_API RPR::FResult GetMaterial(RPR::FShape Shape, RPR::FMaterialNode& OutMaterialNode); 33 | RPRTOOLS_API RPR::FResult GetType(RPR::FShape Shape, RPR::EShapeType& OutShapeType); 34 | RPRTOOLS_API RPR::FResult GetWorldTransform(RPR::FShape Shape, FTransform& OutTransform); 35 | RPRTOOLS_API RPR::FResult SetTransform(RPR::FShape Shape, const FTransform& Transform); 36 | 37 | /* Get the shape on which a shape instance is based. 38 | * It is not the parent of the shape in the hierarchy! 39 | */ 40 | RPRTOOLS_API RPR::FResult GetInstanceBaseShape(RPR::FShape Shape, RPR::FShape& OutShape); 41 | 42 | RPRTOOLS_API RPR::FResult SetMaterial(FShape Shape, RPR::FMaterialNode MaterialNode); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Miscs/NumericRestriction.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | #include "RPRToolsModule.h" 19 | 20 | template 21 | class FNumericRestriction 22 | { 23 | public: 24 | 25 | FNumericRestriction() 26 | : bHasMinimum(false) 27 | , bHasMaximum(false) 28 | , Minimum(TNumericLimits::Lowest()) 29 | , Maximum(TNumericLimits::Max()) 30 | {} 31 | 32 | void SetRange(NumericType InMinimum, NumericType InMaximum) 33 | { 34 | SetMinimum(InMinimum); 35 | SetMaximum(InMaximum); 36 | } 37 | 38 | // Set the range from 0 to 1 39 | void SetRange01() 40 | { 41 | SetRange(0.0f, 1.0f); 42 | } 43 | 44 | void SetMinimum(NumericType InMinimum) 45 | { 46 | bHasMinimum = true; 47 | Minimum = InMinimum; 48 | } 49 | 50 | void SetMaximum(NumericType InMaximum) 51 | { 52 | bHasMaximum = true; 53 | Maximum = InMaximum; 54 | } 55 | 56 | bool IsConstrainedByMinimum() const 57 | { 58 | return (bHasMinimum); 59 | } 60 | 61 | bool IsConstrainedByMaximum() const 62 | { 63 | return (bHasMaximum); 64 | } 65 | 66 | bool IsConstrainedByMinimumAndMaximum() const 67 | { 68 | return (IsConstrainedByMinimum() && IsConstrainedByMaximum()); 69 | } 70 | 71 | NumericType GetMinimum() const 72 | { 73 | return (Minimum); 74 | } 75 | 76 | NumericType GetMaximum() const 77 | { 78 | return (Maximum); 79 | } 80 | 81 | private: 82 | 83 | bool bHasMinimum; 84 | bool bHasMaximum; 85 | 86 | NumericType Minimum; 87 | NumericType Maximum; 88 | 89 | }; 90 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/RPRToolsModule.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Modules/ModuleManager.h" 21 | 22 | DECLARE_LOG_CATEGORY_EXTERN(LogRPRTools, All, All); 23 | 24 | // Used to trace rendering steps 25 | DECLARE_LOG_CATEGORY_EXTERN(LogRPRTools_Step, Verbose, Verbose); 26 | 27 | class FRPRToolsModule : public IModuleInterface 28 | { 29 | public: 30 | virtual void StartupModule() override; 31 | virtual void ShutdownModule() override; 32 | }; 33 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/Public/Typedefs/RPRTypedefs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "Templates/SharedPointer.h" 20 | #include 21 | #include "FFrameBuffer.h" 22 | #include "FPostEffect.h" 23 | 24 | /* 25 | * Use typedefs to associate native types with clearer names (and respecting the UE4 norm) 26 | */ 27 | namespace RPR 28 | { 29 | typedef rpr_int FResult; 30 | 31 | typedef rpr_int FPluginId; 32 | typedef rpr_creation_flags FCreationFlags; 33 | typedef rpr_context_properties FContextProperties; 34 | 35 | typedef rpr_context FContext; 36 | typedef rpr_material_system FMaterialSystem; 37 | typedef rpr_scene FScene; 38 | 39 | typedef rpr_shape FShape; 40 | typedef rpr_light FLight; 41 | typedef rpr_image FImage; 42 | typedef rpr_camera FCamera; 43 | typedef rpr_image_format FImageFormat; 44 | typedef rpr_image_desc FImageDesc; 45 | 46 | typedef rpr_material_node_info FMaterialNodeInfo; 47 | typedef rpr_material_node_input_info FMaterialNodeInputInfo; 48 | typedef rpr_material_node_type FMaterialNodeType; 49 | typedef rpr_material_node_input_type FMaterialNodeInputType; 50 | 51 | typedef rpr_material_node_arithmetic_operation FMaterialNodeArithmeticOperation; 52 | 53 | typedef void* FMaterialRawDatas; 54 | typedef rpr_material_node FMaterialNode; 55 | 56 | typedef rpr_material_system_type FMaterialSystemType; 57 | 58 | typedef TSharedPtr FImagePtr; 59 | typedef TWeakPtr FImageWeakPtr; 60 | } 61 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/RPRTools/RPRTools.Build.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | using System; // Console.WriteLine(""); 18 | using System.IO; 19 | using UnrealBuildTool; 20 | 21 | /// 22 | /// Primary runtime module on which any other module can depend. 23 | /// This module only provide tools that will *never* need other RPR dependencies. 24 | /// 25 | public class RPRTools : ModuleRules 26 | { 27 | public RPRTools(ReadOnlyTargetRules Target) : base(Target) 28 | { 29 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 30 | 31 | PrivateIncludePaths.AddRange( 32 | new string[] { 33 | "RPRTools/Public", 34 | "RPRTools/Private", 35 | System.IO.Path.Combine(ModuleDirectory, @"../../ThirdParty/gli"), 36 | System.IO.Path.Combine(ModuleDirectory, @"../../ThirdParty/glm"), 37 | System.IO.Path.Combine(ModuleDirectory, @"../../ThirdParty"), 38 | } 39 | ); 40 | 41 | PublicIncludePaths.AddRange( 42 | new string[] { 43 | System.IO.Path.Combine(ModuleDirectory, @"../../ThirdParty/gli"), 44 | System.IO.Path.Combine(ModuleDirectory, @"../../ThirdParty/glm"), 45 | System.IO.Path.Combine(ModuleDirectory, @"../../ThirdParty"), 46 | } 47 | ); 48 | 49 | PublicDependencyModuleNames.AddRange( 50 | new string[] 51 | { 52 | "RPR_SDK" 53 | // ... add other public dependencies that you statically link with here ... 54 | } 55 | ); 56 | 57 | 58 | PrivateDependencyModuleNames.AddRange( 59 | new string[] 60 | { 61 | "Core", 62 | "CoreUObject", 63 | "Engine", 64 | "RenderCore", 65 | // ... add private dependencies that you statically link with here ... 66 | }); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Plugins/RPRPlugin/Source/SDK/Public/RPR_SDKModule.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "Modules/ModuleManager.h" 21 | 22 | class RPR_SDK_API FRPR_SDKModule : public IModuleInterface 23 | { 24 | public: 25 | 26 | FRPR_SDKModule(); 27 | 28 | virtual void StartupModule() override; 29 | virtual void ShutdownModule() override; 30 | 31 | static FString GetDLLsDirectory(FString sdk); 32 | 33 | static bool IsSDKLoadValid(); 34 | static bool IsLoaded(); 35 | 36 | private: 37 | bool bIsSDKLoadValid; 38 | }; 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RadeonProRenderUE 2 | 3 | # Setup project 4 | 5 | ## Generate Visual Studio files 6 | 7 | Right-click on RPR.uproject and select "Generate Visual Studio project files".
8 | It should create a "RPR.sln" file 9 | 10 | ## Compile 11 | 12 | - Open the "RPR.sln" file. 13 | - Check that your build configuration is in "Development Editor" (or "DebugGame Editor") 14 | - Press "Local Windows Debugger" to start the build. 15 | 16 | At the end of the build, the project should start. 17 | 18 | 19 | # Build the RPR plugin for marketplace 20 | 21 | ## For the first time 22 | 23 | You will need to set an environment variable that will tell to the build script where is your UE4 installation. 24 | 25 | ### Unix (Linux/MacOSX) 26 | 27 | - Open a terminal 28 | - Write `setenv UE4_Path **[Path to the root of your UE4 installation]**`. Add **"** around your path if there is spaces in it.
29 | Example : 30 | - `setenv UE4_Path D:/Softwares/UE_4.18` 31 | - `setenv UE4_Path "~/softs/my UE4 installation"` 32 | 33 | 34 | ## Start the build 35 | 36 | ### Windows 37 | 38 | - Enter the directory **BuildPluginTools** 39 | - Start **Build_RPRPlugin_XXX.bat** with **XXX** being the version you want (using double-click) 40 | - Wait for everything to be setup. It will take a while since it will compile the whole plugin and copy some binary/image files.
41 | - Once your build is over, go to **PluginStaging\UE4_[YourUE4Version]** 42 | - Your plugin is right here, ready to be zipped in hosted 43 | 44 | ![Screenshot of Build_RPRPlugin.bat in action](Medias/BuildRPRPlugin_Screenshot01.jpg "Build_RPRPlugin.bat in action") 45 | 46 | You can also use **Build_RPRPlugin_All.bat** to build on all versions. 47 | 48 | 49 | ### Unix (Linux/MacOSX) 50 | 51 | - Open a terminal 52 | - Navigate through **RadeonProRenderUE/BuildPluginTools** (use `cd` and `ls` to respectively move among the directories and list files in the current directory). 53 | - Start the build script using `./Build_RPRPlugin.sh` 54 | - The **UE4_Path** should be displayed at the beginning. Check that it is correct. 55 | - Wait for the build to be completed. Press **Ctrl+C** if you want to abort the operation. 56 | - Once your build is over, go to **PluginStaging/UE4_[YourUE4Version]** 57 | - Your plugin is right here, ready to be zipped in hosted 58 | -------------------------------------------------------------------------------- /RPR.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.20", 4 | "Category": "Code Plugins", 5 | "Description": "Radeon Pro Render", 6 | "Modules": [ 7 | { 8 | "Name": "RPR", 9 | "Type": "Editor", 10 | "LoadingPhase": "Default", 11 | "AdditionalDependencies": [ 12 | "Engine" 13 | ] 14 | } 15 | ], 16 | "TargetPlatforms": [ 17 | "AllDesktop", 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /Source/RPR.Target.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | using UnrealBuildTool; 18 | using System.Collections.Generic; 19 | 20 | public class RPRTarget : TargetRules 21 | { 22 | public RPRTarget(TargetInfo Target) : base(Target) 23 | { 24 | Type = TargetType.Game; 25 | 26 | ExtraModuleNames.AddRange( new string[] { "RPR" } ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/RPR/RPR.Build.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | using UnrealBuildTool; 18 | 19 | public class RPR : ModuleRules 20 | { 21 | public RPR(ReadOnlyTargetRules Target) : base(Target) 22 | { 23 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 24 | 25 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"/*, 26 | "RPRPlugin"*/ }); 27 | 28 | PrivateDependencyModuleNames.AddRange(new string[] { }); 29 | 30 | // Uncomment if you are using Slate UI 31 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 32 | 33 | // Uncomment if you are using online features 34 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 35 | 36 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/RPR/RPR.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPR.h" 18 | #include "Modules/ModuleManager.h" 19 | 20 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, RPR, "RPR" ); 21 | -------------------------------------------------------------------------------- /Source/RPR/RPR.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | 21 | -------------------------------------------------------------------------------- /Source/RPR/RPRGameModeBase.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "RPRGameModeBase.h" 18 | -------------------------------------------------------------------------------- /Source/RPR/RPRGameModeBase.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "GameFramework/GameModeBase.h" 21 | #include "RPRGameModeBase.generated.h" 22 | 23 | UCLASS() 24 | class RPR_API ARPRGameModeBase : public AGameModeBase 25 | { 26 | GENERATED_BODY() 27 | }; 28 | -------------------------------------------------------------------------------- /Source/RPR/actorRPRHandler.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #include "actorRPRHandler.h" 18 | 19 | 20 | // Sets default values 21 | AactorRPRHandler::AactorRPRHandler() 22 | { 23 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 24 | PrimaryActorTick.bCanEverTick = true; 25 | 26 | } 27 | 28 | // Called when the game starts or when spawned 29 | void AactorRPRHandler::BeginPlay() 30 | { 31 | Super::BeginPlay(); 32 | 33 | } 34 | 35 | // Called every frame 36 | void AactorRPRHandler::Tick(float DeltaTime) 37 | { 38 | Super::Tick(DeltaTime); 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Source/RPR/actorRPRHandler.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | #pragma once 18 | 19 | #include "CoreMinimal.h" 20 | #include "GameFramework/Actor.h" 21 | #include "actorRPRHandler.generated.h" 22 | 23 | UCLASS() 24 | class RPR_API AactorRPRHandler : public AActor 25 | { 26 | GENERATED_BODY() 27 | 28 | public: 29 | // Sets default values for this actor's properties 30 | AactorRPRHandler(); 31 | 32 | protected: 33 | // Called when the game starts or when spawned 34 | virtual void BeginPlay() override; 35 | 36 | public: 37 | // Called every frame 38 | virtual void Tick(float DeltaTime) override; 39 | 40 | 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /Source/RPREditor.Target.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright 2020 Advanced Micro Devices 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *************************************************************************/ 16 | 17 | using UnrealBuildTool; 18 | using System.Collections.Generic; 19 | 20 | public class RPREditorTarget : TargetRules 21 | { 22 | public RPREditorTarget(TargetInfo Target) : base(Target) 23 | { 24 | Type = TargetType.Editor; 25 | 26 | ExtraModuleNames.AddRange( new string[] { "RPR" } ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/testimg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderUE/f9cf8d32fad1e7bb157c3ff63aa14cc5a8bd00df/Source/testimg.png --------------------------------------------------------------------------------