BRL-CAD
sh_camo.c File Reference
#include "common.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "bu/units.h"
#include "vmath.h"
#include "raytrace.h"
#include "optical.h"
Include dependency graph for sh_camo.c:

Go to the source code of this file.

Data Structures

struct  camo_specific
 

Macros

#define SMOOTHSTEP(x)   ((x)*(x)*(3 - 2*(x)))
 
#define camo_MAGIC   0x18364 /* XXX change this number for each shader */
 
#define CK_camo_SP(_p)   BU_CKMAG(_p, camo_MAGIC, "camo_specific")
 
#define SHDR_NULL   ((struct camo_specific *)0)
 
#define SHDR_O(m)   bu_offsetof(struct camo_specific, m)
 

Functions

void color_fix (const struct bu_structparse *, const char *, void *, const char *, void *)
 
HIDDEN int marble_setup (register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
 
HIDDEN int marble_render (struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
 
HIDDEN int camo_setup (register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
 
HIDDEN int camo_render (struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
 
HIDDEN void camo_print (register struct region *rp, void *dp)
 
HIDDEN void camo_free (void *cp)
 
HIDDEN int setup (register struct region *rp, struct bu_vls *matparm, void **dpp, struct rt_i *rtip, char *parameters, struct camo_specific defaults)
 

Variables

struct bu_structparse camo_print_tab []
 
struct bu_structparse camo_parse []
 
struct mfuncs camo_mfuncs []
 

Detailed Description

A shader to apply a crude camouflage color pattern to an object using a fractional Brownian motion of 3 colors

At each hit point, the shader evaluate the fbm to obtain a "Noise" value between -1 and 1. The color produced is:

Noise value Color -1 <= N < t1 c1 t1 <= N < t2 c2 t2 <= N <= 1 c3

Definition in file sh_camo.c.

Macro Definition Documentation

#define SMOOTHSTEP (   x)    ((x)*(x)*(3 - 2*(x)))

Definition at line 50 of file sh_camo.c.

#define camo_MAGIC   0x18364 /* XXX change this number for each shader */

Definition at line 53 of file sh_camo.c.

#define CK_camo_SP (   _p)    BU_CKMAG(_p, camo_MAGIC, "camo_specific")

Definition at line 70 of file sh_camo.c.

Referenced by camo_render(), and marble_render().

#define SHDR_NULL   ((struct camo_specific *)0)

Definition at line 106 of file sh_camo.c.

#define SHDR_O (   m)    bu_offsetof(struct camo_specific, m)

Definition at line 107 of file sh_camo.c.

Function Documentation

void color_fix ( const struct bu_structparse sdp,
const char *  name,
void *  base,
const char *  value,
void *  data 
)

Definition at line 174 of file sh_camo.c.

References bu_structparse::sp_count, and bu_structparse::sp_offset.

HIDDEN int marble_setup ( register struct region rp,
struct bu_vls matparm,
void **  dpp,
const struct mfuncs *  mfp,
struct rt_i rtip 
)

Definition at line 353 of file sh_camo.c.

References setup().

Here is the call graph for this function:

int marble_render ( struct application ap,
const struct partition pp,
struct shadework *  swp,
void *  dp 
)

Definition at line 364 of file sh_camo.c.

References BN_CK_TABDATA, BN_GET_TABDATA, bn_noise_turb(), bn_tabdata_blend2(), bn_tabdata_free(), bu_struct_print(), camo_specific::c2, CK_camo_SP, M_PI, camo_specific::noise_h_val, camo_specific::noise_lacunarity, camo_specific::noise_octaves, rdebug, RDEBUG_SHADE, RT_AP_CHECK, RT_CHECK_PT, rt_spect_reflectance_rgb(), spectrum, and camo_specific::xform.

Here is the call graph for this function:

HIDDEN int camo_setup ( register struct region rp,
struct bu_vls matparm,
void **  dpp,
const struct mfuncs *  mfp,
struct rt_i rtip 
)

Definition at line 271 of file sh_camo.c.

References setup().

Here is the call graph for this function:

int camo_render ( struct application ap,
const struct partition pp,
struct shadework *  swp,
void *  dp 
)

Definition at line 296 of file sh_camo.c.

References BN_CK_TABDATA, bn_noise_fbm(), bu_struct_print(), camo_specific::c1, camo_specific::c2, camo_specific::c3, CK_camo_SP, camo_specific::noise_h_val, camo_specific::noise_lacunarity, camo_specific::noise_octaves, rdebug, RDEBUG_SHADE, RT_AP_CHECK, RT_CHECK_PT, rt_spect_reflectance_rgb(), camo_specific::t1, camo_specific::t2, and camo_specific::xform.

Here is the call graph for this function:

HIDDEN void camo_print ( register struct region rp,
void *  dp 
)

Definition at line 278 of file sh_camo.c.

References bu_struct_print(), and region::reg_name.

Here is the call graph for this function:

HIDDEN void camo_free ( void *  cp)

Definition at line 285 of file sh_camo.c.

References BU_PUT.

HIDDEN int setup ( register struct region rp,
struct bu_vls matparm,
void **  dpp,
struct rt_i rtip,
char *  parameters,
struct camo_specific  defaults 
)

Definition at line 205 of file sh_camo.c.

References bn_mat_mul(), bn_mat_mul2(), bn_mat_print(), BU_CK_VLS, BU_GET, bu_log(), bu_struct_parse(), bu_struct_print(), bu_vls_addr(), db_region_mat(), camo_specific::noise_delta, camo_specific::noise_size, camo_specific::noise_vscale, rdebug, RDEBUG_SHADE, region::reg_name, RT_CHECK_RTI, RT_CK_REGION, rt_uniresource, rt_i::rti_dbip, and camo_specific::xform.

Referenced by camo_setup(), and marble_setup().

Here is the call graph for this function:

Variable Documentation

struct bu_structparse camo_print_tab[]
Initial value:
= {
{"%g", 1, "lacunarity", SHDR_O(noise_lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "H", SHDR_O(noise_h_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "octaves", SHDR_O(noise_octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "size", SHDR_O(noise_size), bu_mm_cvt, NULL, NULL },
{"%f", 3, "vscale", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "thresh1", SHDR_O(t1), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "thresh2", SHDR_O(t2), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "color1", SHDR_O(c1), color_fix, NULL, NULL },
{"%f", 3, "color2", SHDR_O(c2), color_fix, NULL, NULL },
{"%f", 3, "color3", SHDR_O(c3), color_fix, NULL, NULL },
{"%f", 3, "delta", SHDR_O(noise_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
void bu_mm_cvt(const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
Definition: units.c:386
#define SHDR_O(m)
Definition: sh_camo.c:107
void color_fix(const struct bu_structparse *, const char *, void *, const char *, void *)
Definition: sh_camo.c:174
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153

Definition at line 112 of file sh_camo.c.

struct bu_structparse camo_parse[]
Initial value:
= {
{"%g", 1, "lacunarity", SHDR_O(noise_lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "l", SHDR_O(noise_lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "H", SHDR_O(noise_h_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "octaves", SHDR_O(noise_octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "o", SHDR_O(noise_octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "t1", SHDR_O(t1), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "t2", SHDR_O(t2), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "size", SHDR_O(noise_size), bu_mm_cvt, NULL, NULL },
{"%g", 1, "s", SHDR_O(noise_size), bu_mm_cvt, NULL, NULL },
{"%f", 3, "vscale", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "vs", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "v", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "c1", SHDR_O(c1), color_fix, NULL, NULL },
{"%f", 3, "c2", SHDR_O(c2), color_fix, NULL, NULL },
{"%f", 3, "c3", SHDR_O(c3), color_fix, NULL, NULL },
{"%f", 3, "delta", SHDR_O(noise_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "d", SHDR_O(noise_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
void bu_mm_cvt(const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
Definition: units.c:386
#define SHDR_O(m)
Definition: sh_camo.c:107
void color_fix(const struct bu_structparse *, const char *, void *, const char *, void *)
Definition: sh_camo.c:174
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153

Definition at line 128 of file sh_camo.c.