User Tools

Site Tools


nintendo_64:fog

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
nintendo_64:fog [2018/07/01 21:49]
David created
nintendo_64:fog [2019/05/29 20:49] (current)
David Updated dead link
Line 3: Line 3:
 {{ https://​i.imgur.com/​Hh1JQVH.png?​280}} {{ https://​i.imgur.com/​Hh1JQVH.png?​280}}
  
-Fog alters ​the color of polygons ​based on their distance from the cameraAs objects and geometry get farther away from the camera, they start to blend into the background color. This is an easy and useful method ​to reduce ​the strain on the N64's RCP, and can improve performance.+**Vertex ​Fog** is a setting in the RSP that can be used to fade polygons ​into the backgroundIt works by gradually blending ​the fog color (or transparency) ​into the geometry until it looks like it completely faded away. This effect can be used along with lowering the draw distance ​to reduce ​lag.
  
-If your level still has lag even with fog enabled, ​try cutting down the amount ​of polygons and active objects on screen.+Do note that you cannot use vertex alpha when fog is enabled. This is because when the SHADE alpha value is used in the color combinerit will get the fog alpha instead ​of the vertex alpha.
  
 ---- ----
Line 85: Line 85:
 ===== Setting Fog Color ===== ===== Setting Fog Color =====
  
-The fog color is a simple RGBA value that you define in the display list: +The fog color is a simple RGBA value that you define in the display list. Generally, this should be the same color as the background. If the background is complicated (clouds, mountains, gradients, etc), [[http://​ultra64.ca/​files/​documentation/​online-manuals/​man/​pro-man/​pro11/​index11.8.html|then you should try making the objects fade by transparency rather than by color]].
  
   Fast3D / Fast3DEX / Fast3DEX2 / Fast3DZEX ​   Fast3D / Fast3DEX / Fast3DEX2 / Fast3DZEX ​
Line 95: Line 95:
 ---- ----
  
-===== Vertex Alpha & Fog ===== +===== Disabling ​Fog =====
-> From the N64 Function Reference Manual for **gDPSetFogColor**:​ +
-> N64 processes fog by Gouraud-shading the fog attenuation coefficients in the alpha channel of RDP. At that time, the BL adjusts the attenuation of the pipeline pixel colors to the surrounding fog color. Because the alpha channel of RDP is being used for Gouraud-shading the fog attenuation coefficient,​ normal alpha values cannot be Gouraud-shaded. **In other words, you cannot change the transparency inside a single triangle when you are using fog.**+
  
-What this says is that you cannot use vertex alpha transparency while fog is enabled. Fog is independent of lighting and texturesso you can still use the alpha transparency from those sources.+To disable ​fog, you simply have to do the reverse of what you did to enable it. This can vary based on what the default settings are in each gameFor custom Super Mario 64 levels, we do the following:
  
-----+1.) Set the RDP back into 1 cycle mode.
  
-===== Background Images & Fog =====+  Fast3D / Fast3DEX 
 +  BA 00 14 02 00 00 00 00
  
-Because of how fog works, using a background that is not a solid color will make the fog look weird. It is best to use a solid color that matches the fog color.+  Fast3DEX2 / Fast3DZEX  
 +  E3 00 14 02 00 00 00 00
  
-If you are making or modifying a level in Super Mario 64, then you can change ​the background ​to a solid color by modifying the [[super_mario_64:geometry_layout_commands#​set_background|0x19 command ​in the level'​s ​geometry ​layout]]+  C/C++ 
 +  gsDPSetCycleType(G_CYC_1CYCLE) 
 +   
 + 
 +2.) Next we set the render mode back to normal. (seehttp://​n64devkit.square7.ch/​n64man/​gdp/​gDPSetRenderMode.htm) 
 + 
 +  Fast3D / Fast3DEX 
 +  B9 00 03 1D 00 44 30 78 
 + 
 +  Fast3DEX2 / Fast3DZEX  
 +  E2 00 03 1D 00 44 30 78 
 + 
 +  C/C++ 
 +  gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF,​ G_RM_NOOP2) // If surface is fully opaque 
 +  gsDPSetRenderMode(G_RM_AA_ZB_XLU_SURF,​ G_RM_NOOP2) // If surface has transparency 
 + 
 +3.) Finally we clear the fog flag in the geometry ​mode. 
 +  Fast3D / Fast3DEX 
 +  B6 00 00 00 00 01 00 00 
 + 
 +  Fast3DEX2 / Fast3DZEX  
 +  D9 01 00 00 00 00 00 00 
 + 
 +  C/C++ 
 +  gsSPClearGeometryMode(G_FOG)
  
 ---- ----
  
 ===== References ===== ===== References =====
-  * https://level42.ca/projects/ultra64/Documentation/​man/​pro-man/​pro11/​index11.8.html+  * http://ultra64.ca/files/documentation/online-manuals/​man/​pro-man/​pro11/​index11.8.html
   * http://​ultra64.ca/​files/​documentation/​online-manuals/​man/​n64man/​gdp/​gDPSetFogColor.html   * http://​ultra64.ca/​files/​documentation/​online-manuals/​man/​n64man/​gdp/​gDPSetFogColor.html
   * http://​n64devkit.square7.ch/​n64man/​gdp/​gDPSetRenderMode.htm   * http://​n64devkit.square7.ch/​n64man/​gdp/​gDPSetRenderMode.htm
nintendo_64/fog.1530481794.txt.gz · Last modified: 2018/07/01 21:49 by David