aboutsummaryrefslogtreecommitdiff
path: root/libexe/sample/include/shaveSDKCALLBACKS2.c
blob: 5baddb138784449959245862225663c3f906d2b2 (plain) (blame)
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
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

#include <shader.h>

#include "shaveSDKTYPES.h"
#include "shaveSDKCALLBACKS2.h"
#include "shaveMRShaderConst.h"
#include "shaveMRShaderUtil.h"


void SHAVE2apply_inst_color(
		WFTYPE* instance_geom, int hairID, int slgID, unsigned long shaveINSTID
)
{
}


VERT SHAVE2displace_root(VERT* root, CURVEINFO* ci, int ID)
{
	VERT ret;
	ret.x=0;
	ret.y=0;
	ret.z=0;
	return ret;
}


int SHAVE2progress(int actual, int estimated_total)
{
	if (!shaveProgress_enabled) return 0;

	if ((actual > 0) && (--shaveProgress_ticksLeft > 0)) return 0;

	shaveProgress_ticksLeft = shaveProgress_ticksPerMsg;

	if (actual > estimated_total) actual = estimated_total;

	mi_progress(
		"Shave: %s done %f%%.\n",
		shaveProgress_action, 
		(float)actual * 100.0 / (float)estimated_total
	);

	return 0;
}


void SHAVE2coord_convertTOSHAVE(VERT* in)
{
}


void SHAVE2coord_convertFROMSHAVE(VERT* in)
{
}


float SHAVE2apply_texture(
		CURVEINFO*		ci,
		VERT			rest_root_worldpos,
		unsigned long	shaveINSTID,
		int				parm,
		float			inbound_value
)
{
	return inbound_value;	
}


void MAYA2external_forces(VERT* lastpos, VERT* velocity, int y)
{
}


VERT SHAVE2apply_GI(VERT v,CURVEINFO *cinfo)
{
	//
	// The irradiance funcs cannot be called from an output shader, so we
	// just return zero irradiance.
	//
	static VERT	shaveIrrad = { 0.0f, 0.0f, 0.0f };

	return shaveIrrad;
}


float SHAVE2apply_falloff(int lightNUM, VERT p, float intensity)
{
	if (intensity > 0.0f)
	{
		ShaveMRDecayRate	decay = kDecayNone;
		miTag				lightInst;

		if (shaveMR_getLightInfoByID(lightNUM, &lightInst, &decay)
		&&	(decay != kDecayNone))
		{
			//
			// Get the light's world position and calculate the distance
			// from it to 'p'.
			//
			miScalar		dist;
			const miVector	localLightPos = { 0.0f, 0.0f, 0.0f };
			miVector*		p2 = (miVector*)&p;
			miMatrix*		pMat;
			miVector		worldLightPos;

			mi_query(miQ_INST_LOCAL_TO_GLOBAL, NULL, lightInst, (void*)&pMat);
			mi_point_transform(&worldLightPos, &localLightPos, *pMat);

			dist = (miScalar)mi_vector_dist(&worldLightPos, p2);

			//
			// Decay doesn't begin until one unit out from the light.
			//
			if (dist > 1.0f)
			{
				switch (decay)
				{
					case kDecayLinear:
						intensity = intensity / dist;
					break;

					case kDecayQuadratic:
						intensity = intensity / (dist * dist);
					break;

					case kDecayCubic:
						intensity = intensity / (dist * dist * dist);
					break;

					default:
					break;
				}
			}
		}
	}

	return intensity;
}



VERT SHAVE2apply_illumination(int LIGHTID, VERT wpos, VERT vector, VERT color)
{
	return color;
}


void SHAVE2apply_illuminationWF(int LIGHTID, WFTYPE* samples)
{
}


VERT SHAVE2apply_atmosphere(VERT wpos, VERT inbound_color)
{
	return inbound_color;
}


float SHAVE2apply_VMAP(long SHAVEINSTID,int VERTID,int chan, float inbound_value)
{
	return inbound_value;	
}

void SHAVEdraw_tile_callback2(VERT *a, VERT *b)
{
}