ue4 采样cubemap
时间:2019-10-19
本文章向大家介绍ue4 采样cubemap,主要包括ue4 采样cubemap使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
float4 GetSphereCaptureVector(float3 ReflectionVector, float3 WorldPosition, float4 CapturePositionAndRadius) { float4 ProjectedCaptureVector; ProjectedCaptureVector.w = 0; ProjectedCaptureVector.xyz = ReflectionVector; float3 RayDirection = ReflectionVector; float ProjectionSphereRadius = CapturePositionAndRadius.w * 1.2f; float SphereRadiusSquared = ProjectionSphereRadius * ProjectionSphereRadius; float3 ReceiverToSphereCenter = WorldPosition - CapturePositionAndRadius.xyz; float ReceiverToSphereCenterSq = dot(ReceiverToSphereCenter, ReceiverToSphereCenter); float3 CaptureVector = WorldPosition - CapturePositionAndRadius.xyz; float CaptureVectorLength = sqrt(dot(CaptureVector, CaptureVector)); float NormalizedDistanceToCapture = saturate(CaptureVectorLength / CapturePositionAndRadius.w); // Find the intersection between the ray along the reflection vector and the capture's sphere float3 QuadraticCoef; QuadraticCoef.x = 1; QuadraticCoef.y = 2 * dot(RayDirection, ReceiverToSphereCenter); QuadraticCoef.z = ReceiverToSphereCenterSq - SphereRadiusSquared; float Determinant = QuadraticCoef.y * QuadraticCoef.y - 4 * QuadraticCoef.z; BRANCH // Only continue if the ray intersects the sphere if (Determinant >= 0) { float FarIntersection = (sqrt(Determinant) - QuadraticCoef.y) * 0.5; float3 IntersectPosition = WorldPosition + FarIntersection * RayDirection; ProjectedCaptureVector.xyz = IntersectPosition - CapturePositionAndRadius.xyz; // Fade out based on distance to capture ProjectedCaptureVector.w = 1.0 - smoothstep(.6, 1, NormalizedDistanceToCapture); } return ProjectedCaptureVector; }
1 2 half3 GetImageBasedReflectionLighting(FMaterialPixelParameters MaterialParameters, half Roughness) 3 { 4 #if HQ_REFLECTIONS 5 half3 SpecularIBL = BlendReflectionCaptures(MaterialParameters, Roughness); 6 #else 7 8 half3 ProjectedCaptureVector = MaterialParameters.ReflectionVector; 9 10 half UsingSkyReflection = MobileReflectionParams.w > 0; 11 half CubemapMaxMip = UsingSkyReflection ? MobileReflectionParams.w : ResolvedView.ReflectionCubemapMaxMip; 12 13 // Compute fractional mip from roughness 14 half AbsoluteSpecularMip = ComputeReflectionCaptureMipFromRoughness(Roughness, CubemapMaxMip); 15 // Fetch from cubemap and convert to linear HDR 16 half3 SpecularIBL; 17 half4 SpecularIBLSample = ReflectionCubemap.SampleLevel(ReflectionCubemapSampler, ProjectedCaptureVector, AbsoluteSpecularMip); 18 if (UsingSkyReflection) 19 { 20 SpecularIBL = SpecularIBLSample.rgb; 21 // Apply sky colour if the reflection map is the sky. 22 SpecularIBL *= ResolvedView.SkyLightColor.rgb; 23 } 24 else 25 { 26 SpecularIBL = RGBMDecode(SpecularIBLSample, 16.0); 27 SpecularIBL = SpecularIBL * SpecularIBL; 28 #if LQ_TEXTURE_LIGHTMAP || CACHED_POINT_INDIRECT_LIGHTING 29 // divide by average brightness for lightmap use cases only. 30 SpecularIBL *= MobileReflectionParams.x; 31 #endif 32 } 33 34 #endif 35 36 #if WEBGL 37 // need a rgb swizzle instead of the existing rgba swizzle, we should add it if another use case comes up. 38 return SpecularIBL.bgr; 39 #else 40 return SpecularIBL; 41 #endif 42 }
原文地址:https://www.cnblogs.com/Shaojunping/p/11703350.html
- 关于 hadoop reduce 阶段遍历 Iterable 的 2 个“坑”
- Hadoop Mapper 阶段将数据直接从 HDFS 导入 Hbase
- 译文 | 量化投资教程:投资组合优化与R实践
- 浅谈 java 中构建可执行 jar 包的几种方式
- python 日志模块 logging 详解
- 基于堆实现的优先级队列:PriorityQueue 解决 Top K 问题
- explain 深入剖析 MySQL 索引及其性能优化指南
- 图文并茂详解 SQL JOIN
- 自定义 hadoop MapReduce InputFormat 切分输入文件
- Hadoop MapReduce 二次排序原理及其应用
- MySQL Tips【Updating】
- Meltdown、Spectre攻击---CPU乱序执行和预测执行导致的安全问题
- WordPress 4.6远程代码执行漏洞(CVE-2016-10033)复现环境搭建指南
- 相似文档查找算法之 simHash 简介及其 java 实现
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 同城双活与异地多活架构分析
- leetcode多线程之按序打印
- leetcode多线程之交替打印FooBar
- leetcode链表之反转链表
- leetcode链表之合并两个排序的链表
- leetcode链表之找出倒数第k个节点
- ZooKeeper能解决什么问题?不能解决什么问题?
- 画解算法 77-组合
- Spring 源码系列之容器概览~
- Spring Security 中如何让上级拥有下级的所有权限?
- Spring Security 权限管理的投票器与表决机制
- 通过cycler实现属性的自动映射
- 为你的图片添加图例
- matplotlib中的黑魔法:constrained和tight layout
- 用不同的坐标系统对图形元素进行定位