7 #include "VectorMath.h"
17 namespace PackedStencilShadowShaderCode
19 const std::string PositionName =
"Position";
20 const std::string ExtrusionUnpackName =
"ExtrusionUnpack";
21 const std::string UnpackModelViewProjectionMatrixName =
"UnpackModelViewProjectionMatrix";
23 const std::string _vertexCode =
24 "attribute highp vec4 "+PositionName+
";\n"
25 "uniform highp mat4 "+UnpackModelViewProjectionMatrixName+
";\n"
26 "uniform highp vec3 "+ExtrusionUnpackName+
";\n"
29 "highp vec3 packedPos = Position.xyz - ExtrusionUnpack*Position.w;\n"
30 "gl_Position = UnpackModelViewProjectionMatrix * vec4(packedPos, 1.0);\n"
33 const std::string _fragmentCode =
36 "gl_FragColor.rgb = vec3(1.0,0.0,0.0);\n"
37 "gl_FragColor.a = 1.0;\n"
48 PackedStencilShadowShaderCode::_vertexCode,
49 PackedStencilShadowShaderCode::_fragmentCode
53 void SetMVP(
const m44& mvp)
const
55 bool transpose =
false;
56 SetUniformM44(mvp, m_mvpUniformLocation, transpose);
59 void SetExtrusionUnpack(
const v3& extrusionUnpack)
const
61 SetUniformV3(extrusionUnpack, m_extrusionUnpackUniform);
70 PackedStencilShadowShader(
const TShaderId shaderId,
const std::string& vertexShaderCode,
const std::string& fragmentShaderCode)
72 , m_mvpUniformLocation(0)
73 , m_extrusionUnpackUniform(0)
75 CompileProgram(vertexShaderCode, fragmentShaderCode);
77 m_mvpUniformLocation = GetUniformLocation(PackedStencilShadowShaderCode::UnpackModelViewProjectionMatrixName);
78 m_extrusionUnpackUniform = GetUniformLocation(PackedStencilShadowShaderCode::ExtrusionUnpackName);
82 GLuint m_mvpUniformLocation;
83 GLuint m_extrusionUnpackUniform;