文章目录
自学Raymarching汇总:
Unity Shader - Ray Marching Study Summary - 学习汇总
- Project
前一篇得到了表面的法线后,那么光照着色就不成问题了。
核心代码
...
float4 _LightInfo; // 点光源信息:.xyz = pos, .w = 1/range
...
fixed4 getColor(v2f i) {
float3 ori = i.ray; // 射线起点
float3 dir = normalize(i.ray); // 射线方向
float3 pos; // 当前步进到的位置
float dist; // 当前步进到的最近距离
float d; // 当前最近距离
float far = _ProjectionParams.z; // far
ori += _WorldSpaceCameraPos.xyz; // 偏移,加上相机位置
pos = ori; // 从起点出发
float3 lightPos = _LightInfo.xyz; // 灯光位置
float lightRange = _LightInfo.w; // 灯光范围
float rangeEnable = step(EPSILON, lightRange);
UNITY_LOOP
for (int it = 0; it
关注
打赏
热门博文
- 3D Assets (Textures & Model & Animations) & Game Design Ideas & DCC Tutorials & TA
- LearnGL - 学习笔记目录
- Unity - Timeline 知识汇总
- Unity Graphics - 知识点目录 - 停止翻译,因为发现官方有中文文档了
- Graphic资料
- Unity Lightmap&LightProbe局部动态加载(亲测2020以及以上版本官方修复了)
- Unity - 踩坑日志 - 低版本线性颜色空间渲染异常的 “BUG”
- Unity Shader - PBR 渲染 SP 导出的素材
- 什么是 3A 游戏?
- Photosohp - 实现 2D MetaBall、MetaFont