UE编辑器灯光颜色,能量传入Shader流程

编辑器界面:

 

 代码流程:

FLinearColor ULightComponent::GetColoredLightBrightness() const
{// Brightness in Lumensfloat LightBrightness = ComputeLightBrightness();FLinearColor Energy = FLinearColor(LightColor) * LightBrightness;if (bUseTemperature){Energy *= FLinearColor::MakeFromColorTemperature(Temperature);}return Energy;
}/** * Filter color of the light.* Note that this can change the light's effective intensity.*/
UPROPERTY(BlueprintReadOnly, interp, Category=Light, meta=(HideAlphaChannel, ShouldShowInViewport = true))FColor LightColor;FORCEINLINE FLinearColor::FLinearColor(const FColor& Color)
{R = sRGBToLinearTable[Color.R];G = sRGBToLinearTable[Color.G];B = sRGBToLinearTable[Color.B];A = float(Color.A) * (1.0f / 255.0f);
}float ULightComponent::ComputeLightBrightness() const
{float LightBrightness = Intensity;if(IESTexture){if(bUseIESBrightness){LightBrightness = IESTexture->Brightness * IESBrightnessScale;}LightBrightness *= IESTexture->TextureMultiplier;}return LightBrightness;
}FLinearColor FLinearColor::MakeFromColorTemperature( float Temp )
{Temp = FMath::Clamp( Temp, 1000.0f, 15000.0f );// Approximate Planckian locus in CIE 1960 UCSfloat u = ( 0.860117757f + 1.54118254e-4f * Temp + 1.28641212e-7f * Temp*Temp ) / ( 1.0f + 8.42420235e-4f * Temp + 7.08145163e-7f * Temp*Temp );float v = ( 0.317398726f + 4.22806245e-5f * Temp + 4.20481691e-8f * Temp*Temp ) / ( 1.0f - 2.89741816e-5f * Temp + 1.61456053e-7f * Temp*Temp );float x = 3.0f * u / ( 2.0f * u - 8.0f * v + 4.0f );float y = 2.0f * v / ( 2.0f * u - 8.0f * v + 4.0f );float z = 1.0f - x - y;float Y = 1.0f;float X = Y/y * x;float Z = Y/y * z;// XYZ to RGB with BT.709 primariesfloat R =  3.2404542f * X + -1.5371385f * Y + -0.4985314f * Z;float G = -0.9692660f * X +  1.8760108f * Y +  0.0415560f * Z;float B =  0.0556434f * X + -0.2040259f * Y +  1.0572252f * Z;return FLinearColor(R,G,B);
}
void FLightRenderParameters::MakeShaderParameters(const FViewMatrices& ViewMatrices, float Exposure, FLightShaderParameters& OutShaderParameters) const
{OutShaderParameters.TranslatedWorldPosition = FVector3f(ViewMatrices.GetPreViewTranslation() + WorldPosition);OutShaderParameters.InvRadius = InvRadius;OutShaderParameters.Color = FVector3f(Color) * GetLightExposureScale(Exposure);OutShaderParameters.FalloffExponent = FalloffExponent;OutShaderParameters.Direction = Direction;OutShaderParameters.SpecularScale = SpecularScale;OutShaderParameters.Tangent = Tangent;OutShaderParameters.SourceRadius = SourceRadius;OutShaderParameters.SpotAngles = SpotAngles;OutShaderParameters.SoftSourceRadius = SoftSourceRadius;OutShaderParameters.SourceLength = SourceLength;OutShaderParameters.RectLightBarnCosAngle = RectLightBarnCosAngle;OutShaderParameters.RectLightBarnLength = RectLightBarnLength;OutShaderParameters.RectLightAtlasUVOffset = RectLightAtlasUVOffset;OutShaderParameters.RectLightAtlasUVScale = RectLightAtlasUVScale;OutShaderParameters.RectLightAtlasMaxLevel = RectLightAtlasMaxLevel;
}
FLightSceneProxy::FLightSceneProxy(const ULightComponent* InLightComponent): LightComponent(InLightComponent), SceneInterface(InLightComponent->GetScene()), IndirectLightingScale(InLightComponent->IndirectLightingIntensity), VolumetricScatteringIntensity(FMath::Max(InLightComponent->VolumetricScatteringIntensity, 0.0f)), ShadowResolutionScale(InLightComponent->ShadowResolutionScale), ShadowBias(InLightComponent->ShadowBias), ShadowSlopeBias(InLightComponent->ShadowSlopeBias), ShadowSharpen(InLightComponent->ShadowSharpen), ContactShadowLength(InLightComponent->ContactShadowLength), SpecularScale(InLightComponent->SpecularScale), LightGuid(InLightComponent->LightGuid), RayStartOffsetDepthScale(InLightComponent->RayStartOffsetDepthScale), IESTexture(0), bContactShadowLengthInWS(InLightComponent->ContactShadowLengthInWS ? true : false), bMovable(InLightComponent->IsMovable()), bStaticLighting(InLightComponent->HasStaticLighting()), bStaticShadowing(InLightComponent->HasStaticShadowing()), bCastDynamicShadow(InLightComponent->CastShadows && InLightComponent->CastDynamicShadows), bCastStaticShadow(InLightComponent->CastShadows && InLightComponent->CastStaticShadows), bCastTranslucentShadows(InLightComponent->CastTranslucentShadows), bTransmission(InLightComponent->bTransmission && bCastDynamicShadow && !bStaticShadowing), bCastVolumetricShadow(InLightComponent->bCastVolumetricShadow), bCastHairStrandsDeepShadow(InLightComponent->bCastDeepShadow), bCastShadowsFromCinematicObjectsOnly(InLightComponent->bCastShadowsFromCinematicObjectsOnly), bForceCachedShadowsForMovablePrimitives(InLightComponent->bForceCachedShadowsForMovablePrimitives), CastRaytracedShadow(InLightComponent->CastShadows == 0? (TEnumAsByte<ECastRayTracedShadow::Type>) ECastRayTracedShadow::Disabled : InLightComponent->CastRaytracedShadow), bAffectReflection(InLightComponent->bAffectReflection), bAffectGlobalIllumination(InLightComponent->bAffectGlobalIllumination), bAffectTranslucentLighting(InLightComponent->bAffectTranslucentLighting), bUsedAsAtmosphereSunLight(InLightComponent->IsUsedAsAtmosphereSunLight()), bAffectDynamicIndirectLighting(InLightComponent->bAffectDynamicIndirectLighting), bUseRayTracedDistanceFieldShadows(InLightComponent->bUseRayTracedDistanceFieldShadows), bUseVirtualShadowMaps(false)	// See below, bCastModulatedShadows(false), bUseWholeSceneCSMForMovableObjects(false), AtmosphereSunLightIndex(InLightComponent->GetAtmosphereSunLightIndex()), AtmosphereSunDiskColorScale(InLightComponent->GetAtmosphereSunDiskColorScale()), LightType(InLightComponent->GetLightType())	, LightingChannelMask(GetLightingChannelMaskForStruct(InLightComponent->LightingChannels)), StatId(InLightComponent->GetStatID(true)), ComponentName(InLightComponent->GetFName()), LevelName(InLightComponent->GetOwner() ? InLightComponent->GetOwner()->GetLevel()->GetOutermost()->GetFName() : NAME_None), FarShadowDistance(0), FarShadowCascadeCount(0), ShadowAmount(1.0f), SamplesPerPixel(1), DeepShadowLayerDistribution(InLightComponent->DeepShadowLayerDistribution)
#if ACTOR_HAS_LABELS, OwnerNameOrLabel(InLightComponent->GetOwner() ? InLightComponent->GetOwner()->GetActorNameOrLabel() : InLightComponent->GetName())
#endif
{check(SceneInterface);// Currently we use virtual shadows maps for all lights when the global setting is enabledbUseVirtualShadowMaps = ::UseVirtualShadowMaps(SceneInterface->GetShaderPlatform(), SceneInterface->GetFeatureLevel());// Treat stationary lights as movable when non-nanite VSMs are enabledconst bool bNonNaniteVirtualShadowMaps = UseNonNaniteVirtualShadowMaps(SceneInterface->GetShaderPlatform(), SceneInterface->GetFeatureLevel());if (bNonNaniteVirtualShadowMaps){bStaticShadowing = bStaticLighting;}const FLightComponentMapBuildData* MapBuildData = InLightComponent->GetLightComponentMapBuildData();if (MapBuildData && bStaticShadowing && !bStaticLighting){ShadowMapChannel = MapBuildData->ShadowMapChannel;}else{ShadowMapChannel = INDEX_NONE;}// Use the preview channel if valid, otherwise fallback to the lighting build channelPreviewShadowMapChannel = InLightComponent->PreviewShadowMapChannel != INDEX_NONE ? InLightComponent->PreviewShadowMapChannel : ShadowMapChannel;StaticShadowDepthMap = &LightComponent->StaticShadowDepthMap;if(LightComponent->IESTexture){IESTexture = LightComponent->IESTexture;}Color = LightComponent->GetColoredLightBrightness();
}
FDeferredLightUniformStruct GetDeferredLightParameters(const FSceneView& View, const FLightSceneInfo& LightSceneInfo)
{FDeferredLightUniformStruct Out;FLightRenderParameters LightParameters;LightSceneInfo.Proxy->GetLightShaderParameters(LightParameters);LightParameters.MakeShaderParameters(View.ViewMatrices, View.GetLastEyeAdaptationExposure(), Out.LightParameters);
}
struct FLightRenderParameters
{ENGINE_API void MakeShaderParameters(const FViewMatrices& ViewMatrices, float Exposure, FLightShaderParameters& OutShaderParameters) const;ENGINE_API float GetLightExposureScale(float Exposure) const;static ENGINE_API float GetLightExposureScale(float Exposure, float InverseExposureBlend);// Position of the light in world space.FVector WorldPosition;// 1 / light's falloff radius from Position.float InvRadius;// Color of the light.FLinearColor Color;// The exponent for the falloff of the light intensity from the distance.float FalloffExponent;// Direction of the light if applies.FVector3f Direction;// Factor to applies on the specular.float SpecularScale;// One tangent of the light if applies.// Note: BiTangent is on purpose not stored for memory optimisation purposes.FVector3f Tangent;// Radius of the point light.float SourceRadius;// Dimensions of the light, for spot light, but alsoFVector2f SpotAngles;// Radius of the soft source.float SoftSourceRadius;// Other dimensions of the light source for rect light specifically.float SourceLength;// Barn door angle for rect lightfloat RectLightBarnCosAngle;// Barn door length for rect lightfloat RectLightBarnLength;// Rect. light atlas transformationFVector2f RectLightAtlasUVOffset;FVector2f RectLightAtlasUVScale;float RectLightAtlasMaxLevel;float InverseExposureBlend;// Return Invalid rect light atlas MIP levelstatic float GetRectLightAtlasInvalidMIPLevel() { return 32.f;  }
};

