1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
|
/**
** sipp - SImple Polygon Processor
**
** A general 3d graphic package
**
** Copyright Equivalent Software HB 1992
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 1, or any later version.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You can receive a copy of the GNU General Public License from the
** Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/**
** shaders.h - This include file defines the different shaders availiable
** in sipp. Each shader is defined by a structure containing
** the necessary parameters to describe how a surface should
** be shaded with that particular shader, and the extern
** declaration of the shader function itself.
**/
#ifndef _SHADERS_H
#define _SHADERS_H
#include <sipp.h>
/*
* Surface description used in phong_shader().
*/
typedef struct {
double ambient; /* Fraction of color visible in ambient light */
double diffuse; /* Diffuse reflexion factor */
double specular; /* Specular reflexion factor */
int spec_exp; /* Exponent in the specular calculation */
Color color; /* Color of the surface */
Color opacity; /* Opacity of the surface */
} Phong_desc;
/*
* Surface description used in strauss_shader().
*/
typedef struct {
double ambient; /* Fraction of color visible in ambient light */
double smoothness; /* Smoothness of the surface [0, 1] */
double metalness; /* Metalness of the surface [0, 1] */
Color color; /* Base color of the surface */
Color opacity; /* Opacity of the surface */
} Strauss_desc;
/*
* Surface description for the bozo shader.
*/
typedef struct {
Color *colors;
int no_of_cols;
double ambient;
double specular;
double c3;
double scale; /* Scale the texture by this value */
Color opacity; /* Opacity of the surface */
} Bozo_desc;
/*
* Surface description used by the wood shader. This shader
* creates a solid texture (using noise & turbulence) that
* simulates wood.
*/
typedef struct {
double ambient;
double specular;
double c3;
double scale; /* Scale the wood texture by this value */
Color base; /* "Base" color of the surface */
Color ring; /* Color of the darker rings */
Color opacity; /* Opacity of the surface */
} Wood_desc;
/*
* Surface description used by the marble shader. marble_shader
* creates a solid texture (using noise & turbulence) that
* simulates marble.
*/
typedef struct {
double ambient;
double specular;
double c3;
double scale; /* Scale the marble texture by this value */
Color base; /* "Base" color of the surface */
Color strip; /* Color of the "stripes" in the marble */
Color opacity; /* Opacity of the surface */
} Marble_desc;
/*
* Surface description used by the granite shader. granite_shader
* creates a solid texture (using noise) that mixes two colors
* to simulate granite.
*/
typedef struct {
double ambient;
double specular;
double c3;
double scale; /* Scale the texture by this value */
Color col1; /* The two color components */
Color col2;
Color opacity; /* Opacity of the surface */
} Granite_desc;
/*
* Mask shader. It uses mask image (ususally a bitmap) to
* choose between two other shaders. When a
* surface is shaded it calls masker() to check the
* u, v coordinate in the mask and calls one of two other
* shaders depending of the outcome of that test.
*/
typedef struct {
Shader *t_shader; /* Shader to call if mask(x, y) != 0 */
void *t_surface; /* Surface description for fg_shader */
Shader *f_shader; /* Shader to call if mask(x, y) == 0 */
void *f_surface; /* Surface description for bg_shader */
void *mask_data; /* Pointer to data for masking function */
bool (*masker)(); /* Function that tests a pixel value */
} Mask_desc;
/*
* Surface description for the bumpy_shader(). This shader
* fiddles with the surface normals of a surface so the surface
* looks bumpy.
*/
typedef struct {
Shader *shader;
void *surface;
double scale;
bool bumpflag;
bool holeflag;
} Bumpy_desc;
/*
* Declarations of the actual shading functions.
*/
extern void
phong_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Phong_desc *pd,
Color *color,
Color *opacity));
extern void
strauss_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Strauss_desc *sd,
Color *color,
Color *opacity));
extern void
marble_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Marble_desc *md,
Color *color,
Color *opacity));
extern void
granite_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Granite_desc *gd,
Color *color,
Color *opacity));
extern void
bozo_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Bozo_desc *bd,
Color *color,
Color *opacity));
extern void
mask_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Mask_desc *md,
Color *color,
Color *opacity));
extern void
bumpy_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Bumpy_desc *bd,
Color *color,
Color *opacity));
extern void
planet_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Surf_desc *sd,
Color *color,
Color *opacity));
extern void
wood_shader _ANSI_ARGS_((Vector *pos,
Vector *normal,
Vector *texture,
Vector *view_vec,
Lightsource *lights,
Wood_desc *wd,
Color *color,
Color *opacity));
#endif /* _SHADERS_H */
|