网页
资讯
视频
图片
知道
文库
贴吧
地图
采购
进入贴吧
全吧搜索
吧内搜索
搜贴
搜人
进吧
搜标签
日
一
二
三
四
五
六
签到排名:今日本吧第
个签到,
本吧因你更精彩,明天继续来努力!
本吧签到人数:0
一键签到
成为超级会员,使用一键签到
一键签到
本月漏签
0
次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行
补签
。
连续签到:
天 累计签到:
天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
04月19日
漏签
0
天
unity3d吧
关注:
116,237
贴子:
559,969
看贴
图片
吧主推荐
视频
游戏
首页
上一页
1
2
3
4
下一页
尾页
46
回复贴,共
4
页
,跳到
页
确定
<<返回unity3d吧
>0< 加载中...
回复:【伪直播】看完星际穿越,迫不及待想做一个虫洞演示程序
取消只看楼主
收藏
回复
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
趁生成光谱的时间楼主找来两个天空盒
大家有没有更霸气一点的 支援下呗~??
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
新的光谱终于出来了,
RB通道的组合代表出射光线的角度,G通道决定出射空间
int package = Mathf.RoundToInt(final_angle * 10000f + 32768);
Color32 c = new Color32 ();
c.r = (byte)(package & 255);
c.b = (byte)((package >> 8) & 255);
c.g = (byte)(p.Position4.w > 0 ? 128 : 0);
c.a = (byte)255;
spectrumTex.SetPixel(i, d, c);
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
导入工程的设置
Bypass sRGB Sampling ,Format RGB24bit,和Point 采样确保了shader中读取该图片颜色的准确性
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
创建了一个材质球,
属性有A,B两个天空盒的Cubemap,光谱的Texture 和当前摄像机的位置
Properties
{
_SkyboxA ("Space A skybox", CUBE) = "" {}
_SkyboxB ("Space B skybox", CUBE) = "" {}
_Spectrum ("Wormhole Spectrum", 2D) = "" {}
_CamPos ("Camera Position", Vector) = (100,0,0,0)
}
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
光谱通过极坐标映射到屏幕中计算正确!!!!
现在还差最后一步,在Cubemap上求值,祈祷。。
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
楼主啥也不说了,上图吧。。
和预期还是有点差距,
待我加点后期特效和摄像机控制
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
检查了下算法,没问题,捣鼓了这么久,总算是成功了!!!!
加了一些后期特效,如Bloom,LenFlare,还用了一个HDR插件
下面是最终效果图
图片来自:
_17th_的百度相册
换个角度
远看
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
以下展示虫洞的折光性质:
(虫洞右上角的亮点其实是折的左下角星云的强光)
另一个折光图:
这张图中,虫洞遮住了一个恒星,但是能从虫洞边缘看到一个环形的折光,和“泊松亮斑”的原理有点类似。
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
下面我们亲身走进虫洞力场
这是位于虫洞的管道中部(A空间与B空间的连接管内)截的图,
由于各方光线汇聚于此处,亮度明显提高了很多
@邪恶的PS
吧主,现在可以精了么?
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
(这张图我把A,B两个空间的天空盒改成一样的了)
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
做了一张动态图,不过。。右下角那是什么
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
这是最终天空盒的shader
这个shader利用了之前的光谱。。
Shader "Zhouxun/Universe/Skybox (wormhole)"
{
Properties
{
_SkyboxA ("Space A skybox", CUBE) = "" {}
_SkyboxB ("Space B skybox", CUBE) = "" {}
_Spectrum ("Wormhole Spectrum", 2D) = "" {}
_CamPos ("Camera Position", Vector) = (100,0,0,0)
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"Queue" = "Background"
}
Fog { Mode Off }
Pass
{
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
samplerCUBE _SkyboxA;
samplerCUBE _SkyboxB;
sampler2D _Spectrum;
float4 _CamPos;
struct appdata_skybox
{
float4 vertex : POSITION;
};
struct v2f
{
float3 wp : TEXCOORD0;
float4 pos : POSITION0;
};
half4 FinalColor (float4 photon)
{
return lerp (texCUBE(_SkyboxB, normalize(photon.yzx)),
texCUBE(_SkyboxA, normalize(photon.xyz)),
saturate((photon.w + 1) * 0.5));
}
#define PI (3.141592654)
#define SPEC_SIZE (2048)
#define SPEC_PIXEL (0.00048828125)
#define SPEC_HALF_PIXEL (0.000244140625)
float2 OutputAngle2D (float input_angle, float input_space, float dist)
{
float2 tc = 0;
tc.x = (input_angle / PI) * (SPEC_SIZE - 1);
tc.y = sqrt(max(0,dist-10))*111.1111111;
float2 frac_tc = float2(frac(tc.x), frac(tc.y));
float2 tc00 = float2(tc.x, tc.y) * SPEC_PIXEL;
float2 tc10 = float2(tc.x + 1, tc.y) * SPEC_PIXEL;
float2 tc01 = float2(tc.x, tc.y) * SPEC_PIXEL;
float2 tc11 = float2(tc.x + 1, tc.y + 1) * SPEC_PIXEL;
float3 c00 = tex2D(_Spectrum, tc00).rgb;
float output_angle00 = ((round(c00.r * 255) + round(c00.b * 255) * 256) - 32768) * 0.0001;
float output_space00 = ((c00.g - 0.25) * 4) * input_space;
float3 c10 = tex2D(_Spectrum, tc10).rgb;
float output_angle10 = ((round(c10.r * 255) + round(c10.b * 255) * 256) - 32768) * 0.0001;
float output_space10 = ((c10.g - 0.25) * 4) * input_space;
float3 c01 = tex2D(_Spectrum, tc01).rgb;
float output_angle01 = ((round(c01.r * 255) + round(c01.b * 255) * 256) - 32768) * 0.0001;
float output_space01 = ((c01.g - 0.25) * 4) * input_space;
float3 c11 = tex2D(_Spectrum, tc11).rgb;
float output_angle11 = ((round(c11.r * 255) + round(c11.b * 255) * 256) - 32768) * 0.0001;
float output_space11 = ((c11.g - 0.25) * 4) * input_space;
float output_angle = lerp(lerp(output_angle00, output_angle10, frac_tc.x),
lerp(output_angle01, output_angle11, frac_tc.x), frac_tc.y);
float output_space = lerp(lerp(output_space00, output_space10, frac_tc.x),
lerp(output_space01, output_space11, frac_tc.x), frac_tc.y);
return float2(output_angle, output_space);
}
v2f vert (appdata_skybox v)
{
v2f o;
o.wp.xyz = v.vertex.xyz;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
half4 frag (v2f i) : COLOR
{
float input_space = _CamPos.w;
float3 dir = normalize(i.wp);
//dir.x *= input_space;
float3 elem = -_CamPos.xyz;
float3 n_elem = normalize(elem);
float input_angle = acos(clamp(dot(dir, n_elem), -1, 1));
float dist = length(elem);
float2 output2d = OutputAngle2D(input_angle, input_space, dist);
float3 axis = normalize(cross(dir, n_elem));
float3 curv = normalize(cross(n_elem, axis));
float _x = cos(output2d.x);
float _y = sin(output2d.x);
float3 output_dir = _x * n_elem + _y * curv;
return pow(FinalColor(float4(output_dir, output2d.y)),1.7);
}
ENDCG
}
}
}
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
到这里还没有结束,
今天只是把虫洞的样子做了出来,而且只简单的做了一下摄像机控制
要模拟穿越虫洞,摄像机在虫洞力场中的运动路线也应该是测地线,而且摄像机面对的方向还必须偏转,
最后在碰到球界的时候摄像机运动方向和朝向应该被镜像。这些都还没实现,楼主先睡了。。
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
感谢这么多朋友的支持,大家共同学习!!
话说昨天我梦了一晚上虫洞。。
还有这东西
这个要是实现了简直丧心病狂啊。。
有木有觉得很像那个Flux Capacitor
_17th_
Script
11
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
前面发的几张图,其实有 Image Effect 的功劳
外加叠了一个LensFlare Dirt
其实去掉这两个效果的话,就跟41楼差不多。。
另外我把shader最后一句改为了
return pow(FinalColor(float4(output_dir, output2d.y))+0.05,3)*12;
目的是突出亮光
登录百度账号
扫二维码下载贴吧客户端
下载贴吧APP
看高清直播、视频!
贴吧页面意见反馈
违规贴吧举报反馈通道
贴吧违规信息处理公示