ShaderToy Seascape

来源:互联网 发布:中国留学生 欧洲 数据 编辑:程序博客网 时间:2024/05/16 23:55


644.6960.0 fps
Seascape
Tags: procedural, noise, waves, sea,water, subsurface
 
159950    369    0
Uploaded by TDM in 2014-Sep-27
fully-procedural sea surface computing. without textures.

Android version: https://play.google.com/store/apps/details?id=com.nature.seascape
Comments
Dave_Hoskins, 2014-Sep-27
The ITER variable needs to be a constant at compile time, so passing a variable gives an error (GTX 680) on line 98.
It looks great setting the loop to a straight 5 though.
TDM, 2014-Sep-27
yep, thank you!
poljere, 2014-Sep-27
Looks great TDM. Love the water color! You could also add a bit of fog towards the horizon to make the transition between the water and the sky smoother 
TDM, 2014-Sep-27
poljere, thanks! you can uncomment line 172 to enable fog.
Dave_Hoskins, 2014-Sep-27
Hello again! I have a tip for cheap anti-aliasing, if you want it.
Pass the distance to the surface to the getNormal function like:
    vec3 dist = p - ori;    float d = length(dist);    vec3 n = getNormal(p, d*d*.0003);// Or whatever value that suits.


And use the second parameter passed as the epsilon in the normal function.
This smooths distant details and prevents the shimmering pixel effect.
TDM, 2014-Sep-27
yeah, good idea. also, we can get squared length by dot(dist,dist).
Dave_Hoskins, 2014-Sep-27
So true! 
Passion, 2014-Sep-27
Incredible I love it. This is so damn impressive.
gloinart, 2014-Sep-29
Best water Ive seen
4rknova, 2014-Sep-29
Amazing! 
CPU, 2014-Sep-29
awesome!
ewerybody, 2014-Oct-1
Whooooww!! *drool* No shit: This makes me wanna goto the sea!! I need vacation! :|
ewerybody, 2014-Oct-1
The colors and static looks are almost perfect. But after looking at it for a while.. the waves move kind of linear. I miss this bouncing feel they usually have.
fizzer, 2014-Oct-7
Awesome! 
Flavio, 2014-Oct-7
Genius work! AWESOME!
epascal, 2014-Oct-8
Amazing best water ever seen, how long did you take to program it ?
TDM, 2014-Oct-8
a few days, but i've working on water rendering before.
garcia, 2014-Oct-8
This is absolutely amazing. Awesome work!
ac3t1ne, 2014-Oct-11
There is some strange white noise in the first few seconds on my computer, but obviously this is incredible water it looks fantastic!
abhi_bansal, 2014-Oct-11
Awesome !!
mrgnou, 2014-Oct-11
Killer.
ayberkozgur, 2014-Oct-13
This is one of the best CGI things I have ever seen. Simply beautiful.
Chameleon, 2014-Oct-15
Looks amazing!
McRam, 2014-Oct-16
This is ******* amazing! A masterpiece in 185 lines of code.
nimitz, 2014-Oct-20
Finally got around to reading the code. That technique for heightmap intersection is great, is it your own work?
TDM, 2014-Oct-20
it's interpolation search, very fast on linear increasing values (such as distance field). code is mine, algorithm is common.
nimitz, 2014-Oct-21
I see, and it suffers from the same problem as other interval based methods, that is not being able to predict which root it will converge to. But for cases when you (mostly) have only one possible root, like here, this is great.
TDM, 2014-Oct-21
true
jiaolu, 2014-Dec-16
registered account to say it's amazing work
airtight, 2014-Dec-17
I think you might have found the shader that god is running on the actual ocean.
saphire280x, 2014-Dec-31
Is there any cards on the market that can run these demos in fullscreen at 60fps ?
Dave_Hoskins, 2014-Dec-31
My GTX-680 runs this full-screen at 60fps, so I'm sure there are many many more cards that will:-
http://www.videocardbenchmark.net/high_end_gpus.html
valentingalea, 2015-Mar-2
Insane work! Any chance of an article to explain the finer points of how it works? Cheers!
Emuljan, 2015-Apr-10
wow this is really impressive !!!
Aj_, 2015-May-2
This make me wonder if the entire universe is a shader program.
TDM, 2015-May-8
now you can try android version of it (as gpu benchmark):
https://play.google.com/store/apps/details?id=com.nature.seascape
emh, 2015-Jul-18
I'm trying to use this as water plane in my game, or perhaps a sky box eventually.
Could you help me with passing correctly the THREE js camera position as "ori" and angle as "ang" in this JSBin: http://jsbin.com/reqali/edit?html,js,output , so that the mouse camera controls work correctly? Currently I have just set a fixed top-down perspective on a plane in my game, but it would be cool to map the shader with correct perspective, perhaps even to a sky box.
ArtScott, 2015-Jul-23
I play Box of Rain when viewing.
https://www.youtube.com/watch?v=b-z7uN9OjyI
jedi_cy, 2015-Aug-26
reeeeally amaaaaaazing
alfkuhl, 2015-Sep-14
This is Awesome. The AntiAliasing tip D Hoskins made. Would make this perfect!
Sign in to post a comment.
Shader Inputs
uniform vec3      iResolution;           // viewport resolution (in pixels)uniform float     iGlobalTime;           // shader playback time (in seconds)uniform float     iChannelTime[4];       // channel playback time (in seconds)uniform vec3      iChannelResolution[4]; // channel resolution (in pixels)uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: clickuniform samplerXX iChannel0..3;          // input channel. XX = 2D/Cubeuniform vec4      iDate;                 // (year, month, day, time in seconds)uniform float     iSampleRate;           // sound sample rate (i.e., 44100)
1
// "Seascape" by Alexander Alekseev aka TDM - 2014
2
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
3
4
const int NUM_STEPS = 8;
5
const float PI      = 3.1415;
6
const float EPSILON = 1e-3;
7
float EPSILON_NRM   = 0.1 / iResolution.x;
8
9
// sea
10
const int ITER_GEOMETRY = 3;
11
const int ITER_FRAGMENT = 5;
12
const float SEA_HEIGHT = 0.6;
13
const float SEA_CHOPPY = 4.0;
14
const float SEA_SPEED = 0.8;
15
const float SEA_FREQ = 0.16;
16
const vec3 SEA_BASE = vec3(0.1,0.19,0.22);
17
const vec3 SEA_WATER_COLOR = vec3(0.8,0.9,0.6);
18
float SEA_TIME = iGlobalTime * SEA_SPEED;
19
mat2 octave_m = mat2(1.6,1.2,-1.2,1.6);
20
21
// math
22
mat3 fromEuler(vec3 ang) {
23
    vec2 a1 = vec2(sin(ang.x),cos(ang.x));
24
    vec2 a2 = vec2(sin(ang.y),cos(ang.y));
25
    vec2 a3 = vec2(sin(ang.z),cos(ang.z));
26
    mat3 m;
27
    m[0] = vec3(a1.y*a3.y+a1.x*a2.x*a3.x,a1.y*a2.x*a3.x+a3.y*a1.x,-a2.y*a3.x);
28
    m[1] = vec3(-a2.y*a1.x,a1.y*a2.y,a2.x);
29
    m[2] = vec3(a3.y*a1.x*a2.x+a1.y*a3.x,a1.x*a3.x-a1.y*a3.y*a2.x,a2.y*a3.y);
30
    return m;
31
}
32
float hash( vec2 p ) {
33
    float h = dot(p,vec2(127.1,311.7)); 
34
    return fract(sin(h)*43758.5453123);
35
}
36
float noise( in vec2 p ) {
37
    vec2 i = floor( p );
38
    vec2 f = fract( p );    
39
    vec2 u = f*f*(3.0-2.0*f);
40
    return -1.0+2.0*mix( mix( hash( i + vec2(0.0,0.0) ), 
41
                     hash( i + vec2(1.0,0.0) ), u.x),
42
                mix( hash( i + vec2(0.0,1.0) ), 
43
                     hash( i + vec2(1.0,1.0) ), u.x), u.y);
44
}
45
46
// lighting
47
float diffuse(vec3 n,vec3 l,float p) {
48
    return pow(dot(n,l) * 0.4 + 0.6,p);
49
}
50
float specular(vec3 n,vec3 l,vec3 e,float s) {    
51
    float nrm = (s + 8.0) / (3.1415 * 8.0);
52
    return pow(max(dot(reflect(e,n),l),0.0),s) * nrm;
53
}
3741 chars
<div class="uiButton" title="Go full screen (+)" ,="" true)"="" style="margin: 0px; padding: 0px; width: 22px; height: 22px; position: absolute; cursor: pointer; border-radius: 4px; right: 120px; top: 1px; background: url(https://www.shadertoy.com/img/fullscreen.png);">
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 得益乳业 天友乳业 澳优乳业 新乳业股吧 乳业概念 卫岗乳业 伊利乳业 一景乳业 比村乳业 夏进乳业 圣唐乳业 佳宝乳业 优利士乳业 三元乳业 南阳乳业 摇篮乳业 科迪乳业遭问询 科迪乳业股票 科迪乳业股吧 光明乳业股票 002770科迪乳业 辉山乳业崩盘式暴跌 燕塘乳业股票 光明乳业股吧 新疆天润乳业酸奶曝光 光明乳业股份有限公司 600597光明乳业 西安银桥乳业集团 山西古城乳业集团有限公司 伊犁那拉乳业 完达山乳业电话 600597光明乳业股吧 天友乳业招聘信息 陕西雅泰乳业有限公司 新希望 石家庄君乐宝乳业有限公司 健乐多乳清蛋白 空孕催乳剂 催乳剂 沙棘干乳剂 孕催乳剂