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
@@ -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