data = obj.SR_data.ent_unlock[0]
if data.target:
cv_draw_arrow( obj.location, data.target.location, (0,1.0,0.0) )
+ cc1 = (0.4,0.3,0.2)
+ info_cu = Vector((1.2,0.01,0.72))*0.5
+ info_co = Vector((0.0,0.0,0.72))*0.5
+ cv_draw_ucube( obj.matrix_world, cc1, info_cu, info_co)
+
+ vs = [Vector((-0.2,0.0,0.10)),Vector((-0.2,0.0,0.62)),\
+ Vector(( 0.2,0.0,0.62)),Vector((-0.2,0.0,0.30)),\
+ Vector(( 0.1,0.0,0.30))]
+ for v in range(len(vs)):#{
+ vs[v] = obj.matrix_world @ vs[v]
+ #}
+
+ cv_view_verts += [vs[0],vs[1],vs[1],vs[2],vs[3],vs[4]]
+ cv_view_colours += [cc1,cc1,cc1,cc1,cc1,cc1]
#}
elif ent_type == 'ent_audio':#{
if obj.SR_data.ent_audio[0].flag_3d:
/* Print integer into buffer with max length len
* retuns the number of digits written to buf */
-VG_STATIC int highscore_intl( char *buf, int value, int len )
-{
- char temp[32];
+VG_STATIC int highscore_intl( char *buf, int value, int len ){
+ if( value ){
+ char temp[32];
+ int i=0;
+ while(value){
+ if( i>=len )
+ break;
+
+ temp[ i ++ ] = '0' + (value % 10);
+ value /= 10;
+ }
- int i=0;
- while(value){
- if( i>=len )
- break;
+ if( i>len )
+ i = len;
- temp[ i ++ ] = '0' + (value % 10);
- value /= 10;
- }
-
- if( i>len )
- i = len;
-
- for( int j=0; j<i; j ++ )
- buf[j] = temp[ i-1-j ];
+ for( int j=0; j<i; j ++ )
+ buf[j] = temp[ i-1-j ];
- return i;
+ return i;
+ }
+ else{
+ buf[ 0 ] = '0';
+ return 1;
+ }
}
/* Clear buffer with length using clr character */
"\n"
" aUv = a_uv;\n"
" aNorm = vec4( mat3(uMdl) * a_norm, 0.0 );\n"
-" aCo = a_co;\n"
+" aCo = co;\n"
" aWorldCo = world_pos0;\n"
"}\n"
""},
aUv = a_uv;
aNorm = vec4( mat3(uMdl) * a_norm, 0.0 );
- aCo = a_co;
+ aCo = co;
aWorldCo = world_pos0;
}
uniform sampler2D uTexGarbage; // unused
-uniform sampler2D uTexMain;
+uniform sampler2D uTexMain; // unused
uniform vec3 uCamera;
-uniform vec4 uPlane;
+uniform float uTime;
+uniform float uOpacity;
+uniform float uColourize;
#include "common_scene.glsl"
#include "motion_vectors_fs.glsl"
-void main()
-{
+vec3 pal( float t ){
+ vec3 a = vec3(0.30,0.3,0.3);
+ vec3 b = vec3(0.8);
+ vec3 c = vec3(0.28,0.3,0.4);
+ vec3 d = vec3(0.00,0.1,0.1);
+ return a + b*cos( 6.28318*(c*t+d) );
+}
+
+void main(){
compute_motion_vectors();
vec3 vfrag = vec3(0.5,0.5,0.5);
- vec4 vsamplemain = texture( uTexMain, aUv );
vec3 qnorm = aNorm.xyz;
- vfrag = vsamplemain.rgb;
+ //vec4 vsamplemain = texture( uTexMain, aUv );
+ //vfrag = vsamplemain.rgb;
+
+ vec4 spread0 = uTime*0.0002*vec4( 17.3,-19.6, 23.2,-47.7 );
+ vec4 spread1 = uTime*0.0002*vec4( -13.3, 12.6,-28.2, 14.7 );
+
+ vec2 p = aCo.xy + vec2(0.3);
+ float a = atan( p.y/p.x );
+ vec4 v0 = step( vec4(0.5), fract(vec4(a) + spread0) );
+ vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );
+
+ float d = ( v0.x+v0.y+v0.z+v0.w +
+ v1.x+v1.y+v1.z+v1.w ) * 0.125f;
+
+ float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);
+ float x = d*0.8+length(p)*0.3;
+ x = (floor(x*8.0) + step(dither, fract(x * 8.0))) / 8.0;
+
+ if( x + (uOpacity*2.0-1.0) < 0.5 )
+ discard;
+
+ vfrag = mix( vec3(x), pal( x ), uColourize );
- if( g_light_preview == 1 )
- {
+ if( g_light_preview == 1 ){
vfrag = vec3(0.5);
}
"\n"
" aUv = a_uv;\n"
" aNorm = vec4( mat3(uMdl) * a_norm, 0.0 );\n"
-" aCo = a_co;\n"
+" aCo = co;\n"
" aWorldCo = world_pos0;\n"
"}\n"
""},
"uniform sampler2D uTexGarbage; // unused\n"
"uniform sampler2D uTexMain;\n"
"uniform vec3 uCamera;\n"
-"uniform vec4 uPlane;\n"
+"uniform float uTime;\n"
+"uniform float uOpacity;\n"
+"uniform float uColourize;\n"
"\n"
"#line 1 1 \n"
"// :D\n"
" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
"}\n"
"\n"
-"#line 7 0 \n"
+"#line 9 0 \n"
"#line 1 2 \n"
"const float k_motion_lerp_amount = 0.01;\n"
"\n"
" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
"}\n"
"\n"
-"#line 8 0 \n"
+"#line 10 0 \n"
+"\n"
+"vec3 pal( float t ){\n"
+" vec3 a = vec3(0.3,0.3,0.3);\n"
+" vec3 b = vec3(1.00,1.0,1.0);\n"
+" vec3 c = vec3(0.28,0.3,0.4);\n"
+" vec3 d = vec3(0.00,0.1,0.1);\n"
+" return a + b*cos( 6.28318*(c*t+d) );\n"
+"}\n"
"\n"
"void main()\n"
"{\n"
" compute_motion_vectors();\n"
"\n"
" vec3 vfrag = vec3(0.5,0.5,0.5);\n"
-" vec4 vsamplemain = texture( uTexMain, aUv );\n"
" vec3 qnorm = aNorm.xyz;\n"
"\n"
-" vfrag = vsamplemain.rgb;\n"
+" //vec4 vsamplemain = texture( uTexMain, aUv );\n"
+" //vfrag = vsamplemain.rgb;\n"
"\n"
-" if( g_light_preview == 1 )\n"
-" {\n"
+" vec4 spread0 = uTime*0.0002*vec4( 17.3,-19.6, 23.2,-47.7 );\n"
+" vec4 spread1 = uTime*0.0002*vec4( -13.3, 12.6,-28.2, 14.7 );\n"
+"\n"
+" vec2 p = aCo.xy + vec2(0.3);\n"
+" float a = atan( p.y/p.x );\n"
+" vec4 v0 = step( vec4(0.5), fract(vec4(a) + spread0) );\n"
+" vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );\n"
+"\n"
+" float d = ( v0.x+v0.y+v0.z+v0.w +\n"
+" v1.x+v1.y+v1.z+v1.w ) * 0.0625;\n"
+" \n"
+" float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);\n"
+" const float STEPS = 8.;\n"
+" float x = d*0.8+length(p)*0.2;\n"
+" x = (floor(x * STEPS) + step(dither, fract(x * STEPS))) / STEPS;\n"
+"\n"
+" if( x + (uOpacity*2.0-1.0) < 0.5 ) \n"
+" discard;\n"
+"\n"
+" vfrag = mix( vec3(x), pal( x ), uColourize );\n"
+"\n"
+" if( g_light_preview == 1 ){\n"
" vfrag = vec3(0.5);\n"
" }\n"
"\n"
-" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n"
-" oColour = vec4( vfrag, 1.0 );\n"
+" vec3 litfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n"
+" oColour = vec4( litfrag, 1.0 );\n"
"}\n"
""},
};
static GLuint _uniform_scene_font_uTexGarbage;
static GLuint _uniform_scene_font_uTexMain;
static GLuint _uniform_scene_font_uCamera;
-static GLuint _uniform_scene_font_uPlane;
+static GLuint _uniform_scene_font_uTime;
+static GLuint _uniform_scene_font_uOpacity;
+static GLuint _uniform_scene_font_uColourize;
static GLuint _uniform_scene_font_g_world_depth;
static GLuint _uniform_scene_font_uLightsArray;
static GLuint _uniform_scene_font_uLightsIndex;
static void shader_scene_font_uCamera(v3f v){
glUniform3fv(_uniform_scene_font_uCamera,1,v);
}
-static void shader_scene_font_uPlane(v4f v){
- glUniform4fv(_uniform_scene_font_uPlane,1,v);
+static void shader_scene_font_uTime(float f){
+ glUniform1f(_uniform_scene_font_uTime,f);
+}
+static void shader_scene_font_uOpacity(float f){
+ glUniform1f(_uniform_scene_font_uOpacity,f);
+}
+static void shader_scene_font_uColourize(float f){
+ glUniform1f(_uniform_scene_font_uColourize,f);
}
static void shader_scene_font_g_world_depth(int i){
glUniform1i(_uniform_scene_font_g_world_depth,i);
_uniform_scene_font_uTexGarbage = glGetUniformLocation( _shader_scene_font.id, "uTexGarbage" );
_uniform_scene_font_uTexMain = glGetUniformLocation( _shader_scene_font.id, "uTexMain" );
_uniform_scene_font_uCamera = glGetUniformLocation( _shader_scene_font.id, "uCamera" );
- _uniform_scene_font_uPlane = glGetUniformLocation( _shader_scene_font.id, "uPlane" );
+ _uniform_scene_font_uTime = glGetUniformLocation( _shader_scene_font.id, "uTime" );
+ _uniform_scene_font_uOpacity = glGetUniformLocation( _shader_scene_font.id, "uOpacity" );
+ _uniform_scene_font_uColourize = glGetUniformLocation( _shader_scene_font.id, "uColourize" );
_uniform_scene_font_g_world_depth = glGetUniformLocation( _shader_scene_font.id, "g_world_depth" );
_uniform_scene_font_uLightsArray = glGetUniformLocation( _shader_scene_font.id, "uLightsArray" );
_uniform_scene_font_uLightsIndex = glGetUniformLocation( _shader_scene_font.id, "uLightsIndex" );
m4x3_expand_aabb_aabb( volume->to_world, bound,
(boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}} );
}
+ else if( type == k_ent_unlock ){
+ ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+
+ boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f},
+ { 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}};
+ m4x3f transform;
+ mdl_transform_m4x3( &unlock->transform, transform );
+ m4x3_expand_aabb_aabb( transform, bound, box );
+ }
+ else{
+ vg_fatal_error( "Programming error\n" );
+ }
}
VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ){
(boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}},
0xf000ff00 );
}
+ else if( type == k_ent_unlock ){
+ ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+
+ boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f},
+ { 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}};
+ m4x3f transform;
+ mdl_transform_m4x3( &unlock->transform, transform );
+ vg_line_boxf_transformed( transform, box, 0xf0ff0000 );
+ }
else{
vg_fatal_error( "Programming error\n" );
}
ent_volume *volume = mdl_arritm( &world->ent_volume, index );
v3_copy( volume->to_world[3], closest );
}
+ else if( type == k_ent_unlock ){
+ ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+ v3_copy( unlock->transform.co, closest );
+ }
else{
vg_fatal_error( "Programming error\n" );
}
/* sort lists */
const f32 radius = 40.0f;
bh_iter it;
- bh_iter_init_range( 0, &it, pos, radius );
+ bh_iter_init_range( 0, &it, pos, radius+10.0f );
i32 idx;
u32 challenge_list[ 32 ],
if( challenge->flags & k_ent_challenge_hidden ) continue;
f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius),
- scale = vg_smoothstepf( vg_clampf( 10.0f-dist*10.0f, 0.0f,1.0f ) );
+ scale = vg_smoothstepf( vg_clampf( 5.0f-dist*5.0f, 0.0f,1.0f ) );
v3_fill( challenge->transform.s, scale );
shader_scene_font_uTexGarbage(0);
shader_scene_font_uTexMain(1);
shader_scene_font_uPv( skaterift.cam.mtx.pv );
+ shader_scene_font_uTime( vg.time );
/* TODO: Code dupe... */
world_link_lighting_ub( world, _shader_scene_font.id );
mesh_bind( &gui.font.mesh );
+ char buf[32];
+ u32 count = 0;
+
+ for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
+ ent_unlock *unlock = mdl_arritm( &world->ent_unlock, i );
+ vg_line_point( unlock->transform.co, 0.2f, VG__GREEN );
+ if( unlock->status ) count ++;
+ }
+
+ int c=0;
+ c+=highscore_intl( buf+c, count, 3 );
+ buf[c++] = '/';
+ c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_unlock), 3 );
+ buf[c++] = '\0';
+
+ f32 w = font3d_string_width( &gui.font, 1, buf );
+ m4x3f mlocal;
+ m3x3_identity( mlocal );
+ mlocal[3][0] = -w*0.5f;
+
for( u32 i=0; i<unlock_count; i++ ){
u32 index = unlock_list[ i ];
ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
m4x3f mmdl;
mdl_transform_m4x3( &unlock->transform, mmdl );
+ m4x3_mul( mmdl, mlocal, mmdl );
+
+ vg_line_point( unlock->transform.co, 0.25f, VG__RED );
+
+ f32 dist = v3_dist( unlock->transform.co, pos ) * (1.0f/radius),
+ scale = vg_smoothstepf( vg_clampf( 10.0f-dist*10.0f, 0.0f,1.0f ) ),
+ colour = 0.0f;
+
+ if( unlock->status )
+ colour = 1.0f;
+
+ shader_scene_font_uOpacity( scale );
+ shader_scene_font_uColourize( colour );
struct font3d_render render = {
.font = &gui.font,
.shader = k_font_shader_world
};
- font3d_begin( "Test!", &skaterift.cam, mmdl, &render );
+ font3d_begin( buf, &skaterift.cam, mmdl, &render );
font3d_draw( &render );
}
}