Shader对应代码:

FDeferredLightData SetupLightDataForStandardDeferred()
{FDeferredLightData LightData;LightData.TranslatedWorldPosition = GetDeferredLightTranslatedWorldPosition();LightData.InvRadius = DeferredLightUniforms_InvRadius;LightData.Color = DeferredLightUniforms_Color;LightData.FalloffExponent = DeferredLightUniforms_FalloffExponent;LightData.Direction = DeferredLightUniforms_Direction;LightData.Tangent = DeferredLightUniforms_Tangent;LightData.SpotAngles = DeferredLightUniforms_SpotAngles;LightData.SourceRadius = DeferredLightUniforms_SourceRadius;LightData.SourceLength =  1  > 0 ? DeferredLightUniforms_SourceLength : 0;LightData.SoftSourceRadius = DeferredLightUniforms_SoftSourceRadius;LightData.SpecularScale = DeferredLightUniforms_SpecularScale;LightData.ContactShadowLength = abs(DeferredLightUniforms_ContactShadowLength);LightData.ContactShadowLengthInWS = DeferredLightUniforms_ContactShadowLength < 0.0f;LightData.ContactShadowNonShadowCastingIntensity = DeferredLightUniforms_ContactShadowNonShadowCastingIntensity;LightData.DistanceFadeMAD = DeferredLightUniforms_DistanceFadeMAD;LightData.ShadowMapChannelMask = DeferredLightUniforms_ShadowMapChannelMask;LightData.ShadowedBits = DeferredLightUniforms_ShadowedBits;LightData.bInverseSquared =  1  > 0 && DeferredLightUniforms_FalloffExponent == 0;LightData.bRadialLight =  1  > 0;LightData.bSpotLight =  1  > 0;LightData.bRectLight =  1  == 2;LightData.RectLightBarnCosAngle = DeferredLightUniforms_RectLightBarnCosAngle;LightData.RectLightBarnLength = DeferredLightUniforms_RectLightBarnLength;LightData.RectLightAtlasMaxLevel = DeferredLightUniforms_RectLightAtlasMaxLevel;LightData.RectLightAtlasUVOffset = DeferredLightUniforms_RectLightAtlasUVOffset;LightData.RectLightAtlasUVScale = DeferredLightUniforms_RectLightAtlasUVScale;LightData.HairTransmittance = InitHairTransmittanceData();return LightData;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/21832.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

如何在Windows 8和10中检查最后一次的启动模式

Windows 8、Windows 8.1 和 Windows 10 中的用户可以在 PC 上执行混合关机(快速启动)、完全关机或休眠。 快速启动(又名:hiberboot、混合启动或混合关机)在 Windows 中默认打开,是一种帮助你的电脑在关机后更快启动的设置。甚至比休眠还要快。 休眠是一种主要为笔记本电…

推荐五款优秀,可替代商业软件的开源软件

​ 在日常的使用中&#xff0c;我们需要使用各种软件来提高我们的工作效率或者进行创意的表达。然而&#xff0c;商业软件价格昂贵&#xff0c;某些国产软件又充斥着广告。因此&#xff0c;开源软件成为了一个不错的选择&#xff0c;以下是我推荐的五款优秀的开源软件。 图片浏…

nginx配置IP白名单

1、添加IP白名单文件 在nginx目录的 conf 中添加文件 ip.conf&#xff0c;注意白名单文件不用添加任何注释&#xff0c;可以有空行 vi ip.conf 192.168.3.11 1;192.168.3.10 1; 192.168.0.112 1;2、配置nginx.conf 编辑http节点&#xff1a; http {# ...# geo IP whitelist…

macOS 14 Sonama - 小记

文章目录 Sonoma 官方资讯关于 Sonama 命名关于 壁纸Sonoma 官方资讯 macOS Sonoma Preview https://www.apple.com/hk/en/macos/sonoma-preview/官方视频介绍 Apple Events --> Watch the Keynote --> 00:43:13 (约14min) https://www.apple.com/hk/en/apple-events/mac…

数据库基本操作--------MySQL事务

目录 一、MySQL事务的概念 二、事务的ACID特点 1、原子性 2、一致性 3、隔离性 4、持久性 三、事务之间的相互影响 四、MySQL及事务隔离级别 1、查询全局事务隔离级别 2、查询会话事务隔离级别 3、设置全局事务隔离级别 4、设置会话事务隔离级别 五、事务控制语句 1、测…

CentOS环境下的Nginx安装

Nginx 安装 下载 nginx 下载地址&#xff1a;http://nginx.org/en/download.html 将下载好的压缩包拷贝到根目录下 通过xshell如果出现 bash: rz: 未找到命令 &#xff0c;需要先运行下面的命令 yum -y install lrzsz安装 解压到当前目录 tar -zxvf nginx-1.22.1.tar.gz安…

太阳能供电户外视频远程监控4G无线物联网工业路由器ZR3000

太阳能供电技术常被应用于环保节能的项目中&#xff0c;太阳能具备节能环保、寿命长、性能稳定、维护成本低等特点&#xff0c;被各行各业采纳使用。大多数太阳能应用于户外&#xff0c;存在监控点距离较远、取电困难、宽带光纤布线成本高、环境恶劣等问题&#xff0c;现场还有…

火山引擎云搜索服务升级云原生新架构;提供数十亿级分布式向量数据库能力

从互联网发展伊始&#xff0c;搜索技术就绽放出了惊人的社会和经济价值。随着信息社会快速发展&#xff0c;数据呈爆炸式增长&#xff0c;搜索技术通过数据收集与处理&#xff0c;满足信息共享与快速检索的需求。 云搜索服务 ESCloud 是火山引擎提供的完全托管在线分布式搜索服…

【雕爷学编程】Arduino动手做(160)---HLK-V20离线语音模块

37款传感器与模块的提法&#xff0c;在网络上广泛流传&#xff0c;其实Arduino能够兼容的传感器模块肯定是不止37种的。鉴于本人手头积累了一些传感器和执行器模块&#xff0c;依照实践出真知&#xff08;一定要动手做&#xff09;的理念&#xff0c;以学习和交流为目的&#x…

一文详解什么是数据库分片

概要 应用程序正在变得越来越好&#xff0c;它拥有更多的功能、更多的活跃用户&#xff0c;并且每天都会收集更多的数据。但数据库现在导致应用程序的其余部分变慢。数据库分片可能是问题的答案&#xff0c;但许多人不知道它是什么&#xff0c;最重要的是何时使用它。在本文中我…

3ds Max 无插件制作燃烧的火焰动画特效

推荐&#xff1a; NSDT场景编辑器助你快速搭建可二次开发的3D应用场景 在 3ds Max 中对火焰进行动画处理 如果您能找到“大气装置”设置&#xff0c;这很容易做到。基本上&#xff0c;你选择一个“Gizmo”&#xff08;BoxGizmo&#xff0c;SphereGizmo或CylGizmo&#xff09;&…

设计模式之工厂方法模式

写在前面 本文看下工厂方法设计模式。 1&#xff1a;介绍 1.1&#xff1a;什么时候用工厂方法 当我们有若干个种类的对象需要创建&#xff0c;且随着业务的发展&#xff0c;要创建的对象的种类还会不断变化&#xff0c;此时可以考虑使用工厂方法设计模式。 1.2&#xff1a…