gpipeline.fov = freecam? 60.0f: 135.0f; /* 120 */
m4x4_projection( vg_pv, gpipeline.fov,
(float)vg_window_x / (float)vg_window_y,
- 0.1f, 1500.0f );
+ 0.1f, 2100.0f );
m4x4_mul( vg_pv, world_4x4, vg_pv );
--- /dev/null
+#include "water_ref.glsl"
+
+out vec4 FragColor;
+
+uniform vec3 uCamera;
+uniform vec4 uPlane;
+
+in vec4 aColour;
+in vec2 aUv;
+in vec3 aNorm;
+in vec3 aCo;
+
+float ray_plane( vec3 pos, vec3 dir, vec4 plane )
+{
+ float d = dot( plane.xyz, dir );
+ float t = dot((plane.xyz*plane.w - pos),plane.xyz) / d;
+ return t;
+}
+
+void main()
+{
+ float fdist = ray_plane( uCamera, -aNorm, uPlane );
+ vec3 world_pos = uCamera - aNorm*fdist;
+
+ FragColor = vec4(fract(world_pos*0.1),1.0);
+}
--- /dev/null
+#ifndef SHADER_planeinf_H
+#define SHADER_planeinf_H
+static void shader_planeinf_link(void);
+static void shader_planeinf_register(void);
+static struct vg_shader _shader_planeinf = {
+ .name = "planeinf",
+ .link = shader_planeinf_link,
+ .vs =
+{
+.orig_file = "../shaders/standard.vs",
+.static_src =
+"layout (location=0) in vec3 a_co;\n"
+"layout (location=1) in vec3 a_norm;\n"
+"layout (location=2) in vec4 a_colour;\n"
+"layout (location=3) in vec2 a_uv;\n"
+"\n"
+"#line 2 0 \n"
+"\n"
+"uniform mat4 uPv;\n"
+"uniform mat4x3 uMdl;\n"
+"\n"
+"out vec4 aColour;\n"
+"out vec2 aUv;\n"
+"out vec3 aNorm;\n"
+"out vec3 aCo;\n"
+"\n"
+"void main()\n"
+"{\n"
+" gl_Position = uPv * vec4( uMdl * vec4(a_co,1.0), 1.0 );\n"
+" aColour = a_colour;\n"
+" aUv = a_uv;\n"
+" aNorm = mat3(uMdl) * a_norm;\n"
+" aCo = a_co;\n"
+"}\n"
+""},
+ .fs =
+{
+.orig_file = "../shaders/planeinf.fs",
+.static_src =
+"vec4 water_surf( vec3 halfview, vec3 vnorm, float depthvalue, \n"
+" vec4 beneath, vec4 above )\n"
+"{\n"
+" vec3 colour_shore = vec3( 0.21, 0.6, 0.8 );\n"
+" vec3 colour_ocean = vec3( 0.01, 0.1, 0.2 );\n"
+" vec3 surface_tint = mix(colour_shore, colour_ocean, depthvalue);\n"
+"\n"
+" float ffresnel = pow(1.0-dot( vnorm, halfview ),5.0);\n"
+"\n"
+" vec3 lightdir = vec3(0.95,0.0,-0.3);\n"
+" vec3 specdir = reflect( -lightdir, vnorm );\n"
+" float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;\n"
+" \n"
+" // Depth \n"
+" float depthblend = pow( beneath.a,0.8 );\n"
+"\n"
+" // Composite\n"
+" vec3 vsurface = mix(surface_tint, above.rgb, ffresnel );\n"
+" //vsurface += spec;\n"
+"\n"
+" return vec4( vsurface,depthblend );\n"
+"}\n"
+"\n"
+"#line 2 0 \n"
+"\n"
+"out vec4 FragColor;\n"
+"\n"
+"uniform vec3 uCamera;\n"
+"uniform vec4 uPlane;\n"
+"\n"
+"in vec4 aColour;\n"
+"in vec2 aUv;\n"
+"in vec3 aNorm;\n"
+"in vec3 aCo;\n"
+"\n"
+"float ray_plane( vec3 pos, vec3 dir, vec4 plane )\n"
+"{\n"
+" float d = dot( plane.xyz, dir );\n"
+" float t = dot((plane.xyz*plane.w - pos),plane.xyz) / d;\n"
+" return t;\n"
+"}\n"
+"\n"
+"void main()\n"
+"{\n"
+" float fdist = ray_plane( uCamera, -aNorm, uPlane );\n"
+" vec3 world_pos = uCamera - aNorm*fdist;\n"
+"\n"
+" FragColor = vec4(fract(world_pos*0.1),1.0);\n"
+"}\n"
+""},
+};
+
+static GLuint _uniform_planeinf_uPv;
+static GLuint _uniform_planeinf_uMdl;
+static GLuint _uniform_planeinf_uCamera;
+static GLuint _uniform_planeinf_uPlane;
+static void shader_planeinf_uPv(m4x4f m){
+ glUniformMatrix4fv( _uniform_planeinf_uPv, 1, GL_FALSE, (float *)m );
+}
+static void shader_planeinf_uMdl(m4x3f m){
+ glUniformMatrix4x3fv( _uniform_planeinf_uMdl, 1, GL_FALSE, (float *)m );
+}
+static void shader_planeinf_uCamera(v3f v){
+ glUniform3fv( _uniform_planeinf_uCamera, 1, v );
+}
+static void shader_planeinf_uPlane(v4f v){
+ glUniform4fv( _uniform_planeinf_uPlane, 1, v );
+}
+static void shader_planeinf_register(void){
+ vg_shader_register( &_shader_planeinf );
+}
+static void shader_planeinf_use(void){ glUseProgram(_shader_planeinf.id); }
+static void shader_planeinf_link(void){
+ _uniform_planeinf_uPv = glGetUniformLocation( _shader_planeinf.id, "uPv" );
+ _uniform_planeinf_uMdl = glGetUniformLocation( _shader_planeinf.id, "uMdl" );
+ _uniform_planeinf_uCamera = glGetUniformLocation( _shader_planeinf.id, "uCamera" );
+ _uniform_planeinf_uPlane = glGetUniformLocation( _shader_planeinf.id, "uPlane" );
+}
+#endif /* SHADER_planeinf_H */
void main()
{
float fintensity = 1.0-(abs(aNorm.y)*0.7);
- float fblend = pow(fintensity,6.0);
- vec3 horizon = vec3( 0.61, 0.71, 0.86 )*1.5;
- vec3 skycolour = vec3( 0.31, 0.56, 0.91 );
+ float fblend = pow(fintensity,8.0);
+ vec3 horizon = vec3( 0.8, 0.9, 0.9 );
+ vec3 skycolour = vec3( 0.5, 0.6, 0.9 );
vec3 diffuse = mix( skycolour, horizon, fblend );
float fmove = uTime * 0.004;
- vec2 cloudplane = (aCo.xz / (aCo.y*sign(aNorm.y))) * 0.03;
+ vec2 cloudplane = (aNorm.xz / (aNorm.y*sign(aNorm.y))) * 0.05;
vec4 clouds1 = texture( uTexGarbage, cloudplane + vec2(0.1,0.4)*fmove*2.0 );
vec4 clouds2 = texture( uTexGarbage, cloudplane + vec2(0.3,0.1)*fmove );
float fhorizon = step( aNorm.y * 0.5 + 0.5, 0.5 );
vec3 skycomp = mix(diffuse, vec3(1.0,1.0,1.0), cloud_e);
- skycomp = mix(mix(pow(colour_ocean,vec3(6.0))*0.6,skycomp, 0.7),skycomp,fhorizon);
-
- FragColor = vec4(skycomp, 0.0);
+ FragColor = vec4(skycomp,1.0);
}
"void main()\n"
"{\n"
" float fintensity = 1.0-(abs(aNorm.y)*0.7);\n"
-" float fblend = pow(fintensity,6.0);\n"
-" vec3 horizon = vec3( 0.61, 0.71, 0.86 )*1.5;\n"
-" vec3 skycolour = vec3( 0.31, 0.56, 0.91 );\n"
+" float fblend = pow(fintensity,8.0);\n"
+" vec3 horizon = vec3( 0.8, 0.9, 0.9 );\n"
+" vec3 skycolour = vec3( 0.5, 0.6, 0.9 );\n"
" vec3 diffuse = mix( skycolour, horizon, fblend );\n"
"\n"
" float fmove = uTime * 0.004;\n"
-" vec2 cloudplane = (aCo.xz / (aCo.y*sign(aNorm.y))) * 0.03;\n"
+" vec2 cloudplane = (aNorm.xz / (aNorm.y*sign(aNorm.y))) * 0.05;\n"
" vec4 clouds1 = texture( uTexGarbage, cloudplane + vec2(0.1,0.4)*fmove*2.0 );\n"
" vec4 clouds2 = texture( uTexGarbage, cloudplane + vec2(0.3,0.1)*fmove );\n"
"\n"
" vec3 colour_ocean = vec3( 0.61, 0.84, 0.9 );\n"
" float fhorizon = step( aNorm.y * 0.5 + 0.5, 0.5 );\n"
"\n"
-" vec3 skycomp = mix(diffuse, vec3(1.0,1.0,1.0), cloud_e);\n"
-" skycomp = mix(mix(pow(colour_ocean,vec3(6.0))*0.6,skycomp, 0.7),skycomp,fhorizon);\n"
-"\n"
-" FragColor = vec4(skycomp, 0.0);\n"
+" vec3 skycomp = mix(diffuse, vec3(1.0,1.0,1.0), cloud_e*(1.0-fblend*3.0));\n"
+" FragColor = vec4(skycomp,1.0);\n"
"}\n"
""},
};
{
float d = dot( plane.xyz, dir );
float t = dot((plane.xyz*plane.w - pos),plane.xyz) / d;
- return t*0.05;
+ return t*0.04;
}
void main()
// Lighting
vec3 lightdir = vec3(0.95,0.0,-0.3);
- vec3 shadow = pow(vec3(0.014,0.034,0.084),vec3(1.0/3.2));
+ vec3 shadow = vec3(0.27,0.25,0.34);
float light1 = dot( lightdir, mix(qnorm,aNorm,amtsand) )*0.5+0.5;
diffuse = diffuse * (light1*vec3(1.0,0.96,0.9)*1.2 + shadow*(1.0-light1));
"{\n"
" float d = dot( plane.xyz, dir );\n"
" float t = dot((plane.xyz*plane.w - pos),plane.xyz) / d;\n"
-" return t*0.05;\n"
+" return t*0.04;\n"
"}\n"
"\n"
"void main()\n"
"\n"
" // Lighting\n"
" vec3 lightdir = vec3(0.95,0.0,-0.3);\n"
-" vec3 shadow = pow(vec3(0.014,0.034,0.084),vec3(1.0/3.2));\n"
+" vec3 shadow = vec3(0.3,0.25,0.34);\n"
" float light1 = dot( lightdir, mix(qnorm,aNorm,amtsand) )*0.5+0.5;\n"
" diffuse = diffuse * (light1*vec3(1.0,0.96,0.9)*1.2 + shadow*(1.0-light1));\n"
" \n"
+#include "water_ref.glsl"
+
out vec4 FragColor;
uniform sampler2D uTexMain;
void main()
{
- // Reflected and warped texture
+ // Create texture coords
vec2 ssuv = gl_FragCoord.xy*uInvRes;
-
- vec4 dudva = texture( uTexDudv, aUv.xy - vec2(uTime*0.004f,uTime*0.003f) );
- vec4 dudvb = texture( uTexDudv, aUv.xy*0.7 - vec2(uTime*0.01,uTime*0.0054) );
- vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 0.6;
-
- vec4 reflected = texture( uTexMain, ssuv+distortamt );
// Surface colour composite
float depthvalue = texture( uTexDepth, aUv.zw ).r;
- vec3 colour_shore = vec3( 0.21, 0.6, 0.8 );
- vec3 colour_ocean = vec3( 0.01, 0.1, 0.2 );
- vec3 surface_tint = mix(colour_shore, colour_ocean, pow(depthvalue,1.8))*1.5;
+ vec4 dudva = texture(uTexDudv, aUv.xy + vec2(uTime*0.008,uTime*0.006))-0.5;
+ vec4 dudvb = texture(uTexDudv, aUv.xy*7.0-vec2(uTime*0.003,uTime*0.03))-0.5;
+
+ vec3 surfnorm = dudva.rgb + dudvb.rgb;
+ surfnorm = normalize(vec3(0.0,1.0,0.0) + dudva.xyz*0.4 + dudvb.xyz*0.1);
// Foam
- float fband = fract( aCo.z*0.1+uTime*0.1-depthvalue*10.0 );
- fband = step( fband+dudvb.g*0.8, 0.5 ) * max((1.0-depthvalue*4.0),0.0);
+ float fband = fract( aCo.z*0.02+uTime*0.1+depthvalue*10.0 );
+ fband = step( fband+dudva.a*0.8, 0.3 ) * max((1.0-depthvalue*4.0),0.0);
// Lighting
- vec3 surfnorm = vec3(distortamt.x,1.0,distortamt.y);
-
vec3 halfview = -normalize( aCo-uCamera );
- float ffresnel = pow(1.0-dot( surfnorm, halfview ),5.0);
- vec3 lightdir = vec3(0.95,0.0,-0.3);
- vec3 specdir = reflect( -lightdir, surfnorm );
- float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;
-
- // Depth
- vec4 backsample = texture( uTexBack, ssuv+distortamt*0.1 );
- float depthblend = pow(backsample.a,0.8);
+ // Sample textures
+ vec4 above = texture( uTexMain, ssuv+ surfnorm.xz*0.2 );
+ vec4 beneath = texture( uTexBack, ssuv );
+
+ // Fog
+ //vec4 horizon = vec4( 0.5, 0.6, 0.9, 1.0 );
+ vec4 horizon = vec4( 0.7,0.8,0.88, 1.0 );
+ float fdist = pow(length( aCo.xz-uCamera.xz ) * 0.00047, 2.6);
// Composite
- vec3 vsurface = mix(surface_tint*backsample.rgb, reflected.rgb, ffresnel );
- vsurface += spec;
-
- FragColor = mix( vec4(vsurface,depthblend), vec4(1.0,1.0,1.0,0.8), fband );
+ vec4 vsurface = water_surf( halfview, surfnorm, depthvalue, beneath, above );
+ vsurface.a -= fdist;
+ FragColor = mix( vsurface, vec4(1.0,1.0,1.0,0.5), fband );
}
" gl_Position = uPv * vec4(world_pos,1.0);\n"
"\n"
" vec2 depth_coords = (world_pos.xz-uDepthBounds.xy)*uDepthBounds.zw;\n"
-" aUv = vec4(world_pos.xz*0.01,depth_coords);\n"
+" aUv = vec4(world_pos.xz*0.005,depth_coords);\n"
" aCo = world_pos;\n"
"\n"
" aDepth = gl_Position.z;\n"
{
.orig_file = "../shaders/water.fs",
.static_src =
+"vec4 water_surf( vec3 halfview, vec3 vnorm, float depthvalue, \n"
+" vec4 beneath, vec4 above )\n"
+"{\n"
+" vec3 colour_shore = vec3( 0.21, 0.6, 0.8 );\n"
+" vec3 colour_ocean = vec3( 0.01, 0.1, 0.2 );\n"
+" vec3 surface_tint = mix(colour_shore, colour_ocean, depthvalue);\n"
+"\n"
+" float ffresnel = pow(1.0-dot( vnorm, halfview ),5.0);\n"
+"\n"
+" vec3 lightdir = vec3(0.95,0.0,-0.3);\n"
+" vec3 specdir = reflect( -lightdir, vnorm );\n"
+" float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;\n"
+" \n"
+" // Depth \n"
+" float depthblend = pow( beneath.a,0.8 );\n"
+"\n"
+" // Composite\n"
+" vec3 vsurface = mix(surface_tint, above.rgb, ffresnel );\n"
+" //vsurface += spec;\n"
+"\n"
+" return vec4( vsurface,depthblend );\n"
+"}\n"
+"\n"
+"#line 2 0 \n"
+"\n"
"out vec4 FragColor;\n"
"\n"
"uniform sampler2D uTexMain;\n"
"\n"
"void main()\n"
"{\n"
-" // Reflected and warped texture\n"
+" // Create texture coords\n"
" vec2 ssuv = gl_FragCoord.xy*uInvRes;\n"
-"\n"
-" vec4 dudva = texture( uTexDudv, aUv.xy - vec2(uTime*0.004f,uTime*0.003f) );\n"
-" vec4 dudvb = texture( uTexDudv, aUv.xy*0.7 - vec2(uTime*0.01,uTime*0.0054) );\n"
-" vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 0.6;\n"
-"\n"
-" vec4 reflected = texture( uTexMain, ssuv+distortamt );\n"
" \n"
" // Surface colour composite\n"
" float depthvalue = texture( uTexDepth, aUv.zw ).r;\n"
"\n"
-" vec3 colour_shore = vec3( 0.21, 0.6, 0.8 );\n"
-" vec3 colour_ocean = vec3( 0.01, 0.1, 0.2 );\n"
-" vec3 surface_tint = mix(colour_shore, colour_ocean, pow(depthvalue,1.8))*1.5;\n"
+" vec4 dudva = texture(uTexDudv, aUv.xy + vec2(uTime*0.008,uTime*0.006))-0.5;\n"
+" vec4 dudvb = texture(uTexDudv, aUv.xy*7.0-vec2(uTime*0.003,uTime*0.03))-0.5;\n"
+"\n"
+" vec3 surfnorm = dudva.rgb + dudvb.rgb;\n"
+" surfnorm = normalize(vec3(0.0,1.0,0.0) + dudva.xyz*0.4 + dudvb.xyz*0.1);\n"
" \n"
" // Foam\n"
-" float fband = fract( aCo.z*0.1+uTime*0.1-depthvalue*10.0 );\n"
-" fband = step( fband+dudvb.g*0.8, 0.5 ) * max((1.0-depthvalue*4.0),0.0);\n"
+" float fband = fract( aCo.z*0.02+uTime*0.1+depthvalue*10.0 );\n"
+" fband = step( fband+dudva.a*0.8, 0.3 ) * max((1.0-depthvalue*4.0),0.0);\n"
"\n"
" // Lighting\n"
-" vec3 surfnorm = vec3(distortamt.x,1.0,distortamt.y);\n"
-" \n"
" vec3 halfview = -normalize( aCo-uCamera );\n"
-" float ffresnel = pow(1.0-dot( surfnorm, halfview ),5.0);\n"
"\n"
-" vec3 lightdir = vec3(0.95,0.0,-0.3);\n"
-" vec3 specdir = reflect( -lightdir, surfnorm );\n"
-" float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;\n"
-" \n"
-" // Depth \n"
-" vec4 backsample = texture( uTexBack, ssuv+distortamt*0.1 );\n"
-" float depthblend = pow(backsample.a,0.8);\n"
+" // Sample textures\n"
+" vec4 above = texture( uTexMain, ssuv+ surfnorm.xz*0.2 );\n"
+" vec4 beneath = texture( uTexBack, ssuv );\n"
+"\n"
+" // Fog\n"
+" //vec4 horizon = vec4( 0.5, 0.6, 0.9, 1.0 );\n"
+" vec4 horizon = vec4( 0.7,0.8,0.88, 1.0 );\n"
+" float fdist = pow(length( aCo.xz-uCamera.xz ) * 0.00047, 2.6);\n"
"\n"
" // Composite\n"
-" vec3 vsurface = mix(surface_tint*backsample.rgb, reflected.rgb, ffresnel );\n"
-" vsurface += spec;\n"
-" \n"
-" FragColor = mix( vec4(vsurface,depthblend), vec4(1.0,1.0,1.0,0.8), fband );\n"
+" vec4 vsurface = water_surf( halfview, surfnorm, depthvalue, beneath, above );\n"
+" vsurface.a -= fdist;\n"
+" FragColor = mix( vsurface, vec4(1.0,1.0,1.0,0.5), fband );\n"
"}\n"
""},
};
gl_Position = uPv * vec4(world_pos,1.0);
vec2 depth_coords = (world_pos.xz-uDepthBounds.xy)*uDepthBounds.zw;
- aUv = vec4(world_pos.xz*0.01,depth_coords);
+ aUv = vec4(world_pos.xz*0.005,depth_coords);
aCo = world_pos;
aDepth = gl_Position.z;
--- /dev/null
+#include "water_ref.glsl"
+
+out vec4 FragColor;
+
+uniform sampler2D uTexMain;
+uniform sampler2D uTexDudv;
+uniform sampler2D uTexDepth;
+uniform sampler2D uTexBack;
+
+uniform vec2 uInvRes;
+uniform float uTime;
+
+uniform vec3 uCamera;
+uniform float uSurfaceY;
+
+in vec4 aUv;
+in vec3 aCo;
+in float aDepth;
+
+void main()
+{
+ // Reflected and warped texture
+ vec2 ssuv = gl_FragCoord.xy*uInvRes;
+
+ vec4 dudva = texture( uTexDudv, aUv.xy - vec2(uTime*0.004f,uTime*0.003f) );
+ vec4 dudvb = texture( uTexDudv, aUv.xy*0.7 - vec2(uTime*0.01,uTime*0.0054) );
+ vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 0.6;
+
+ vec4 reflected = texture( uTexMain, ssuv+distortamt );
+
+ // Surface colour composite
+ float depthvalue = texture( uTexDepth, aUv.zw ).r;
+
+ vec3 colour_shore = vec3( 0.21, 0.6, 0.8 );
+ vec3 colour_ocean = vec3( 0.01, 0.1, 0.2 );
+ vec3 surface_tint = mix(colour_shore, colour_ocean, pow(depthvalue,1.8))*1.5;
+
+ // Foam
+ float fband = fract( aCo.z*0.1+uTime*0.1-depthvalue*10.0 );
+ fband = step( fband+dudvb.g*0.8, 0.5 ) * max((1.0-depthvalue*4.0),0.0);
+
+ // Lighting
+ vec3 surfnorm = vec3(distortamt.x,1.0,distortamt.y);
+
+ vec3 halfview = -normalize( aCo-uCamera );
+ float ffresnel = pow(1.0-dot( surfnorm, halfview ),5.0);
+
+ vec3 lightdir = vec3(0.95,0.0,-0.3);
+ vec3 specdir = reflect( -lightdir, surfnorm );
+ float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;
+
+ // Depth
+ vec4 backsample = texture( uTexBack, ssuv+distortamt*0.1 );
+ float depthblend = pow(backsample.a,0.8);
+
+ // Composite
+ vec3 vsurface = mix(surface_tint*backsample.rgb, reflected.rgb, ffresnel );
+ vsurface += spec;
+
+ FragColor = mix( vec4(vsurface,depthblend), vec4(1.0,1.0,1.0,0.8), fband );
+}
#include "shaders/terrain.h"
#include "shaders/sky.h"
+#include "shaders/planeinf.h"
vg_tex2d tex_terrain_colours = { .path = "textures/gradients.qoi",
.flags = VG_TEXTURE_CLAMP | VG_TEXTURE_NEAREST
static struct
{
glmesh skydome;
+ submodel dome_upper,
+ dome_lower;
}
trender;
{
shader_terrain_register();
shader_sky_register();
+ shader_planeinf_register();
}
static void terrain_init(void)
model *msky = vg_asset_read("models/rs_skydome.mdl");
model_unpack( msky, &trender.skydome );
+
+ trender.dome_lower = *submodel_get( msky, "dome_lower" );
+ trender.dome_upper = *submodel_get( msky, "dome_upper" );
+
free(msky);
}
shader_terrain_uPlane( (v4f){ 0.0f,1.0f,0.0f, wrender.height } );
}
+static void render_lowerdome( m4x3f camera )
+{
+ m4x4f projection, full;
+ pipeline_projection( projection, 0.4f, 1000.0f );
+
+ m4x3f inverse;
+ m3x3_transpose( camera, inverse );
+ v3_copy((v3f){0.0f,0.0f,0.0f}, inverse[3]);
+ m4x3_expand( inverse, full );
+ m4x4_mul( projection, full, full );
+
+ m4x3f identity_matrix;
+ m4x3_identity( identity_matrix );
+
+ shader_planeinf_use();
+ shader_planeinf_uMdl(identity_matrix);
+ shader_planeinf_uPv(full);
+ shader_planeinf_uCamera(camera[3]);
+ shader_planeinf_uPlane( (v4f){0.0f,1.0f,0.0f, water_height()} );
+
+ submodel_draw( &trender.dome_lower );
+}
+
static void render_sky(m4x3f camera)
{
m4x4f projection, full;
shader_sky_uPv(full);
shader_sky_uTexGarbage(0);
shader_sky_uTime( vg_time );
+
+
vg_tex2d_bind( &tex_terrain_noise, 0 );
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
mesh_bind( &trender.skydome );
- mesh_draw( &trender.skydome );
-
+ submodel_draw( &trender.dome_upper );
+
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
}
shader gatelq gate.vs gate_lq.fs
shader water water.vs water.fs
shader sky standard.vs sky.fs
+shader planeinf standard.vs planeinf.fs
}
wrender =
{
- .fbreflect = { .format = GL_RGB, .div = 4 },
+ .fbreflect = { .format = GL_RGB, .div = 3 },
.fbdepth = { .format = GL_RGBA, .div = 4 }
};
vg_info( "Computing depth map\n" );
u8 *img = malloc( kres*kres );
+ boxf interior;
+ v3_add(bounds[0],(v3f){1.0f,1.0f,1.0f},interior[0]);
+ v3_sub(bounds[1],(v3f){1.0f,1.0f,1.0f},interior[1]);
+
v3f volume;
- v3_sub( bounds[1], bounds[0], volume );
- box_copy( bounds, wrender.depthbounds );
+ v3_sub( interior[1], interior[0], volume );
+ box_copy( interior, wrender.depthbounds );
for( int y=0; y<kres; y++ )
{
for( int x=0; x<kres; x++ )
{
v3f pos = { x, 0.0f, y };
- v3_divs( pos, kres, pos );
- v3_muladd( bounds[0], pos, volume, pos );
- pos[1] = wrender.height;
+ pos[0] += 0.5f;
+ pos[1] += 0.5f;
+ v3_divs( pos, kres+1, pos );
+ v3_muladd( interior[0], pos, volume, pos );
+ pos[1] = 2000.0f;
ray_hit hit;
hit.dist = INFINITY;
*dst = (u8)(h*255.0f);
}
else
+ {
*dst = 0;
+ }
}
}
m4x3_invert_affine( camera, inverse );
m4x3_expand( inverse, view );
- v4f clippb = { 0.0f, -1.0f, 0.0f, -(wrender.height) };
+ float bias = -(camera[3][1]-wrender.height)*0.1f;
+ v4f clippb = { 0.0f, -1.0f, 0.0f, -(wrender.height) + bias };
m4x3_mulp( inverse, clippb, clippb );
clippb[3] *= -1.0f;