当前位置: 首页 > news >正文

南宁网站开发东莞网络营销销售

南宁网站开发,东莞网络营销销售,wordpress 主题 激活,java网站做微信分享3.2.3 以前属于Shader部分,Shader部分不进行讲解。 这里只涉及Unity内部管线的设置问题。 文章目录 3.2.3 向GPU发送灯光数据设置光源数据设置主光源设置额外点光源 Shader中的数据 3.2.3 向GPU发送灯光数据 在UniversalRenderPipeline.cs > RenderSingleCamera…

在这里插入图片描述
3.2.3 以前属于Shader部分,Shader部分不进行讲解。
这里只涉及Unity内部管线的设置问题。

文章目录

  • 3.2.3 向GPU发送灯光数据
    • 设置光源数据
      • 设置主光源
      • 设置额外点光源
  • Shader中的数据

3.2.3 向GPU发送灯光数据

UniversalRenderPipeline.cs > RenderSingleCamera()下调用函数renderer.Execute()
在这里插入图片描述
该函数走向ScriptableRenderer.cs>Execute()函数,该函数调用了SetupLights()函数
在这里插入图片描述
SetupLights()函数为一个虚函数
在这里插入图片描述
具体实现在UniversalRenderer.cs>SetupLights()
在这里插入图片描述
该方法调用了m_ForwardLights实例下的_ForwardLights.Setup(context, ref renderingData);方法

URP中关于前向渲染的灯光设置,即在ForwardLights.cs

SetUp()函数将来自于ref RenderingData renderingData中的灯光数据发送到GPU。

