1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     Gas.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46365 $
14  *---------------------------------------------------------------------------*/
15 
16 /*
17  *------------------------------------------------------------
18  * Copyright(c) 2009-2010 by Digital Media Professionals Inc.
19  * All rights reserved.
20  *------------------------------------------------------------
21  * This source code is the confidential and proprietary
22  * of Digital Media Professionals Inc.
23  *------------------------------------------------------------
24  */
25 #ifndef DMP_GAS_H__
26 #define DMP_GAS_H__
27 
28 #include <nn/gx.h>
29 
30 /*
31  * Definitions
32  */
33 
34 #define APP_NAME            "GasColorOptimal"
35 
36 /* Buffer size */
37 #define DISPLAY_WIDTH       (nn::gx::DISPLAY0_WIDTH)
38 #define DISPLAY_HEIGHT      (nn::gx::DISPLAY0_HEIGHT)
39 
40 /* accumulation buffer can be smaller size than DISPLAY but should be powered by 2. */
41 #define GAS_ACC_WIDTH       (128)
42 #define GAS_ACC_HEIGHT      (128)
43 /* texture should be same size as accumulation buffer */
44 #define GAS_TEX_WIDTH       (GAS_ACC_WIDTH)
45 #define GAS_TEX_HEIGHT      (GAS_ACC_HEIGHT)
46 
47 /* Default buffer ID */
48 #define DISPLAY_BUFFER      (0)     /* default frame buffer */
49 
50 /* Particle pattern */
51 #define PARTICLE_PATTERNS   (1)
52 #define PARTICLE_FILES       "rom:/resources/ptcl0.tga"
53 
54 
55 struct gas_data {
56     //Gas geometry definition (accumulation pass)
57     GLuint          gasgeo_tri_ID;              /* used in accumulation pass. Vertex Index buffer ID */
58     GLuint          gasgeo_center_ID;           /* used in accumulation pass. Vertex position buffer ID */
59     GLuint          gasgeo_tx0_ID;              /* used in accumulation pass. Vertex Texture coordinates buffer ID */
60     GLuint          gasgeo_density_ID;          /* used in accumulation pass. Vertex color buffer ID */
61     GLuint          pattern[PARTICLE_PATTERNS]; /* Texture ID applied to each particle */
62     GLsizei         gasgeo_size;                /* Number of elements (triangles) defining the gaseous object*/
63     GLfloat         _dela_z;                    /* used in accumulation pass, to control final alpha blending*/
64 
65     GLint           _autoAcc;                   /* used in post synthesis pass */
66     float           _densMax;                   /* used in post synthesis pass. Shading control*/
67     GLfloat         _lightDirX;                 /* used in post synthesis pass. Shading control */
68     GLfloat         _lightDirY;                 /* used in post synthesis pass. Shading control */
69     GLfloat         _LightXY[4];                /* used in post synthesis pass. Shading control */
70     GLfloat         _LightZ[4];                 /* used in post synthesis pass. Shading control */
71     GLuint          FogLut_ID;                  /* used in post synthesis pass. Look up table ID */
72     GLuint          CollectionLUT_ID;           /* used in post synthesis pass. Texture collection ID */
73     GLuint          gasTransfert_ID[3];         /* used in post synthesis pass. Lookup table ID for gas color look up table */
74     float           RR[16],GG[16],BB[16];       /* used in post synthesis pass. Lookup table for gas color content */
75     float           fogTable[256];              /* used in post synthesis pass. Fog look up table for density to alpha conversion*/
76     GLenum          shadingDensitySrc;          /* used in post synthesis pass. Density selection for shading input*/
77     GLenum          colorLutInput;              /* used in post synthesis pass. Input selection for the gas color look up*/
78     //Gas geometry definition / simple quad (post synthesis pass)
79     GLuint          quad_index_ID;              /* used in post synthesis pass. Vertex Index buffer ID */
80     GLuint          quad_vertBuf_ID;            /* used in post synthesis pass. Vertex position buffer ID */
81     GLuint          quad_texBuf_ID;             /* used in post synthesis pass. Vertex Texture coordinates buffer ID */
82     GLuint          quad_colBuf_ID;             /* used in post synthesis pass. Vertex color buffer ID */
83 
84 };
85 
86 /*
87  * Function declarations
88  */
89 
90 /* buffer initialization */
91 void GasInitialize(void);
92 
93 /* gaseous object data structure default initialization */
94 void DefaultGasObject(struct gas_data *gas,float *gasColorTable);
95 
96 /* accumulation pass */
97 void GasAccumulation();
98 
99 /* shading pass */
100 void GasShading(void);
101 
102 /* render accumulation Z buffer */
103 void GasRenderAccumulationZBuffer(void (*drawfunc)(void));
104 
105 /* Blend shading result to color buffer */
106 void GasBlendShadingResult(void);
107 
108 #endif /* DMP_GAS_H__ */
109