Mercurial > hg > Game > Cerium
changeset 1339:035e8c39508c draft
change gouraud shading..not work yet.
author | Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 10 Jan 2012 17:15:44 +0900 |
parents | 64b54c99d895 |
children | b6ee60edacf0 |
files | Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/CreateSpan.cc |
diffstat | 2 files changed, 24 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Tue Dec 20 18:10:08 2011 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Tue Jan 10 17:15:44 2012 +0900 @@ -76,18 +76,24 @@ light_vector[0] = vertex[0] - light[0]; light_vector[1] = vertex[1] - light[1]; - light_vector[2] = vertex[2] - light[3]; + light_vector[2] = vertex[2] - light[2]; light_vector[3] = 0; - normal_vector[0] = vertex[0] - light[0]; - normal_vector[1] = vertex[1] - light[1]; - normal_vector[2] = vertex[2] - light[3]; + normal_vector[0] = normal[0]; + normal_vector[1] = normal[1]; + normal_vector[2] = normal[2]; normal_vector[3] = 0; normalize(light_vector, light_vector); normalize(normal_vector, normal_vector); - return innerProduct(light_vector, normal_vector); + float diffuse = innerProduct(light_vector, normal_vector); + + if ( diffuse < 0 ) { + diffuse = 0; + } + + return diffuse; } @@ -130,12 +136,13 @@ int *light_switch = (int*)smanager->global_get(LightSwitch); int light_num = 4; // test - float diffuse1 = 1; - float diffuse2 = 1; - float diffuse3 = 1; for (int i = 0; i < in_pp->info.size; i++) { + float diffuse1 = 0; + float diffuse2 = 0; + float diffuse3 = 0; + TrianglePack tri = in_pp->tri[i]; xyz1[0] = tri.ver1.x; @@ -185,7 +192,7 @@ // 光源のスイッチが入ってたら if (light_switch[j] == 1) { // 複数の光源の計算, 全部足し合わせてみる.. - // あとで255を超えた値は、255にされるからここではいくら足してもいい + // rdb値は255を超えた値は、255にされるからここではいくら足してもいい diffuse1 += lighting(xyz1, normal1, &light_xyz[j*4]); diffuse2 += lighting(xyz2, normal2, &light_xyz[j*4]); diffuse3 += lighting(xyz3, normal3, &light_xyz[j*4]); @@ -214,7 +221,8 @@ } else { - + + // ここは0じゃなくて、ppに登録しなければいい。pp->info.size をデクリメントすればいいはず xyz1[0] = 0; xyz1[1] = 0; xyz1[2] = 0; @@ -238,7 +246,7 @@ triangle->ver1.tex_x = tri.ver1.tex_x; triangle->ver1.tex_y = tri.ver1.tex_y; // test - triangle->ver1.diffuse = diffuse1; + triangle->ver1.diffuse = diffuse1; triangle->ver2.x = xyz2[0]; triangle->ver2.y = xyz2[1];
--- a/Renderer/Engine/task/CreateSpan.cc Tue Dec 20 18:10:08 2011 +0900 +++ b/Renderer/Engine/task/CreateSpan.cc Tue Jan 10 17:15:44 2012 +0900 @@ -230,7 +230,7 @@ tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); // test - tmp_diffuse_l = calc(vMid10->diffuse - vMin->diffuse, div_y, i, vMin->diffuse); + tmp_diffuse_l = calc(vMid10->diffuse - vMin->diffuse, div_y, i, vMin->diffuse); tmp_diffuse_r = calc(vMid->diffuse - vMin->diffuse, div_y, i, vMin->diffuse); length = (tmp_xpos > tmp_end) @@ -259,8 +259,8 @@ start_tex_y = tmp_tey2; end_tex_y = tmp_tey1; // test - diffuse_l = tmp_diffuse_l; - diffuse_r = tmp_diffuse_r; + diffuse_l = tmp_diffuse_r; + diffuse_r = tmp_diffuse_l; } else { x = (int)tmp_xpos; length = (int)(tmp_end)-(int)(tmp_xpos)+1; @@ -271,8 +271,8 @@ start_tex_y = tmp_tey1; end_tex_y = tmp_tey2; // test - diffuse_l = tmp_diffuse_r; - diffuse_r = tmp_diffuse_l; + diffuse_l = tmp_diffuse_l; + diffuse_r = tmp_diffuse_r; } // ここいる? load してその後必ず、wait してるように見える。