UE4.26材质剖析-Details-Material

本文详细介绍了Unreal Engine 4中的材质系统核心概念,包括Material Domain、Blend Mode、Decal Blend Mode、Shading Model等,并解释了它们的作用及应用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、Material Domain

这玩意定义在MaterialShared.h文件里面,具体定义如下图。

/** Defines the domain of a material. */
UENUM()
enum EMaterialDomain
{
	/** The material's attributes describe a 3d surface. */
	MD_Surface UMETA(DisplayName = "Surface"),
	/** The material's attributes describe a deferred decal, and will be mapped onto the decal's frustum. */
	MD_DeferredDecal UMETA(DisplayName = "Deferred Decal"),
	/** The material's attributes describe a light's distribution. */
	MD_LightFunction UMETA(DisplayName = "Light Function"),
	/** The material's attributes describe a 3d volume. */
	MD_Volume UMETA(DisplayName = "Volume"),
	/** The material will be used in a custom post process pass. */
	MD_PostProcess UMETA(DisplayName = "Post Process"),
	/** The material will be used for UMG or Slate UI */
	MD_UI UMETA(DisplayName = "User Interface"),
	/** The material will be used for runtime virtual texture (Deprecated). */
	MD_RuntimeVirtualTexture UMETA(Hidden),

	MD_MAX
};

2、Blend Mode

这玩意定义在EngineTypes.h文件中,具体定义如下图。

/**
 * The blending mode for materials
 * @warning This is mirrored in Lightmass, be sure to update the blend mode structure and logic there if this changes. 
 * @warning Check UMaterialInstance::Serialize if changed!!
 */
UENUM(BlueprintType)
enum EBlendMode
{
	BLEND_Opaque UMETA(DisplayName="Opaque"),
	BLEND_Masked UMETA(DisplayName="Masked"),
	BLEND_Translucent UMETA(DisplayName="Translucent"),
	BLEND_Additive UMETA(DisplayName="Additive"),
	BLEND_Modulate UMETA(DisplayName="Modulate"),
	BLEND_AlphaComposite UMETA(DisplayName = "AlphaComposite (Premultiplied Alpha)"),
	BLEND_AlphaHoldout UMETA(DisplayName = "AlphaHoldout"),
	BLEND_MAX,
};

3、Decal Blend Mode

这玩意定义在Material.h文件中,具体定义如下图。

/** Defines how the GBuffer channels are getting manipulated by a decal material pass. Actual index is used to control shader parameters so don't change order. */
UENUM()
enum EDecalBlendMode
{
	/** Blend full material, updating the GBuffer, does not work for baked lighting. */
	DBM_Translucent UMETA(DisplayName="Translucent"),
	/** Modulate BaseColor, blend rest, updating the GBuffer, does not work for baked lighting. Does not work in DBuffer mode (approximated as Translucent). */
	DBM_Stain UMETA(DisplayName="Stain"),
	/** Only blend normal, updating the GBuffer, does not work for baked lighting. */
	DBM_Normal UMETA(DisplayName="Normal"),
	/** Additive emissive only. */
	DBM_Emissive UMETA(DisplayName="Emissive"),
	/** Put into DBuffer to work for baked lighting as well (becomes DBM_TranslucentNormal if normal is not hooked up). */
	DBM_DBuffer_ColorNormalRoughness UMETA(DisplayName="DBuffer Translucent Color,Normal,Roughness"),
	/** Put into DBuffer to work for baked lighting as well. */
	DBM_DBuffer_Color UMETA(DisplayName="DBuffer Translucent Color"),
	/** Put into DBuffer to work for baked lighting as well (becomes DBM_DBuffer_Color if normal is not hooked up). */
	DBM_DBuffer_ColorNormal UMETA(DisplayName="DBuffer Translucent Color,Normal"),
	/** Put into DBuffer to work for baked lighting as well. */
	DBM_DBuffer_ColorRoughness UMETA(DisplayName="DBuffer Translucent Color,Roughness"),
	/** Put into DBuffer to work for baked lighting as well. */
	DBM_DBuffer_Normal UMETA(DisplayName="DBuffer Translucent Normal"),
	/** Put into DBuffer to work for baked lighting as well (becomes DBM_DBuffer_Roughness if normal is not hooked up). */
	DBM_DBuffer_NormalRoughness UMETA(DisplayName="DBuffer Translucent Normal,Roughness"),
	/** Put into DBuffer to work for baked lighting as well. */
	DBM_DBuffer_Roughness UMETA(DisplayName="DBuffer Translucent Roughness"),

