/
InteractionPass.h
51 lines (40 loc) · 1.17 KB
/
InteractionPass.h
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
#pragma once
#include "OpenGLShaderPass.h"
#include "glprogram/GLSLBumpProgram.h"
namespace render
{
class OpenGLRenderSystem;
class GLProgramFactory;
/**
* Lighting Interaction pass (Diffuse/Bump/Specular).
*/
class InteractionPass :
public OpenGLShaderPass
{
public:
InteractionPass(OpenGLShader& owner, OpenGLRenderSystem& renderSystem);
GLSLBumpProgram& getProgram()
{
return *static_cast<GLSLBumpProgram*>(_glState.glProgram);
}
Matrix4 getDiffuseTextureTransform() const
{
return GetTextureTransformFromStage(state().stage0);
}
Matrix4 getBumpTextureTransform() const
{
return GetTextureTransformFromStage(state().stage1);
}
Matrix4 getSpecularTextureTransform() const
{
return GetTextureTransformFromStage(state().stage2);
}
// Generates the state with all the required flags for drawing interaction passes
static OpenGLState GenerateInteractionState(GLProgramFactory& programFactory);
private:
inline static Matrix4 GetTextureTransformFromStage(const IShaderLayer::Ptr& stage)
{
return stage ? stage->getTextureTransform() : Matrix4::getIdentity();
}
};
}