;
; Carlswood track shaders
;

;
; Vertex/fragment templates
;
vf_standard
{
  ; Most-often used shader for static objects
  vertex_shader 
  {
    file=standard_v.cg
  }
  fragment_shader
  {
    file=standard_f.cg
  }
}
vf_dyn_standard
{
  ; Dynamic objects (such as cones) with a default shader
  vertex_shader 
  {
    file=dyn_standard_v.cg
  }
  fragment_shader
  {
    file=standard_f.cg
  }
}
vf_standard_transparent
{
  ; Shader for transparent (blended) materials
  vertex_shader 
  {
    file=standard_v.cg
  }
  fragment_shader
  {
    file=standard_transparent_f.cg
  }
}
vf_vertexcolor
{
  ; Carlswood uses vertex coloring a lot in the grass. Other tracks may use 'standard_v.cg' and 'standard_f.cg' instead.
  vertex_shader 
  {
    file=standard_vc_v.cg
  }
  fragment_shader
  {
    file=standard_vc_f.cg
  }
}
vf_animate
{
  ; Animation test (top moves around)
  vertex_shader 
  {
    file=animate_test_v.cg
  }
  fragment_shader
  {
    file=standard_f.cg
  }
}
vf_road
{
  ; The road uses specularity but burned through the red channel to get a coarse gloss map
  specular=1 1 1
  shininess=4
  scale=7.5
  vertex_shader 
  {
    file=standard_v.cg
  }
  fragment_shader
  {
    file=standard_detail_burn_a_f.cg
    ; Burn specularity through alpha
    ;file=standard_burn_a_f.cg
  }
}
vf_sky
{
  vertex_shader
  {
    ;file=sky_daynight_v.cg
    file=sky_v.cg
  }
  fragment_shader
  {
    ;file=sky_daynight_f.cg
    file=sky_f.cg
  }
}
vf_bump
{
  vertex_shader
  {
    file=standard_bump_v.cg
  }
  fragment_shader
  {
    file=standard_bump_f.cg
  }
}
vf_tree
{
  ; Tree fake their normals pointing up
  vertex_shader
  {
    file=standard_tree_v.cg
  }
  fragment_shader
  {
    file=standard_tree_f.cg
  }
}
vf_xtree
{
  ; Tree fake their normals pointing up
  vertex_shader
  {
    ;file=dyn_standard_v.cg
    file=standard_xtree_v.cg
  }
  fragment_shader
  {
    ;file=standard_f.cg
    file=standard_xtree_f.cg
    ; UV coordinates are bad (see http://www.racer.nl/tutorial/xtrees.htm)
    ;file=standard_xtree_f.cg
  }
}

;
; Shaders
;
shader_road~vf_road
{
  ;ambient=1 1 1
  diffuse=0.5 0.5 0.5
  cast_shadow=0
  ; Avoid projected lights cutting through the first layer's texture alpha channel (0..1)
  bounce_alpha=0
  ; Reflectivity of the road for projective lights
  bounce_amount=1.0
  layer0
  {
    map=road.tga
  }
  layer1
  {
    map=road-add.tga
    mode=linear
  }
}
shader_road_tracks01~vf_standard_transparent
{
  cast_shadow=0
  layer0
  {
    ;texenv=replace
    map=road_tracks01.tga
    ; Dithering (but Z-buffered)
    alpha_to_coverage=1
    ; Don't write depth; we're a decal - that makes sure Racer renders the road first, then the tracks on top
    depthwrite=0
    ; Regular blending
    ;blendfunc=blend
    ;alphafunc=gequal 128
    ;depthwrite=0
    ;depthfunc=lequal
  }
}
shader_road_start~vf_road
{
  ; Use same shader as road for specular etc
  diffuse=0.5 0.5 0.5
  cast_shadow=0
  ; Avoid projected lights cutting through the first layer's texture alpha channel (0..1)
  bounce_alpha=0
  ; Reflectivity of the road for projective lights
  bounce_amount=1.0
  layer0
  {
    map=road_start.tga
  }
  layer1
  {
    map=road-add.tga
    mode=linear
  }
}

shader_sky~vf_sky
{
  sky=1
  cull=none
  layer0
  {
    map=sky_clouds.tga
    depthwrite=0
    depthfunc=always
  }
  layer1
  {
    map=sky_night.tga
    depthwrite=0
    depthfunc=always
  }
}

shader_kerbs~vf_bump
{
  ; Turn off shadowcasting? Only useful with really low suns
  cast_shadow=0
  diffuse=1 1 1
  ;ambient=0 0 0
  specular=0.5 0.5 0.5
  shininess=30
  tangents=1
  layer0
  {
    map=kerb.tga
  }
  layer1
  {
    map=kerb_normal.tga
    ; Normals don't need conversion from SRGB to linear
    mode=linear
  }
}
shader_concrete02~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=concrete02.tga
    ;mipmap=0
  }
}
shader_gravel~vf_standard
{
  cast_shadow=0
  layer0
  {
    map=gravel.tga
  }
}
shader_grass1a~vf_vertexcolor
{
  cast_shadow=0
  layer0
  {
    ;map=xs02.tga
    map=grass1a.tga
  }
}
shader_sand~vf_vertexcolor
{
  cast_shadow=0
  layer0
  {
    map=sand.tga
  }
}
shader_xs01~vf_standard
{
  cast_shadow=0
  layer0
  {
    map=xs01.tga
    ;mipmap=0
  }
}
shader_xs02~vf_standard
{
  cast_shadow=0
  layer0
  {
    map=xs02.tga
    ;mipmap=0
  }
}
shader_xsnd~vf_vertexcolor
{
  cast_shadow=0
  layer0
  {
    ;map=xs02.tga
    map=grass1a.tga
    ;mipmap=0
  }
}
shader_tree1~vf_xtree
{
  cast_shadow=1
  ; Light fall-through
  ambient=3 3 3
  layer0
  {
    map=tree1.tga
    alpha_to_coverage=1
    depthwrite=1
    ;blendfunc=blend
    alphafunc=gequal 128
    ; Avoid too much light difference based on direction
    ;diffuse=0 0 0
    ;diffuse=0.5 0.6 0.5 
    ;ambient=1 1 1
    ;diffuse=0.1 0.1 0.1
  }
}
shader_tree3~vf_xtree
{
  cast_shadow=1
  layer0
  {
    map=tree3.tga
    alpha_to_coverage=1
    depthwrite=1
    ;blendfunc=blend
    alphafunc=gequal 128
    ;depthwrite=0
    ; Avoid too much light difference based on direction
    ;diffuse=0 0 0
    ;diffuse=0.5 0.6 0.5 
    ;ambient=1 1 1
    ;diffuse=0.1 0.1 0.1
  }
}
shader_tretp~vf_xtree
{
  cast_shadow=1
  layer0
  {
    map=tretp.tga
    alpha_to_coverage=1
    depthwrite=1
    ;blendfunc=blend
    alphafunc=gequal 128
    ;depthwrite=0
    ; Avoid too much light difference based on direction
    ;diffuse=0 0 0
    ;diffuse=0.5 0.6 0.5
    ;ambient=1 1 1
    ;diffuse=0.1 0.1 0.1
  }
}
shader_tretopf~vf_xtree
{
  cast_shadow=1
  layer0
  {
    map=tretopf.tga
    alpha_to_coverage=1
    depthwrite=1
    ;blendfunc=blend
    alphafunc=gequal 128
    ;depthwrite=0
    ; Avoid too much light difference based on direction
    ;ambient=1 1 1
    ;diffuse=0.5 0.5 0.5
    ;diffuse=0.1 0.1 0.1
  }
}
shader_woods01~vf_tree
{
  cast_shadow=1
  ; Trouble with sun behind trees if blended
  layer0
  {
    map=woods01.tga
    alpha_to_coverage=1
    alphafunc=gequal 128
    depthwrite=1
    ;blendfunc=blend
    wrap_t=clamp_to_edge
    depthwrite=1
    ; Avoid too much light difference based on direction
    ;diffuse=2.5 0.6 0.5
    ;ambient=1 1 1
    ;diffuse=0.1 0.1 0.1
  }
}
shader_twalltp~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=twalltp.tga
    ;texenv=replace
  }
}
shader_twall~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=twall.tga
    ;texenv=replace
  }
}
shader_signs~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=signs.tga
    texenv=replace
  }
}