	/** Internal DBffer decal blend modes used for auto-converted decals */
	DBM_DBuffer_Emissive UMETA(DisplayName = "DBuffer Emissive", Hidden),
	DBM_DBuffer_AlphaComposite UMETA(DisplayName = "DBuffer AlphaComposite (Premultiplied Alpha)", Hidden),
	DBM_DBuffer_EmissiveAlphaComposite UMETA(DisplayName = "DBuffer Emissive AlphaComposite (Premultiplied Alpha)", Hidden),

	/** Output signed distance in Opacity depending on LightVector. Note: Can be costly, no shadow casting but receiving, no per pixel normal yet, no quality settings yet */
	DBM_Volumetric_DistanceFunction UMETA(DisplayName="Volumetric Distance Function (experimental)"),
	
	/** Blend with existing scene color. Decal color is already pre-multiplied by alpha. */
	DBM_AlphaComposite UMETA(DisplayName ="AlphaComposite (Premultiplied Alpha)"),

	/** Ambient occlusion. */
	DBM_AmbientOcclusion UMETA(DisplayName = "Ambient Occlusion"),

	DBM_MAX,
};

4、ShadingModel

这玩意定义在EngineTypes.h文件中,具体定义如下图。

/** 
 * Specifies the overal rendering/shading model for a material
 * @warning Check UMaterialInstance::Serialize if changed!
 */
UENUM()
enum EMaterialShadingModel
{
	MSM_Unlit					UMETA(DisplayName="Unlit"),
	MSM_DefaultLit				UMETA(DisplayName="Default Lit"),
	MSM_Subsurface				UMETA(DisplayName="Subsurface"),
	MSM_PreintegratedSkin		UMETA(DisplayName="Preintegrated Skin"),
	MSM_ClearCoat				UMETA(DisplayName="Clear Coat"),
	MSM_SubsurfaceProfile		UMETA(DisplayName="Subsurface Profile"),
	MSM_TwoSidedFoliage			UMETA(DisplayName="Two Sided Foliage"),
	MSM_Hair					UMETA(DisplayName="Hair"),
	MSM_Cloth					UMETA(DisplayName="Cloth"),
	MSM_Eye						UMETA(DisplayName="Eye"),
	MSM_SingleLayerWater		UMETA(DisplayName="SingleLayerWater"),
	MSM_ThinTranslucent			UMETA(DisplayName="Thin Translucent"),
	/** Number of unique shading models. */
	MSM_NUM						UMETA(Hidden),
	/** Shading model will be determined by the Material Expression Graph,
		by utilizing the 'Shading Model' MaterialAttribute output pin. */
	MSM_FromMaterialExpression	UMETA(DisplayName="From Material Expression"),
	MSM_MAX
};

5、TwoSided

这玩意定义在Material.h文件中,具体定义如下图。

/** Indicates that the material should be rendered without backface culling and the normal should be flipped for backfaces. */
	UPROPERTY(EditAnywhere, Category=Material)
	uint8 TwoSided : 1;

6、UseMaterialAttributes

这玩意定义在Material.h文件中,具体定义如下图。

/** when true, the material attributes pin is used instead of the regular pins. */
	UPROPERTY(EditAnywhere, Category=Material)
	uint8 bUseMaterialAttributes : 1;

7、CastRayTracedShadows

这玩意定义在Material.h文件中,具体定义如下图。

	/** when true, the material casts ray tracing shadows. */
	UPROPERTY(EditAnywhere, Category = Material)
	uint8 bCastRayTracedShadows : 1;

8、SubsurfaceProfile

这玩意定义在SubsurfaceProfile.h文件中,具体定义如下图。

/**
 * Subsurface Scattering profile asset, can be specified at the material. Only for "Subsurface Profile" materials, is use during Screenspace Subsurface Scattering
 * Don't change at runtime. All properties in here are per material - texture like variations need to come from properties that are in the GBuffer.
 */
UCLASS(autoexpandcategories = SubsurfaceProfile, MinimalAPI)
class USubsurfaceProfile : public UObject
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(Category = USubsurfaceProfile, EditAnywhere, meta = (ShowOnlyInnerProperties))
	struct FSubsurfaceProfileStruct Settings;

	//~ Begin UObject Interface
	virtual void BeginDestroy();
	virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent);

	// Upgrade parameters from Separable to Burley.
	virtual void PostLoad();
	//~ End UObject Interface
};

9、有空补充

 

