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
|
#ifndef _HAIR_VR_SHADE_INSTANCE_H_
#define _HAIR_VR_SHADE_INSTANCE_H_
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#include <vrayinterface.h>
#include <geometryclasses.h>
#include "vray3_compat.h"
#include "shaveVrayVoxelPrim.h"
//class shaveVrayVoxelPrim;
class shaveVrayShadeInstance: public VR::VRayShadeInstance, VR::ObjectShadeInstance {
shaveVrayVoxelPrim *hairPrim;
public:
shaveVrayShadeInstance(shaveVrayVoxelPrim *p):hairPrim(p){}
PluginInterface* newInterface(InterfaceID id) VRAY_OVERRIDE {
if (id == EXT_OBJECT_SHADE_INSTANCE) return static_cast<VR::ObjectShadeInstance*>(this);
return NULL;
}
PluginBase* getPlugin(void) VRAY_OVERRIDE {return this;}
// From ObjectShadeInstance
VR::ShadeVec getBasePtObj(const VR::VRayContext &rc) VRAY_OVERRIDE {return rc.rayresult.wpoint;}
VR::ShadeVec worldToObjectVec(const VR::VRayContext &rc, const VR::ShadeVec &vec) VRAY_OVERRIDE {
(void)rc; (void)vec;
return /*(rc.rayparams.currentPass != RPASS_GI && rc.rayparams.currentPass != RPASS_LIGHTMAP) ? vec :*/ VR::ShadeVec(1.0f,0.0f,0.0f);}
VR::ShadeVec worldToObjectPt(const VR::VRayContext &rc, const VR::ShadeVec &pt) VRAY_OVERRIDE {
(void)rc; (void)pt;
return /*(rc.rayparams.currentPass != RPASS_GI && rc.rayparams.currentPass != RPASS_LIGHTMAP) ? pt :*/ VR::ShadeVec(0.0f,0.0f,0.0f);}
VR::ShadeVec objectToWorldVec(const VR::VRayContext &rc, const VR::ShadeVec &vec) VRAY_OVERRIDE {
(void)rc; (void)vec;
return /*(rc.rayparams.currentPass != RPASS_GI && rc.rayparams.currentPass != RPASS_LIGHTMAP) ? vec :*/ VR::ShadeVec(1.0f,0.0f,0.0f);}
VR::ShadeVec objectToWorldPt(const VR::VRayContext &rc, const VR::ShadeVec &pt) VRAY_OVERRIDE {
(void)rc; (void)pt;
return /*(rc.rayparams.currentPass != RPASS_GI && rc.rayparams.currentPass != RPASS_LIGHTMAP) ? pt :*/ VR::ShadeVec(0.0f,0.0f,0.0f);}
#if defined(VRAY30)
VR::TracePoint getShadowPt(const VR::VRayContext &rc) VRAY_OVERRIDE{return rc.rayresult.wpoint; }
#elif defined(VRAY40)
VR::ShadeVec getShadowPt(const VR::VRayContext &rc) VRAY_OVERRIDE{return rc.rayresult.wpoint; }
#endif
VR::ShadeVec getVelocity(const VR::VRayContext &rc) VRAY_OVERRIDE
{
const IHairVoxel* hair=hairPrim->GetVoxel();
int strandIdx, segmentIdx;
float segmentOffset;
shaveVrayGetHairParams(rc, strandIdx, segmentIdx, segmentOffset);
int fs, fe;
hair->GetFace(strandIdx, fs, fe);
int vert_idx = fs + segmentIdx;
VR::ShadeVec ve0, ve1;
GetVelocity(hair, vert_idx, ve0);
GetVelocity(hair, vert_idx + 1, ve1);
return VR::interpolate(segmentOffset, ve0, ve1);
}
};
#endif
|