shader_fence02~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=fence02.tga
    blendfunc=blend
    alphafunc=gequal 100
    shininess=128
    depthwrite=1 
    texenv=replace
  }
}
shader_iron_fence~vf_standard
{
  cast_shadow=1
  specular=1 1 1
  shininess=70
  layer0
  {
    ;blendfunc=one src_alpha
    map=iron_fence.tga
    ;shininess=128
    ;diffuse=1 1 1
    ;ambient=1 1 1
  }
}

shader_met_galv~vf_standard
{
  cast_shadow=1
  Xlayer0
  {
    texenv=replace
    map=$trackenvmap
    texgen_s=reflection_map
    texgen_t=reflection_map
    texgen_r=reflection_map
    diffuse=-1 -1 -1 1
    ambient=0.5 0.5 .05 1
  }
  layer0
  {
    ;blendfunc=one src_alpha
    map=met_galv.tga
    ;shininess=128
    ;specular=1 1 1
    ;diffuse=1 1 1
    ;ambient=1 1 1
    ;alphafunc=lequal 200
  }
}

shader_cone~vf_dyn_standard
{
  cast_shadow=1
  ; Cones (used to have the material 'shader_c_orange) in v0.8.2-
  layer0
  {
    map=c_orange.tga
  }
}

shader_wood_old~vf_standard
{
  cast_shadow=1
  ; Cones
  layer0
  {
    map=wood_old.tga
  }
}
shader_s_start~vf_standard
{
  cast_shadow=1
  ; Start sign
  layer0
  {
    map=s_start.tga
  }
}
shader_c_white~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=c_white.tga
  }
}
shader_s_201m~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=s_201m.tga
  }
}
shader_s_402m~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=s_402m.tga
  }
}
shader_s_1000m~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=s_1000m.tga
  }
}
shader_rock~vf_standard
{
  cast_shadow=1
  layer0
  {
    map=rock.tga
  }
}

;
; Multisub shader; in Racer v0.8.9, DOFs loaded with materials that only have submaterials
; are renamed internally as 'multisub'. Any material without a shader gets warned about,
; and this shader catches the top levels of multi/sub materials
; You can use the latest Modeler to optimize this, and it will try to re-organize
; the multisub material to a 'main' material.
;
shader_multisub~vf_standard
{
  cast_shadow=1
  layer0
  {
    ; Take any map
    map=rock.tga
  }
}

shader_sphere~vf_dyn_standard
{
  cast_shadow=1
  layer0
  {
    map=c_orange.tga
  }
}
