ICompositeShader.h

Go to the documentation of this file.
00001 
00002 //
00003 //      Composite Shader Interface
00004 //
00005 //      Created: 9/27/01 Cleve Ard
00006 //
00007 #pragma once
00008 
00009 #include "iFnPub.h"
00010 // forward declarations
00011 class RenderGlobalContext;
00012 
00013 // ISpecularCompositeShader is used to let a shader choose the manner
00014 // that it combines specular and diffuse lighting. The shader can use
00015 // any information in the RenderGlobalContext to make this decision.
00016 
00017 // Several shaders, include anisotropic, translucent, and multilayer
00018 // combine specular and diffuse lighting using this equation:
00019 //   L = specular + (1 - specular) * diffuse
00020 // This only works when 0 <= specular <= 1. These shaders use this
00021 // interface to determine whether we are rendering with a tone operator.
00022 // If the render is using a tone operator, then the specular and diffuse
00023 // lighting is simply added for the total lighting.
00024 
00025 // In order for a StdMtl2 to ask for and call this interface for a shader
00026 // it must return MTLREQ_PREPRO in it's LocalRequirements method.
00027 
00079 class ISpecularCompositeShader : public BaseInterface {
00080 public:
00081 
00082     // Choose specular method
00095     virtual void ChooseSpecularMethod(TimeValue t, RenderGlobalContext* rgc) = 0;
00096 };
00097 
00098 
00099 #define ISPECULAR_COMPOSITE_SHADER_ID Interface_ID(0x5e2117d0, 0x327e2f73)
00100 
00101 // Get the ISpecularCompositeShader method, if there is one.
00102 inline ISpecularCompositeShader* GetSpecularCompositeShader(InterfaceServer* s)
00103 {
00104     return static_cast<ISpecularCompositeShader*>(s->GetInterface(
00105         ISPECULAR_COMPOSITE_SHADER_ID));
00106 }
00107 
00108 // Choose the method for combining specular and diffuse lighting.
00109 inline void ChooseSpecularMethod(InterfaceServer* s, TimeValue t, RenderGlobalContext* rgc)
00110 {
00111     ISpecularCompositeShader* scs = GetSpecularCompositeShader(s);
00112     if (scs != NULL)
00113         scs->ChooseSpecularMethod(t, rgc);
00114 }
00115