// Doom of Lights 1.2, October 2003 // Fixed: A stupid bug with shadow map size (noted by eetu martola). // // Doom of Lights 1.1, August 2003 // Fiex: Now you don't need to have Auto Key turned on. // // DoL creates an array of lights to fake radiosity and soft shadows. // Select a NULL or any object in the middle of your scene, the lights will aim this object. // // Felipe Esquivel // // TODO: Implement correctly the Hammersley sphere. // Add a spline color to have a gradient between the zenith and the horizon. @version 2.1 @warnings @script generic curScene; generic { type = 1; lightCol = <255,255,255>; shadowTipo = 1; mapSize = 512; radius = 6.0; cache = false; lightNumber = 60; totalIntensity = 2; lightName = "dome"; shadowFuzz = 1.0; reqbegin("Doom of Lights 1.2"); reqsize(500,218); c1 = ctlstring("Light Name", lightName); ctlposition(c1,31,31,177,18); c2 = ctlinteger("Shadow Map Size", mapSize); ctlposition(c2,333,117,132,18); c3 = ctlcheckbox("Cache Shadow Map",cache); ctlposition(c3,349,93,118,15); c4 = ctlchoice("Shadow Type",shadowTipo,@"Trace","Map","Off"@); ctlposition(c4,261,66,206,22); c5 = ctlchoice("Light Type",type,@"Spot","Distant","Point","Area"@); ctlposition(c5,229,31,238,23); c6 = ctlnumber("Shadow Fuzziness",shadowFuzz); ctlposition(c6,331,148,134,18); c7 = ctldistance("Dome Radius",radius); ctlposition(c7,94,59,114,18); c8 = ctlinteger("Number of Lights",lightNumber); ctlposition(c8,78,88,130,18); c9 = ctlpercent("Total Intensity",totalIntensity); ctlposition(c9,92,117,116,18); c10 = ctlcolor("Color",lightCol); ctlposition(c10,51,147,157,18); c11 = ctltext("","Constructs a dome with lights to fake radiosity Felipe Esquivel "); ctlposition(c11,20,2,450,13); return if !reqpost(); lightName = getvalue(c1); type = getvalue(c5); shadowTipo = getvalue(c4); mapSize = getvalue(c2); cache = getvalue(c3); shadowFuzz = getvalue(c6); radius = getvalue(c7); lightNumber = getvalue(c8); totalIntensity = getvalue(c9); lightCol = getvalue(c10); reqend(); var parNull, parId, i; var x, y, z; //AddNull(string(prefix,"_Null")); curScene = Scene(); (parNull) = curScene.getSelect(); //antes que nada hay que ir al primer frame de la escena for(i=1; i<=lightNumber; i+= 1) { if(type==1){ AddSpotlight(lightName + "_" + i); // 1=trace, 2=map, -1=off if(shadowTipo==1) ShadowType(1); else if(shadowTipo==2){ ShadowType(2); ShadowMapSize(mapSize); ShadowMapFuzziness(shadowFuzz); if(cache) CacheShadowMap(); } else if(shadowTipo==3) ShadowType(-1); } else if(type==2) AddDistantLight(lightName + "_" + i); else if(type==3) AddPointLight(lightName + "_" + i); else if(type==4) AddAreaLight(lightName + "_" + i); else AddLinearLight(lightName + "_" + i); parId = parNull.id; TargetItem(parId); //ParentItem(parId); HController(2); PController(2); // pone las luces en una esfera al azar sin ningun tipo de distribucion theta = random(0, 6.2832); // 0 - 360 degrees eta = random(0, 3.1416); // 0 - 180 degrees x = radius * sin(theta)* cos(eta); y = radius * sin(theta)* sin(eta); z = radius * cos(theta); if (y < 0) y = -y; // hacemos media esfera solamente // distribucion de cilindro al azar /* theta = random(0, 3.1416 * 2); eta = random(0, 3.1416/2); x = radius * sin(theta); y = radius * sin(eta); z = radius * cos(theta); if (y < 0) y = -y; // hacemos media esfera solamente */ /* // Hammersley sphere // for(kk = i; kk; p*=0.5; kk = kk * 2){ t = 0; p = 0; for(kk = i; kk != 0; kk = kk * 2){ kk = kk % 2; if (kk == 1) t += p; p *= 0.5; } t = 2 * t - 1; phi = (i + 0.5) / lightNumber; phirad = phi * 2 * 3.1416; st = sqrt(1 - t * t); x = radius * st * cos(phirad); y = radius * st * sin(phirad); z = radius * t; */ Position(x, y, z); CreateKey(0); // create a key at frame 0 to anchor the light //LightColor(1, 1, 1); LightColor(lightCol.r/65025.0, lightCol.g/65025.0, lightCol.b/255.0); LightIntensity(totalIntensity/lightNumber); } }