protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddUniform(ShaderVarType.Mat4, "mdl_matrix"); vert.AddAttribute(ShaderVarType.Vec3, "in_position"); vert.AddAttribute(ShaderVarType.Vec3, "in_texture"); vert.AddAttribute(ShaderVarType.Vec3, "in_normal"); vert.AddVarying(ShaderVarType.Float, "var_shade"); vert.AddVarying(ShaderVarType.Vec3, "var_texture"); vert.Logic = @" void main(void) { var_texture = in_texture; const vec3 sun_dir = normalize(vec3(1.0, -2.0, 0.0)); var_shade = 0.75 + abs(dot(sun_dir, (mdl_matrix * vec4(in_normal, 0.0)).xyz)) * 0.25; vec3 world_pos = (mdl_matrix * vec4(in_position, 1.0)).xyz; gl_Position = proj * view * vec4( world_pos.x + world_offset.x, world_pos.y, world_pos.z + world_offset.y, 1.0 ); } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddUniform(ShaderVarType.Vec4, "body"); vert.AddAttribute(ShaderVarType.Vec2, "in_vertex"); vert.AddVarying(ShaderVarType.Vec3, "var_position"); vert.Logic = @" void main(void) { float r = body.w; vec3 cam = camera - body.xyz; float dist = length(cam); float hyp = sqrt(dist * dist - r * r); float ang = atan(r / hyp); float opp = hyp * sin(ang); float dif = sqrt(r * r - opp * opp); vec3 center = normalize(cam) * dif; vec3 up = normalize(cross(cam, (view * vec4(0, 0, 1, 0)).xyz)) * opp; vec3 right = normalize(cross(cam, up)) * opp; var_position = vec3(center + in_vertex.x * right + in_vertex.y * up) / r; gl_Position = proj * view * vec4(body.xyz + center + in_vertex.x * right + in_vertex.y * up, 1); } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddAttribute(ShaderVarType.Vec2, "in_position"); vert.AddAttribute(ShaderVarType.Vec2, "in_texture"); vert.AddAttribute(ShaderVarType.Vec4, "in_colour"); vert.AddVarying(ShaderVarType.Vec2, "var_texture"); vert.AddVarying(ShaderVarType.Vec4, "var_colour"); vert.Logic = @" void main(void) { var_texture = in_texture; var_colour = in_colour; gl_Position = in_position; } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddAttribute(ShaderVarType.Vec2, "in_position"); vert.AddAttribute(ShaderVarType.Vec2, "in_texture"); vert.AddAttribute(ShaderVarType.Vec4, "in_colour"); vert.AddVarying(ShaderVarType.Vec2, "var_texture"); vert.AddVarying(ShaderVarType.Vec4, "var_colour"); vert.Logic = @" void main(void) { var_texture = in_texture; var_colour = in_colour; gl_Position = in_position; } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddAttribute(ShaderVarType.Vec2, "in_vertex"); vert.AddVarying(ShaderVarType.Vec2, "var_texcoord"); vert.Logic = @" void main(void) { var_texcoord = vec2(in_vertex.x, 1 - in_vertex.y); gl_Position = in_vertex * screen_resolution; } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddAttribute(ShaderVarType.Vec3, "in_vertex"); vert.AddVarying(ShaderVarType.Vec3, "var_texcoord"); vert.Logic = @" void main(void) { vec4 pos = proj * view * vec4(in_vertex, 0); gl_Position = pos.xyww; var_texcoord = in_vertex; } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddAttribute(ShaderVarType.Vec3, "in_vertex"); vert.Logic = @" void main(void) { const float yscale = 2.0 / sqrt(3.0); gl_Position = proj * view * vec4( in_vertex.x + world_offset.x, in_vertex.y * yscale, in_vertex.z + world_offset.y, 1.0 ); } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddUniform(ShaderVarType.Vec2, "scale"); vert.AddUniform(ShaderVarType.Vec3, "position"); vert.AddUniform(ShaderVarType.Vec2, "size"); vert.AddUniform(ShaderVarType.Float, "texture"); vert.AddAttribute(ShaderVarType.Vec3, "in_vertex"); vert.AddVarying(ShaderVarType.Vec3, "var_texture"); vert.Logic = @" void main(void) { switch(int(in_vertex.z)) { case 0: var_texture = vec3(0.0, 0.0, texture); break; case 1: var_texture = vec3(size.x, 0.0, texture); break; case 2: var_texture = vec3(0.0, size.y, texture); break; case 3: var_texture = vec3(size.x, size.y, texture); break; } const float yscale = 2.0 / sqrt(3.0); gl_Position = proj * view * vec4( position.x + world_offset.x, (position.y + in_vertex.y * size.y) * yscale, position.z + world_offset.y, 1.0 ) + vec4(in_vertex.x * scale.x * size.x, 0.0, 0.0, 0.0); } "; }
protected override void ConstructVertexShader(ShaderBuilder vert) { base.ConstructVertexShader(vert); vert.AddAttribute(ShaderVarType.Vec3, "in_vertex"); vert.AddVarying(ShaderVarType.Vec3, "var_tex"); vert.AddVarying(ShaderVarType.Float, "var_shade"); vert.AddVarying(ShaderVarType.Vec2, "var_blood_tex"); vert.AddVarying(ShaderVarType.Float, "var_blood"); vert.Logic = @" void main(void) { int dat = int(in_vertex.z); int ix = int(in_vertex.x); int iz = int(in_vertex.y); float x = (ix & 0xfff) / 8.0; float z = (iz & 0xfff) / 8.0; var_tex = vec3( float(dat & 0x1), float((dat >> 1) & 0x3) / 2.0, float((dat >> 8) & 0xffff) ); const float yscale = 1.0 / sqrt(3.0); vec2 normals[] = vec2[4] ( vec2( 0.5, 0.0), vec2( 0.0, 0.5), vec2(-0.5, 0.0), vec2( 0.0, -0.5) ); float y = float((dat >> 4) & 0xf); vec2 bloodadd; if (y > 0.0f) { int normalno = ((ix >> 12) & 0x1) | ((iz >> 11) & 0x2); bloodadd = normals[normalno]; } else { bloodadd = vec2(0.0, 0.0); } var_shade = 1.0 - 0.125 * float((dat >> 3) & 0x1); var_blood = max(1.0 - y / 2.0, 0.0); var_blood_tex = vec2( x + bloodadd.x, z + bloodadd.y ) * 8.0; gl_Position = proj * view * vec4( x + world_offset.x, y * yscale, z + world_offset.y, 1.0 ); } "; }