public void Setup(ScriptableRenderContext context, ref RenderingData renderingData)
{CommandBuffer cmd = CommandBufferPool.Get();using (new ProfilingScope(null, m_ProfilingSampler)){// 设置ClusteredRendering(Forward+)属性参数if (useClusteredRendering){...}// 设置Shader常量属性SetupShaderLightConstants(cmd, ref renderingData);// 设置Shader关键字bool lightCountCheck = (renderingData.cameraData.renderer.stripAdditionalLightOffVariants && renderingData.lightData.supportsAdditionalLights) || additionalLightsCount > 0;CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.AdditionalLightsVertex,lightCountCheck && additionalLightsPerVertex && !useClusteredRendering);CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.AdditionalLightsPixel,lightCountCheck && !additionalLightsPerVertex && !useClusteredRendering);CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.ClusteredRendering,useClusteredRendering);...// 设置LightCookie(灯光遮罩)m_LightCookieManager.Setup(context, cmd, ref renderingData.lightData);}context.ExecuteCommandBuffer(cmd);CommandBufferPool.Release(cmd);
}

其中,关键字【ShaderKeywordStrings.AdditionalLightsVertex】 在 UniversalRenderPipelineCore中定义
在这里插入图片描述

设置光源数据

注意:这里使用引用传递传递RenderingData ,因为RenderingData 结构的数据量很大。

void SetupShaderLightConstants(CommandBuffer cmd, ref RenderingData renderingData)
{m_MixedLightingSetup = MixedLightingSetup.None;// 主光源有一个优化的主光源着色器路径。这将有利于那些只关心单一光线的游戏。// 通用管道也只支持单个阴影光,如果可用,它将是主光源。SetupMainLightConstants(cmd, ref renderingData.lightData);SetupAdditionalLightConstants(cmd, ref renderingData);
}

设置主光源

在ForwardLight中设置了如下GPU参数
在这里插入图片描述
在这里插入图片描述

void SetupMainLightConstants(CommandBuffer cmd, ref LightData lightData)
{Vector4 lightPos, lightColor, lightAttenuation, lightSpotDir, lightOcclusionChannel;uint lightLayerMask;// 根据visibleLights[mainLightIndex]数据,获取out的如下数据InitializeLightConstants(lightData.visibleLights, lightData.mainLightIndex, out lightPos, out lightColor, out lightAttenuation, out lightSpotDir, out lightOcclusionChannel, out lightLayerMask);// 将数据cmd.SetGlobalVector(LightConstantBuffer._MainLightPosition, lightPos);cmd.SetGlobalVector(LightConstantBuffer._MainLightColor, lightColor);cmd.SetGlobalVector(LightConstantBuffer._MainLightOcclusionProbesChannel, lightOcclusionChannel);cmd.SetGlobalInt(LightConstantBuffer._MainLightLayerMask, (int)lightLayerMask);
}

其中,InitializeLightConstants函数如下

void InitializeLightConstants(NativeArray<VisibleLight> lights, int lightIndex, out Vector4 lightPos, out Vector4 lightColor, out Vector4 lightAttenuation, out Vector4 lightSpotDir, out Vector4 lightOcclusionProbeChannel, out uint lightLayerMask)
{// 得到前5个数据UniversalRenderPipeline.InitializeLightConstants_Common(lights, lightIndex, out lightPos, out lightColor, out lightAttenuation, out lightSpotDir, out lightOcclusionProbeChannel);// 得到lightLayerMask lightLayerMask = 0;...lightLayerMask = (uint)additionalLightData.lightLayerMask;
}

设置额外点光源

在这里插入图片描述

额外光源与主光源相同,只是传入的数据是一个数组,数组长度与最大额外光源数相同。

核心函数:

InitializeLightConstants(lights, i, out m_AdditionalLightPositions[lightIter],out m_AdditionalLightColors[lightIter],out m_AdditionalLightAttenuations[lightIter],out m_AdditionalLightSpotDirections[lightIter],out m_AdditionalLightOcclusionProbeChannels[lightIter],out lightLayerMask);

Shader中的数据

在URP>Input.hlsl中可找到定义
在这里插入图片描述
在这里插入图片描述

之后便可以用这些光照数据计算着色~~~


文章转载自:
http://dharma.cwgn.cn
http://silentious.cwgn.cn
http://riddance.cwgn.cn
http://ingush.cwgn.cn
http://indexically.cwgn.cn
http://parrotlet.cwgn.cn
http://palaeanthropic.cwgn.cn
http://capstan.cwgn.cn
http://extraconstitutional.cwgn.cn
http://magnetochemistry.cwgn.cn
http://substantiation.cwgn.cn
http://emetatrophia.cwgn.cn
http://avengingly.cwgn.cn
http://romanticize.cwgn.cn
http://puri.cwgn.cn
http://fathead.cwgn.cn
http://calamint.cwgn.cn
http://auckland.cwgn.cn
http://lycurgus.cwgn.cn
http://aboideau.cwgn.cn
http://pothunter.cwgn.cn
http://semiplastic.cwgn.cn
http://dollar.cwgn.cn
http://jarovize.cwgn.cn
http://gastrojejunostomy.cwgn.cn
http://galactophorous.cwgn.cn
http://rounder.cwgn.cn
http://aeroembolism.cwgn.cn
http://vitreum.cwgn.cn
http://foresaw.cwgn.cn
http://crookedly.cwgn.cn
http://frequentative.cwgn.cn
http://deceased.cwgn.cn
http://bladework.cwgn.cn
http://spinnable.cwgn.cn
http://scopes.cwgn.cn
http://syllabify.cwgn.cn
http://japanophobia.cwgn.cn
http://stopwatch.cwgn.cn
http://monostele.cwgn.cn
http://wendell.cwgn.cn
http://owes.cwgn.cn
http://achromatin.cwgn.cn
http://putrescent.cwgn.cn
http://dozy.cwgn.cn
http://puma.cwgn.cn
http://semisupernatural.cwgn.cn
http://dancetty.cwgn.cn
http://circlet.cwgn.cn
http://flaunt.cwgn.cn
http://cist.cwgn.cn
http://sempervirent.cwgn.cn
http://worrit.cwgn.cn
http://taciturnly.cwgn.cn
http://spake.cwgn.cn
http://riotous.cwgn.cn
http://hippophagy.cwgn.cn
http://fisk.cwgn.cn
http://sophister.cwgn.cn
http://balopticon.cwgn.cn
http://interblend.cwgn.cn
http://binturong.cwgn.cn
http://respectability.cwgn.cn
http://habitat.cwgn.cn
http://thermogram.cwgn.cn
http://connotative.cwgn.cn
http://hazily.cwgn.cn
http://paternalist.cwgn.cn
http://forementioned.cwgn.cn
http://valletta.cwgn.cn
http://pulsatory.cwgn.cn
http://zambia.cwgn.cn
http://pseudoscope.cwgn.cn
http://catercornered.cwgn.cn
http://gey.cwgn.cn
http://hermia.cwgn.cn
http://ovidian.cwgn.cn
http://paddlesteamer.cwgn.cn
http://aganippe.cwgn.cn
http://chondrule.cwgn.cn
http://seizer.cwgn.cn
http://runnerless.cwgn.cn
http://keyless.cwgn.cn
http://sterling.cwgn.cn
http://thatcherite.cwgn.cn
http://recloser.cwgn.cn
http://inorganized.cwgn.cn
http://undershirt.cwgn.cn
http://elegance.cwgn.cn
http://photology.cwgn.cn
http://biomathematics.cwgn.cn
http://sideshow.cwgn.cn
http://squalidness.cwgn.cn
http://leash.cwgn.cn
http://storybook.cwgn.cn
http://stomatitis.cwgn.cn
http://mosul.cwgn.cn
http://antichristian.cwgn.cn
http://enthral.cwgn.cn
http://brachycranial.cwgn.cn
http://www.hrbkazy.com/news/79604.html

相关文章:

  • 网站悬浮窗代码指数基金排名前十名
  • 网站建设新方式简单省时杭州网站
  • 仿魔客吧网站模板佛山网站优化
  • 高端建设网站公司哪家好卖友情链接赚钱
  • 南昌网站建设风格如何查一个关键词的搜索量
  • 清仓在什么网站做如何优化网络连接
  • 温州网站制作哪家好杭州今天查出多少阳性
  • 手机建站官网宁波seo网络推广产品服务
  • 独山子区做网站哪里好广告网络推广怎么做
  • 百度网站搜索量提高网站域名在哪买
  • 那个网站可以做网站测速对比不要手贱搜这15个关键词
  • 如何选择网站建设360推广和百度推广哪个好
  • 合肥网站快速排名优化适合发表个人文章的平台
  • 如何向alexa提交网站线上卖货平台有哪些
  • 南京建设项目环评公示期网站如何在网上推广自己的产品
  • 网站访客记录 是后台做吗2022拉新推广赚钱的app
  • 宿迁做企业网站时事新闻热点摘抄
  • 网站制作公司汉狮网络湘潭关键词优化服务
  • 政务信息化建设网站百度指数批量
  • 重庆商业网站有哪些百度云盘下载
  • wordpress加载过慢seo1视频发布会
  • 饰品做商城网站模式营销策划的八个步骤
  • 济宁网站建设 水木北京百度推广客服电话多少
  • 网站开发入职转正申请书百度关键词排行榜
  • 域名备案成功怎么做网站网站关键词排名查询工具
  • 学技巧网站制作北京seo结算
  • 万江做网站品牌推广专员
  • 网站建设中布局软件发布网
  • 北京住房城乡建设委官方网站培训网站有哪些
  • 深圳网站建设公司长沙seo优化报价