pouët.net

nXng by Syndrome [web]

					----------------------------------------

				  nX (S3 project) by Emmanuel JULIEN, 1999~2000
							  Code: xBaRr/Syndrome

							'The Syndrome 3D engine'

								xbarr@pingoo.com
							http://xbarr@planet-d.net
						   http://syndrome@planet-d.net
		https://github.com/demoscene-source-archive/preservation-nxng-engine

					----------------------------------------

						First build:
							12/09/1998 (x3)
						Last released version:
							v2.0 - 9.0.0.6 (nXng Twinbee)

					----------------------------------------



						Table of Content:
						-----------------

						1) About,
						2) Rules and Things to know,
						3) Restrictions and loosy stuff,
						4) Major features,
						5) The 'nXs3.ini' file,
						6) Setting up surface shaders,
						7) History,
						8) The Replay engine and MOA,
						9) Last Tips,
						A) Greets.


1) ABOUT:
---------

		nXs3 is a NEWTEK's Lightwave based demo 3D-Engine.
		It barely works like any other 3D-Engine.

		It is pure software 3d-engine. Transformations/clippings/lightning are hand written
		the only calls made to D3D when using hardware rasterizer are SETRENDERSTATE and
		DRAWPRIMITIVE! And yes I feel its lame to use D3D's clipping/lightning/bones or
		whatever (in a demo) sometimes without even knowing how it is done! ):

		Demos that use nX:
		------------------
			- Dash (Condense) uses x3 [http:\\condense.planet-d.net],
			- LTP3 Intro-Invitation (Syndrome) uses X32 [http:\\syndrome.planet-d.net],
			- FreeStyle (Condense & Syndrome) uses nX [http:\\syndrome.planet-d.net],
			- and more to come (: ...


		Requirements:
		-------------

				- Pentium class processor (MMX is NOT a plus),
				- DirectX 7.0 with at least a DirectX compatible graphic card,


2) RULES AND THINGS TO KNOW:
----------------------------

	- WINDOWS IS CRAP,

	- gAudio MP3 Library is available for FREE non-commercial use here:
							http://www.idf.net/gods

	- A scene�!MUST NOT! have any of its objects first appearing with this motion step:
		Position X, Y & Z: -9999999999,123456 m
		Angle H, P & B: -9999999999,123456 �
		Scale X, Y & Z: -9999999999,123456 *
		If you fail to respect this rule then nX behavior is not predictable!
		(even if there is only one chance on infinity you make this�! (8)

	- !!! There are reserved keywords in surface's name�!!!:
		See the SETTING UP THE SURFACE SHADERS section for a complete list.

	- TEXTURE REPEAT is VERY IMPORTANT!
		nX will surely crash if you intend to wrap a texture without setting the appropriate
		Surface's flag�!!! BEWARE ALSO specifying texture wrap when unused is a MEMORY HOLE�!!!
		In order to wrap texture with software renderer nX must stretch EACH wrapping textures
		to 256x256�! (You might sometimes want to use this option to increase linear mapper
		precision but I really do not recommand doing random wrapping settings!)
		NOTE�: This does not apply when rendering via Direct3D.

	- Troughout this document MOA will be refered to as motion overdrawing,

	- If you find some problems with truemap textured D3D surfaces or flashing/jerky lightning
	  try another scene size!

	- There is NO clipping bugs. Disappearing polygons are because of MOA being calculated every
	  8 frames, if you want no replay bug then update MOA in 1x mode <but have a good night then (;>,

	- MOA SHOULD BE updated whenever the scene changes BUT sometimes nX
	  won't detect scenes changes and this may result in HEAVY PLAYBACK BUGS!
	  In this case just check the 'update MOA' option.

	- Last but not least�: try to catch an AMIGA and get a life.



3) RESTRICTIONS AND LOOSY STUFF:
--------------------------------

	- Supported texture formats are in prefered order TARGA, JPEG, BMP and IFF.
	  TARGA, BMP and IFF code are originals. JPEG is based on IJG distribution.

	- When using precalculated motion the number of face in scene must not exceed 65535,
	
	_ Texture width is limited to 256x256 pixels in ALL rendering type IF wrapping otherwise
	  specify [WM] in surface name to activate wide map support for surface (upto 65535x65535).
	  WARNING!: Wide texture repeat WILL crash!
	  But any size lower than 256x256 is allowed (even non-2^x size) with wrapping,
	  Direct3D has hardware texture size limitation (accelerator dependent).
		Note: A 1024x1024 texture fill upto 4mo! think about it and don't even think about CPU-caching datas (;
			  If a rendering type does not have WIDE support you'll get a warning at load time.

	- Because of the way nX calculate UV mapping coordinate, the LIGHTWAVE's texture velocity behavior cannot
	  be reproduced. Only x and y component are took in account and added to u and v texture components.
		i.e: if you specify an x velocity of 1.0 then the texture seen from front will scroll left
			 because its U (x in texture space) will be increased each frame.
	  Mmmh... the best i think is to try and see {-; ...



4) MAJOR FEATURES:
------------------


	Engine:

		- Internal RGB888 routines,
		- Full Float32 FPU 3D calculations,
		- Light color support for all types,
		- Fully independent texture levels (center, size & velocity),
		- Scalable and morphable particle objects,
		- Dynamic shading based upon all lights in scene,
		- Fully parametrable lightning models on a per-surface basis,
		  (specified by keyword 'LGT_x[+x][+...]' in surface name -G3E compatible-)
		  NOTE�: specifying LGT is only needed when restricting surface lightning to specific lights,
		- Diffuse and Specular percentage variable,
		- Specular and Glossiness pow support for all shaded rendering methods,
		- Extra texture effects for all rendering type,
		- Lightning speed load engine (even faster than Lightwave!),
		- Works both windowed/fullscreen either soft or d3d.

	Lightwave functions compatibility level:

		- 'Planar image map', 'Cubic image map', 'Cylindrical image map' support,
		- LIGHTWAVE's 'MetaMorph' support (vertices + normals),
		- MORPH-GIZMO (extension to metamorph for multiple targets),
		- Alpha transparency (256 levels for both software & hardware),
		- Object dissolve fully supported (correctly affect transparency),
		- Transparency texture level support,
		- LIGHTWAVE's 'MaxSmoothingAngle' support,
		- Camera focal envellop,
		- Support for unlimited lights: (with all envellop supported including cone angle&edge angle ones)
			Ambient light intensity,
			Distant Light,
			Point Light,
			Spot light,
			Lens flare support.
		- Null object,
		- Inverse Kinematik (but not ala Lightwave so it is quite unusable for now),
		- Parent objects,
		- Target object,
		- Scale and pivot point,
		- Support motion/envelop End Behavior (Reset is interpreted as Stop),

	Extra functions:

		- Fully configurable spark emiters,

	Software rasterizer:

		- Polygonal rasterizer/clippers (up to 333 edges),
		- Sub-pixel/Sub-texel accurate polydrawer with FLOAT32 precision,
		- GENERIC SOFTWARE RASTERIZER
		  Software has support for ALL render types!
		  Just try MAPPING + EVMAP + BUMP + ALPHA TEXTURE + ADDITIVE + GOURAUD it WORKS! (((:
		  plus 30 custom optimized cases (most common ones).
		- Software colored linear fog,
		- Software selective Z-Buffer (32 bits), must specify '[ZBUFFER]' in surface name to activate,
		- Texture Width & Height wrapping (UV Wrap),

	D3D rasterizer:

		- Uses the texture management feature of D3D (DirectX 6+),
		- ZBuffer automatically select largest Zbuffer type available,
		- CAPS based rendering taking advantage of multipass/multitexture capable accelerators,



5) THE 'nXs3.ini' FILE:
-----------------------

	In case you don't have it, simply cut and paste the following block in a file named
	'nXs3.ini' in program directory:

	[--------------- CUT FROM HERE ---------------]

	INI file for nXs3 (Syndrome 3D Engine)
	--------------------------------------

	' Set the path of your lightwave BASE directory (i.e: the directory
	' containing your programs|plugins|images|scenes|objects folders NOT
	' the directory containing the .exe (unless you moved them from their
	' original folders), In most case this is 'c:\newtek\'

	[NEWTEK]
	c:\newtek\

	[-------------- END OF INI FILE --------------]


6) SETTING UP THE SURFACE SHADERS:
----------------------------------


		// SELECTING A SHADING MODE
		///////////////////////////


		Default nX behavior is to not shade any polygons. Therefore if you want your
	surface to be flat shaded then you must activate 'SHARP TERMINATOR' in surface panel.
	Gouraud shading is enabled via the 'SMOOTHING' button in surface panel.
		--> SMOOTHING and FLAT SHADING are mutually exclusive! Preference is given to Flat.


		// ADDING TEXTURES TO THE SURFACE
		/////////////////////////////////


		All supported textures are activated using the 'T' button for the corresponding
	attribute. So, to add a color texture map one would add it via the 'T' button to the
	right of the 'Surface Color' field in surface panel.
		The same apply to other supported levels.

		Supported texture levels:
		-------------------------

			- Surface Color (MAPPING),

			- Reflectivity (EVMAP),
				This add an envirronment mapping texture to the surface.
				One most correct way to specify a reflectivity map is to set
				the reflection percentage to a non 0 value and specifying the
				texture in reflection image panel. Both way are supported.

			- Transparency (ALPHATEX),

			- Bump (BUMP)
				WARNING: You must have an evmap defined for bump mapping!

		All textures levels are fully UV independent. This mean you can use any mode of
	mapping for each level, for example MAPPING via 'Planar Image Map' + EVMAP.
	Since v1.7, some Fractal Noise and Crumple procedural textures are supported.


		// EXTENDED SURFACE RENDERSTATES
		////////////////////////////////

		In order to have a more complete control on the rendering of surfaces nX uses
	Surface name keywords. This mean that when you type (anywhere) in a surface name
	one of the following keywords you'll turn on its corresponding behavior:
		(You can, of course, combinate them ...)

		Here is a list of nX keywords:

			[BUMP]
				-> old but still supported method to specify bump mapping,
			[ZBUFFER]
				-> specify that surface is to be Zbuffered,
			[WM]
				-> toggle wide map on,
			[ADDEVMAP]
				-> changes the way nX combine color and reflection maps from
				   multiply to additive when using multi-texturing.
				   HINT: try it if you find your COLORMAP+EVMAP too dark...

		The following are not legacy nX keywords but were introduced to be
		compatible with Odin/Gods's G3E:

			LGT_x[+y][+...]
				-> restrict lightning computations to lights n�x,y,...,
			CHROMA
				-> specify chroma keying (black channel) for surface
				  (you should use alpha maps instead)


		Note: Of course, make sure you did not use one of these keywords if one
			  of your surfaces is not behaving the way you were expecting.

		// USING ALPHA AND TRANSPARENCIES
		/////////////////////////////////


		You can add some alpha shading or transparency to your surface in many different
	ways. nX support ALPHATEX, additive shading and surface's transparency percentage to
	perform alpha shading.
		You can indirectly alpha shade your surface using the 'Object Dissolve'.

		Note: ALPHATEX and transparency coef are mutually exclusive in piXel!
			  Preference goes to ALPHATEX.


		// piXel! PERFORMANCE CONSIDERATIONS
		////////////////////////////////////

		nX's piXel! can handle all combinations of the rendertypes above.
	However to do this each polygon must get trought a generic rasterizer wich is
	pretty slow. That's why for the most common (and far less common) shading types
	nX includes assembly optimised scanline routines.
		You should always try to use OPTIMIZED calls whenever possible!
		Here is the list of OPTIMIZED calls:

				FLAT (alpha)
				FLAT + LIGHTSOURCE (alpha)
				GOURAUD (alpha)
				MAPPING (alpha/wide)
				MAPPING + LIGTHSOURCE
				EVMAP (alpha/wide)
				MAPPING PERSPECTIVE (wide)
				MAPPING PERSPECTIVE + GOURAUD
				MAPPING PERSPECTIVE + ADDITIVE

				MAPPING + GOURAUD
				EVMAP + GOURAUD
				EVMAP + BUMP

				ALPHATEX (wide)
				ALPHATEX + LIGHTSOURCE (wide)
				ALPHATEX + MAPPING
				ALPHATEX + EVMAP

				ADDITIVE + FLAT
				MAPPING + ADDITIVE (alpha/wide)
				EVMAP + ADDITIVE (alpha/wide)

				Total: 32 custom rasterizers

		Note: Optimized calls are automatically took in most case.
	For example if you have MAPPING + BUMP in a scene and you want to dissolve it then
	nX will use the optimized call as long as there is no alpha shading. But when the
	alpha get used optimized call will fail and default to generic rasterizer.

		Since there is many individually optimized calls and that generic rasterizer is
	not AWFULLY slow. You might not have to worry about optimizing your scenes. But
	of course hardware is faster (;

		Do not forget to watch perspective correct renders! nX optimized calls only have
	support for MAPPING + PERSPECTIVE! So, DO NOT PERSPECTIVE EVERY SURFACES!

		Note: Generic rasterizer cannot WIDEMAP.


7) HISTORY:
-----------

[v2.0 - 9.0.0.6]

    All memory leaks where tracked down and killed! [:
    Added Sequence support (animated texture map). Two restrictions however! There must be 4 digits in the sequence filenames and the first clip must be numbered 0001! FPS is fixed to 20.
    Better automatic sizing,
    Better Surface decoder requiring less memory while allowing upto 4096 surfaces per entity (:,
    Corrected lotsa small bugs with GUI, implemented LOADER class system,
    Removed an ugly bug in the new BoundingBox system that was a potential cause to total crash with many many scenes,
    TAB toggles stats mode, F1 force use of Single-Texture rasterizer, F2 toggles free camera mode.

[v2.0 - 9.0.0.5]

    GUI is now using automatic scene sizing... This might cause problems with 16bit Zbuffer,
    Added alternate rasterizer for 3d cards that do not support multitexturing,
    Removed brute force resolving in Lightmap computing. Calculations now uses a wrecked BSP giving speed improvement ranging from 2x to 10x over brute force method,
    Lightmaps are now optimized and stored at minimal A.R. possible,
    Removed edge sharing artifacts in Lightmaps.

[v2.0 - 9.0.0.3]

    This is a WORK-IN-PROGRESS release,
    Radiosity version handles shadows correctly! Even alpha textures are ok... Kweeel... [: But this is incredibly fucking slow as hell that sucks!!! (got it? (:)
    Animated Light/Shadow maps,
    nX can now compute Shadow-only maps. Much lighter they can be pretty bigger and make still available realtime lightning engine.

[v2.0 - 9.0.0.1]

    Major cleanup in code, classes only now...
    Enhanced interface with a console output like Quake [;
    RAYTRACED Lightmaps, supporting Alpha-Texture, Transparency to cast shadows and phong shaded lightmaps. Radiosity version is also working but not available since it do not handle shadows properly ))): and alpha textures definitively are a big problem when using radiosity. Lightmaps are perfectly UV-Mapped! (:

-=- CHANGES FROM nXs3 TO nXng -=-

v1.7c:
    - Added the EXTENDED SURFACE RENDERSTATES section to this doc,
    - [ADDEVMAP] surface keyword added to allow COLORMAP + EVMAP to
        be blended using ADDITIVE instead of the default MULTIPLY,
    - Fixed an odd bug in envelops, should fix a lot of weird bugs (;
    - Missing objects no more crash the engine,
    - Missing filename is always given in error messages [:,
    - Relooked the GUI..
	
	
8) THE REPLAY ENGINE AND MOA:
-----------------------------

		The precalculation works by previewing faces visibility for the whole motion (so you must recompute
	the full precalculation as soon as you change any scene' entity motion). As the precalculation allows a
	GREAT speed improvement an option allows user to select precalculation precision so that you can use
	it at any time you try a scene. OF COURSE, the less precision you set the more glitches you'll get during
	playback! As a rule you should only use x8 motion analysis for previewing scenes and final compilation
	should be done with HI precaprec. Preca precision bugs often appears as missing polygons ...

		ONE VERY IMPORTANT THING TO REMEMBER IF YOU WISH TO GET MAXIMUM PROFIT FROM PRECALCULATION!:
		Always split your worlds/scenes in different objects. No matter if instead of one big static world
	you get 32 moving parent objects (or whatever more complex things you wish) the replay using preca will
	ALWAYS be FAR faster (except if you always see all objects at once (: ) bcoz the precalculation permits
	X32 to skip non-visible objects without even doing 1 mul for the object! {-8*



9) LAST TIPS:
-------------

		RULE 1:
		[-----]

		Let's say you are in a tunnel (hum... what an improvement!) and you ride across thousands of doors
	that opens just when you get close to them. PLEASE do not use thousands doors object! But instead use
	3 or 4 doors objects and move back a door object in front of you as soon as it went beside you (got it?!).
		Here is an example seen from the tunnel's side. v is the viewer da, db, dc are 3 doors objects:

		Frame x:
		[------]
				da			db			dc
			v	|			|			|
			--> |			|			|
				|			|			|

			v comes in front of da. da opens.

		Frame x+n:
		[--------]
							db			dc
					v		|			|
					-->		|			|
							|			|

			da is discarded from v's view. v comes in front of db.

		Frame x+2n:
		[---------]
										dc			da
								v		|			|
				 				-->		|			|
										|			|

			As db opens. You put back da to the next door's position behind dc. Et ainsi de suite...
	Of course... this technique is only useful when dealing with repeating objects. If you want to make
	a different door anytime then you'll have to make thousands objects... and it will be slow...
		This can also apply to any other object in a scene. 
		ALWAYS RE-USE AN OBJECT INSTEAD OF LOADING ANOTHER OBJECT' INSTANCE WHEN YOU CAN!



A) FOLLOWING GUYS DESERVE GLEEETINGZ:
-------------------------------------

	- Odin/gOds: We've done a very long way coding together and that was GREAT! Good old AMIGA
			times... when talking of realtime lightnings and true mirrors sounded like utopia (:
	- Liszt/gOds: I always liked your techno-style and I now like your work as a 3D-Artist! Good luck
				  for IMAGINA2000!
	- Chris/gOds: We never really met again since Fraction but in that time you gave me some
				  real motivations to go on with demoscene! Thanks! (:
	- Kinan: Yep! We'll do it one day! (: Until this moment we have to keep learning EVERYTHING! {8
	- Traven: A new friend but a good one I think (I hope! I'm sure (; ) and vERy talented! Stop IRCing
			  make music instead! (; (we all now he's making music all day. IRC is just to take a break)
	- NoRecess: You're in! See you tomorrow.
	- Gozer: Wooby! How's your hairy monster doing?
	- Jibe: "Ptain' y fait le mac avec sa camera Lightwave genre j'my connais et tout j'vais tout gerer
			 pour toi!" (;
	- Yes/OJ: Thanks for giving us (Traven and I) the oportunity to do LTP's stuff! You're great!
	- Nitryk: Mhhhh... presque assez glauque (:
	- Pingoo: A ouais merde! Les graphs pour hier... �:
	- Mad�: Panda va! d: Carl�tosaure! hmrff (:
	- U2: Allez! Un ptit coup d'D3D7? (:
	- G-Hell: Too... too... tooooo...
	- AlexKidd: Merci pour le CD! (; A un de ces 64 sur IRC!
	- And the many other cool people on the scene that I knew or I know but the list is far too long
	  to be written here ): i'll add greets with time (:



					Emmanuel JULIEN,
					(alias xBaRr/Syndrome) 1998~99.
							Merde, le temps �a passe...


												Any comment should go to:
													xbarr@pingoo.com