.. | .. |
---|
12400 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12401 | |
---|
12402 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
12403 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
12404 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12515 | 12560 | "TEMP shininess;" + |
---|
12516 | 12561 | "\n" + |
---|
12517 | 12562 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12563 | + |
---|
12520 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12566 | /* |
---|
.. | .. |
---|
12921 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 12966 | "") + |
---|
12923 | 12967 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
12925 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 12970 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | 12971 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13353 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13402 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13357 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13358 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13359 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13360 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13411 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13414 | } |
---|
13371 | 13415 | |
---|
13372 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13458 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13459 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13460 | + // No shadow when out of frustum |
---|
13417 | 13461 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13463 | ""; |
---|