Greatly improve shading model
- Directional toon lighting component on entities. (extension of the shadow light source) The shadows were doing this anyways, but with extremely bad stairstepping. Now it smoothly blends into the shadow. - Greatly reduce shadow acne via the above and a larger bias. - Respect culling mode for each model. - Two sided shading for course models. - Disable alpha for water that does not use it. - Only GBA Sky Garden's skybox receives shadows now. - Custom light positions for some maps. (you can guess which)
This commit is contained in:
1 parent
f583ad11b1
commit
bbb61394f4
11 files changed
+179
-89
No files matched your search
+38
-38
@@ -14,53 +14,53 @@ window.MKDSCONST = new (function() {
|
||||
this.COURSEDIR = "/data/Course/";
|
||||
|
||||
this.COURSES = [ //in order of course id, nitro through retro
|
||||
"cross_course",
|
||||
"bank_course",
|
||||
"beach_course",
|
||||
"mansion_course",
|
||||
{name:"cross_course", music: 74},
|
||||
{name:"bank_course", music: 16},
|
||||
{name:"beach_course", music: 15},
|
||||
{name:"mansion_course", music: 21, lightHeight: 20/180, lightAngle: 160/180},
|
||||
|
||||
"desert_course",
|
||||
"town_course",
|
||||
"pinball_course",
|
||||
"ridge_course",
|
||||
{name:"desert_course", music: 38, lightHeight: 40/180},
|
||||
{name:"town_course", music: 17},
|
||||
{name:"pinball_course", music: 19},
|
||||
{name:"ridge_course", music: 36},
|
||||
|
||||
"snow_course",
|
||||
"clock_course",
|
||||
"mario_course",
|
||||
"airship_course",
|
||||
{name:"snow_course", music: 37},
|
||||
{name:"clock_course", music: 39},
|
||||
{name:"mario_course", music: 74},
|
||||
{name:"airship_course", music: 18, lightHeight: 40/180, lightAngle: 140/180},
|
||||
|
||||
"stadium_course",
|
||||
"garden_course",
|
||||
"koopa_course",
|
||||
"rainbow_course",
|
||||
{name:"stadium_course", music: 19},
|
||||
{name:"garden_course", music: 20},
|
||||
{name:"koopa_course", music: 40},
|
||||
{name:"rainbow_course", music: 41},
|
||||
|
||||
|
||||
"old_mario_sfc",
|
||||
"old_momo_64",
|
||||
"old_peach_agb",
|
||||
"old_luigi_gc",
|
||||
{name:"old_mario_sfc", music: 22},
|
||||
{name:"old_momo_64", music: 30},
|
||||
{name:"old_peach_agb", music: 26},
|
||||
{name:"old_luigi_gc", music: 33},
|
||||
|
||||
"old_donut_sfc",
|
||||
"old_frappe_64",
|
||||
"old_koopa_agb",
|
||||
"old_baby_gc",
|
||||
{name:"old_donut_sfc", music: 24},
|
||||
{name:"old_frappe_64", music: 31},
|
||||
{name:"old_koopa_agb", music: 27},
|
||||
{name:"old_baby_gc", music: 34},
|
||||
|
||||
"old_noko_sfc",
|
||||
"old_choco_64",
|
||||
"old_luigi_agb",
|
||||
"old_kinoko_gc",
|
||||
{name:"old_noko_sfc", music: 23},
|
||||
{name:"old_choco_64", music: 29},
|
||||
{name:"old_luigi_agb", music: 26},
|
||||
{name:"old_kinoko_gc", music: 35},
|
||||
|
||||
"old_choco_sfc",
|
||||
"old_hyudoro_64",
|
||||
"old_sky_agb",
|
||||
"old_yoshi_gc",
|
||||
{name:"old_choco_sfc", music: 25},
|
||||
{name:"old_hyudoro_64", music: 32},
|
||||
{name:"old_sky_agb", music: 28, skyboxShadows: true},
|
||||
{name:"old_yoshi_gc", music: 33, lightHeight: 30/180, lightAngle: 111/180},
|
||||
|
||||
"mini_stage1",
|
||||
"mini_stage2",
|
||||
"mini_stage3",
|
||||
"mini_stage4",
|
||||
"mini_block_64",
|
||||
"mini_dokan_gc"
|
||||
{name:"mini_stage1", music: 43, battle: true},
|
||||
{name:"mini_stage2", music: 43, battle: true, lightHeight: 20/180, lightAngle: 160/180},
|
||||
{name:"mini_stage3", music: 43, battle: true},
|
||||
{name:"mini_stage4", music: 43, battle: true},
|
||||
{name:"mini_block_64", music: 43, battle: true},
|
||||
{name:"mini_dokan_gc", music: 43, battle: true}
|
||||
|
||||
]
|
||||
|
||||
|
||||
@@ -88,11 +88,11 @@ window.clientScene = function(wsUrl, wsInstance, res) {
|
||||
var mainNarc, texNarc
|
||||
if (obj.c.substr(0, 5) == "mkds/") {
|
||||
var cnum = Number(obj.c.substr(5));
|
||||
var music = MKDSCONST.COURSE_MUSIC[cnum];
|
||||
var cDir = MKDSCONST.COURSEDIR+MKDSCONST.COURSES[cnum];
|
||||
var course = MKDSCONST.COURSE[cnum];
|
||||
var cDir = MKDSCONST.COURSEDIR+course.name;
|
||||
var mainNarc = new narc(lz77.decompress(gameROM.getFile(cDir+".carc")));
|
||||
var texNarc = new narc(lz77.decompress(gameROM.getFile(cDir+"Tex.carc")));
|
||||
setUpCourse(mainNarc, texNarc, music, obj)
|
||||
setUpCourse(mainNarc, texNarc, course, obj)
|
||||
}
|
||||
else throw "custom tracks are not implemented yet!"
|
||||
}
|
||||
@@ -124,7 +124,7 @@ window.clientScene = function(wsUrl, wsInstance, res) {
|
||||
}
|
||||
}
|
||||
|
||||
function setUpCourse(mainNarc, texNarc, music, obj) {
|
||||
function setUpCourse(mainNarc, texNarc, course, obj) {
|
||||
var chars = [];
|
||||
for (var i=0; i<obj.k.length; i++) {
|
||||
var k = obj.k[i];
|
||||
@@ -142,7 +142,7 @@ window.clientScene = function(wsUrl, wsInstance, res) {
|
||||
}
|
||||
}
|
||||
|
||||
t.activeScene = new courseScene(mainNarc, texNarc, music, chars, {}, res);
|
||||
t.activeScene = new courseScene(mainNarc, texNarc, course, chars, {}, res);
|
||||
|
||||
for (var i=0; i<obj.k.length; i++) {
|
||||
t.activeScene.karts[i].active = obj.k[i].active;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// render/*
|
||||
//
|
||||
|
||||
window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes) {
|
||||
|
||||
window.courseScene = function(mainNarc, texNarc, courseObj, chars, options, gameRes) {
|
||||
var music = courseObj.music;
|
||||
var startSetups = [
|
||||
{maxplayers:12, toAline:4, xspacing:32, yspacing:32, liney:160},
|
||||
{maxplayers:24, toAline:4, xspacing:32, yspacing:32, liney:80},
|
||||
@@ -112,12 +112,18 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||
if (!shadow) {
|
||||
var skyMat = mat4.scale(mat4.create(), mvMatrix, [1/64, 1/64, 1/64]);
|
||||
sky.setFrame(frame);
|
||||
if (!courseObj.skyboxShadows) nitroRender.setLightIntensities(0, 0);
|
||||
sky.draw(skyMat, pMatrix);
|
||||
if (!courseObj.skyboxShadows) nitroRender.setLightIntensities();
|
||||
}
|
||||
|
||||
var lvlMat = mat4.scale(mat4.create(), mvMatrix, [1/64, 1/64, 1/64]);//[2, 2, 2]);
|
||||
course.setFrame(frame);
|
||||
course.draw(lvlMat, pMatrix);
|
||||
nitroRender.forceFlatNormals = true;
|
||||
nitroRender.setLightIntensities(0);
|
||||
course.draw(lvlMat, pMatrix);
|
||||
nitroRender.setLightIntensities();
|
||||
nitroRender.forceFlatNormals = false;
|
||||
|
||||
var transE = [];
|
||||
|
||||
@@ -139,13 +145,14 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||
else e.draw(mvMatrix, pMatrix, gl);
|
||||
}
|
||||
|
||||
nitroRender.setLightIntensities(0);
|
||||
for (var i=0; i<scn.particles.length; i++) {
|
||||
var e = scn.particles[i];
|
||||
e.draw(mvMatrix, pMatrix, gl);
|
||||
}
|
||||
|
||||
scn.items.draw(mvMatrix, pMatrix, gl);
|
||||
|
||||
nitroRender.setLightIntensities();
|
||||
}
|
||||
|
||||
function sndUpdate(view) {
|
||||
@@ -249,8 +256,11 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||
function startCourse() {
|
||||
scn.lightMat = mat4.create();
|
||||
|
||||
mat4.rotateX(scn.lightMat, scn.lightMat, Math.PI*(61/180));
|
||||
mat4.rotateY(scn.lightMat, scn.lightMat, Math.PI*(21/180));
|
||||
mat4.rotateX(scn.lightMat, scn.lightMat, Math.PI*(courseObj.lightHeight || (61/180)));
|
||||
mat4.rotateY(scn.lightMat, scn.lightMat, Math.PI*(courseObj.lightAngle || (21/180)));
|
||||
scn.lightDir = [0, 0, 1];
|
||||
vec3.transformMat3(scn.lightDir, scn.lightDir, mat3.invert([], mat3.fromMat4([], scn.lightMat)));
|
||||
|
||||
scn.farShadMat = mat4.create();
|
||||
mat4.translate(scn.farShadMat, scn.lightMat, getLightCenter());
|
||||
|
||||
@@ -408,7 +418,7 @@ window.courseScene = function(mainNarc, texNarc, music, chars, options, gameRes)
|
||||
switch (mode.id) {
|
||||
case 0:
|
||||
//race init. fade scene in and play init music.
|
||||
nitroAudio.playSound(11, {volume:2}, null); //7:race (gp), 11:race2 (vs), 12:battle
|
||||
nitroAudio.playSound((courseObj.battle)?12:11, {volume:2}, null); //7:race (gp), 11:race2 (vs), 12:battle
|
||||
break;
|
||||
case 1:
|
||||
//spawn lakitu and countdown animation. allow pre-acceleration.
|
||||
|
||||
@@ -84,7 +84,7 @@ window.sceneDrawer = new function() {
|
||||
gl.colorMask(false, false, false, false);
|
||||
scn.draw(gl, shadMat, true);
|
||||
|
||||
nitroRender.setShadowMode(shadowTarg.depth, scn.farShad.depth, shadMat, scn.farShadMat);
|
||||
nitroRender.setShadowMode(shadowTarg.depth, scn.farShad.depth, shadMat, scn.farShadMat, scn.lightDir);
|
||||
nitroRender.flagShadow = false;
|
||||
|
||||
nitroRender.updateBillboards(view.mv);
|
||||
|
||||
@@ -52,16 +52,16 @@ window.singleScene = function(course, wsInstance, res) {
|
||||
var mainNarc, texNarc
|
||||
if (course.substr(0, 5) == "mkds/") {
|
||||
var cnum = Number(course.substr(5));
|
||||
var music = MKDSCONST.COURSE_MUSIC[cnum];
|
||||
var cDir = MKDSCONST.COURSEDIR+MKDSCONST.COURSES[cnum];
|
||||
var course = MKDSCONST.COURSES[cnum];
|
||||
var cDir = MKDSCONST.COURSEDIR+course.name;
|
||||
var mainNarc = new narc(lz77.decompress(gameROM.getFile(cDir+".carc")));
|
||||
var texNarc = new narc(lz77.decompress(gameROM.getFile(cDir+"Tex.carc")));
|
||||
setUpCourse(mainNarc, texNarc, music)
|
||||
setUpCourse(mainNarc, texNarc, course)
|
||||
} else throw "custom tracks are not implemented yet!"
|
||||
}
|
||||
|
||||
|
||||
function setUpCourse(mainNarc, texNarc, music) {
|
||||
function setUpCourse(mainNarc, texNarc, course) {
|
||||
var chars = [];
|
||||
chars.push({charN:mchar, kartN:mkart, controller:((window.prompt("press y for cpu controlled") == "y")?controlRaceCPU:controlDefault), raceCam:true, extraParams:[{k:"name", v:"single"}, {k:"active", v:true}]});
|
||||
|
||||
@@ -72,7 +72,7 @@ window.singleScene = function(course, wsInstance, res) {
|
||||
chars.push({charN:tchar, kartN:tkart, controller:controlRaceCPU, raceCam:false, extraParams:[{k:"name", v:"no"}, {k:"active", v:true}]});
|
||||
}
|
||||
|
||||
t.activeScene = new courseScene(mainNarc, texNarc, music, chars, {}, res);
|
||||
t.activeScene = new courseScene(mainNarc, texNarc, course, chars, {}, res);
|
||||
|
||||
t.myKart = t.activeScene.karts[0];
|
||||
t.mode = {
|
||||
|
||||
Reference in new issue
Block a user