<think>好的,我需要解决用户遇到的CarlaUE4在运行时的信号11崩溃问题,特别是UE4版本4.26.2,涉及大内存池分配和核心转储禁用的情况。首先,我需要回顾用户提供的引用内容,分析可能的原因,并逐步寻找解决方案。 根据引用[1]中的错误信息,提到了“GameThread timed out waiting for RenderThread after 60.00 secs”,这表明渲染线程可能出现了问题,导致主线程超时。同时,信号11(段错误)通常与内存访问错误有关,比如访问了未分配的内存或越界访问。此外,引用[2]指出地址已被占用,可能导致端口冲突。 接下来,我需要考虑可能的解决方法。首先检查端口占用情况,如用户提到的后台Carla服务或其他用户可能占用了相同端口。使用命令如`netstat -tuln | grep 2000`(假设默认端口是2000)查看端口占用,终止相关进程。 然后,内存管理方面的问题。大内存分配失败可能导致段错误。用户可尝试调整CarlaUE4的内存分配参数,比如在启动命令中加入`-malloc=system`来使用系统默认分配器,或设置内存池大小限制如`-LowMem`。 显卡驱动和Vulkan API的问题也可能导致渲染线程崩溃。确保使用NVIDIA显卡并安装最新驱动,添加`-prefernvidia`和`-vulkan`参数到启动命令中。此外,验证UE4项目完整性,重新生成项目文件可能修复编译问题。 如果问题依旧,启用核心转储有助于进一步分析。用户需要临时启用核心转储(`ulimit -c unlimited`),运行Carla直到崩溃,然后用gdb分析core文件。同时,检查日志文件(如Saved/Logs/UnrealEngine.log)中的详细错误信息。 版本兼容性方面,确认Carla版本与UE4 4.26.2的兼容性,必要时更新或回退版本。如果所有方法无效,可能需要联系Carla社区或Epic Games支持,提供详细日志和核心转储文件。 最后,总结步骤,确保用户能逐步操作,并提醒备份和社区支持的重要性。</think>### CarlaUE4信号11崩溃问题解决步骤 #### 一、端口冲突排查 1. **检查端口占用** 运行命令查看默认端口(通常为2000-2004)是否被占用: ```bash netstat -tuln | grep 2000 ``` 若发现占用进程,终止相关进程: ```bash kill <PID> # 替换<PID>为实际进程号 ``` 2. **修改默认端口** 在启动命令中指定其他端口: ```bash ./CarlaUE4.sh -carla-rpc-port=3000 ``` #### 二、内存分配优化 1. **调整内存分配器** 添加`-malloc=system`参数使用系统分配器,避免UE4自定义分配器的问题: ```bash ./CarlaUE4.sh -malloc=system -prefernvidia ``` 2. **限制内存池大小** 添加`-LowMem`参数适配低内存模式: ```bash ./CarlaUE4.sh -LowMem ``` #### 三、图形渲染修复 1. **强制使用NVIDIA显卡** 添加参数确保优先使用NVIDIA驱动: ```bash ./CarlaUE4.sh -prefernvidia -vulkan ``` 2. **更新显卡驱动** 安装NVIDIA最新驱动(以Ubuntu为例): ```bash sudo apt install nvidia-driver-535 ``` #### 四、核心转储分析(临时启用) 1. **解除核心转储限制** 临时允许生成核心转储文件: ```bash ulimit -c unlimited ``` 2. **运行并捕获崩溃** 启动CarlaUE4直至崩溃,生成`core`文件: ```bash ./CarlaUE4.sh ``` 3. **使用GDB分析** 通过GDB调试核心转储文件: ```bash gdb CarlaUE4-Linux-Shipping core ``` 在GDB中输入`bt`查看堆栈追踪,定位崩溃位置。 #### 五、日志与版本验证 1. **检查引擎日志** 查看日志文件`YourProject/Saved/Logs/UnrealEngine.log`,搜索`Fatal error`或`Signal 11`相关条目。 2. **验证UE4版本兼容性** 确认使用的Carla版本是否支持UE4 4.26.2。若需降级,参考Carla官方文档重新编译。 #### 六、其他解决方案 1. **清理项目缓存** 删除中间文件避免缓存冲突: ```bash rm -rf ~/.config/Epic/CarlaUE4/ ``` 2. **重编译UE4项目** 重新生成UE4项目文件: ```bash make rebuild ``` --- ### 引用说明 - **端口占用问题**:若后台Carla服务或他人占用端口会导致绑定失败[^2]。 - **内存分配错误**:大内存池分配失败可能引发段错误[^1]。 - **渲染线程超时**:GameThread等待RenderThread超时可能与显卡驱动或API相关[^1]。 ---
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嘿克不黑

你的鼓励是我的最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值