#ifndef _HAIR_VR_SHADE_INSTANCE_H_ #define _HAIR_VR_SHADE_INSTANCE_H_ // Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 #include #include #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(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