Changeset 1275


Ignore:
Timestamp:
Apr 22, 2012, 5:22:26 PM (11 years ago)
Author:
sam
Message:

orbital: port the current shader to HLSL (together with its bugs for now).

Location:
trunk/orbital
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/mesh.h

    r1274 r1275  
    5656            else CASE("ascb") { p = GetArg(p, v3, f1); AppendSmoothChamfBox(v3, f1); }
    5757            else CASE("afcb") { p = GetArg(p, v3, f1); AppendFlatChamfBox(v3, f1); }
    58             else CASE("asph") { p = GetArg(p, v3, f1); AppendSphere(v3, f1); }
     58            else CASE("asph") { p = GetArg(p, v3, f1); AppendSphere(v3, (int)f1); }
    5959            else CASE("as")  { p = GetArg(p, f1, f2, f3, f4, f5); AppendStar((int)f1, f2, f4, (int)f5, (int)f5); }
    6060            else CASE("aes") { /* TODO */ }
    6161            else CASE("ad")  { p = GetArg(p, f1, f2, f3); AppendDisc((int)f1, f2, (int)f3); }
    62             else CASE("at")  { p = GetArg(p, f1, f2); AppendSimpleTriangle(f1, f2); }
    63             else CASE("aq")  { p = GetArg(p, f1, f2); AppendSimpleQuad(f1, f2); }
     62            else CASE("at")  { p = GetArg(p, f1, f2); AppendSimpleTriangle(f1, (int)f2); }
     63            else CASE("aq")  { p = GetArg(p, f1, f2); AppendSimpleQuad(f1, (int)f2); }
    6464            else CASE("acg") { /* TODO */ }
    6565            else CASE("irb") { MeshConvert(); }
     
    208208            "          uniform float3x3 in_NormalMat,"
    209209            "          out float4 out_Position : POSITION,"
    210             "          out float4 pass_Color : COLOR) {"
    211             "    float4 Light = float4(10.0, 1.0, 1.0, 1.0);"
    212             "    float3 Kd = float3(1.0, 0.8, 0.8);"
    213             "    float3 Ld = float3(1.0, 0.8, 0.8);"
    214             ""
    215             "    float3 tnorm = normalize(mul(in_NormalMat, in_Normal));"
    216             "    float4 Eye = mul(in_ModelView, float4(in_Vertex, 1.0));"
    217             "    float3 s = normalize((Light - Eye).xyz);"
    218             ""
    219             "    pass_Color = float4(Ld * Kd * max(dot(s, tnorm), 0.0), 1.0);"
    220             "    out_Position = mul(in_Proj, Eye);"
     210            "          out float4 pass_Color : COLOR)"
     211            "{"
     212            "    float alpha_mul = 1.0f;"
     213            "    float ambient_mul = 0.5f;"
     214            "    float3 diffuse_dir = normalize(float3(-0.7, -0.7, -0.4));"
     215            "    float4 frontColor = float4(1.0, 1.0, 1.0, 1.0);"
     216            "    float4 backColor = float4(0.3, 0.2, 0.0, 1.0);"
     217            "    float3 world_normal = normalize(mul(in_NormalMat, in_Normal));"
     218            "    float d = dot(world_normal, diffuse_dir);"
     219            "    float2 diffuse_mul = max(float2(-d, d), 0.0);"
     220            "    diffuse_mul[0] = min(diffuse_mul[0] + ambient_mul, 1.0);"
     221            "    float4 spec_col = float4(0.8, 0.85, 0.4, 1.0);"
     222            "    float3 spec_dir = normalize(float3(-0.7, -0.7, 0.4));"
     223            "    float spec_exp = 60.0f;"
     224            "    float spec_mul = max(-dot(world_normal, spec_dir), 0.0);"
     225            "    spec_mul = saturate(pow(spec_mul, spec_exp));"
     226            "    float4 TmpColor = frontColor * in_Color;"
     227            "    pass_Color = saturate(diffuse_mul[0] * TmpColor"
     228            "                           + diffuse_mul[1] * backColor"
     229            "                           + spec_mul * spec_col);"
     230            "    pass_Color.a *= alpha_mul;"
     231            "    float4 viewPosition = mul(in_ModelView, float4(in_Vertex, 1.0));"
     232            "    out_Position = mul(in_Proj, viewPosition);"
    221233            "}",
    222234
  • trunk/orbital/orbital.cpp

    r1273 r1275  
    5151
    5252    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0))
    53               * mat4::rotate(m_angle * 0.25, vec3(0, 0, 1));
     53              * mat4::rotate(m_angle * 0.25f, vec3(0, 0, 1));
    5454    mat4 model = mat4::translate(vec3(0, 0, -4.5))
    5555               * mat4::scale(vec3(0.025));
Note: See TracChangeset for help on using the changeset viewer.