This is blotch.c in view mode; [Download] [Up]
/*
* blotch.c
*
* Copyright (C) 1989, 1991, Craig E. Kolb
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
* $Id$
*
* $Log$
*/
#include "texture.h"
#include "blotch.h"
/*
* Create and return a reference to a "blotch" texture.
*/
Blotch *
BlotchCreate(mix, surf)
Float mix;
Surface *surf;
{
Blotch *blotch;
blotch = (Blotch *)Malloc(sizeof(Blotch));
blotch->mix = mix;
blotch->surf = surf;
return blotch;
}
/*
* Apply "blotch" texture.
*/
/*ARGSUSED*/
void
BlotchApply(blotch, prim, ray, pos, norm, gnorm, surf)
Blotch *blotch;
Object *prim;
Ray *ray;
Vector *pos, *norm, *gnorm;
Surface *surf;
{
Float val;
/*
* "mix" represents the 'average' noise value at a point.
*/
val = Noise3(pos);
if (val > blotch->mix) {
val = (val - blotch->mix) / (1. - blotch->mix);
SurfaceBlend(surf, blotch->surf, 1. - val, val);
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.