2016-03-21 04:10:14 +00:00
|
|
|
#ifndef _R3DSHADER_H_
|
|
|
|
#define _R3DSHADER_H_
|
|
|
|
|
|
|
|
#include "Pkgs/glew.h"
|
2017-08-11 00:41:10 +00:00
|
|
|
#include "Util/NewConfig.h"
|
2016-03-21 04:10:14 +00:00
|
|
|
#include "Model.h"
|
|
|
|
|
|
|
|
namespace New3D {
|
|
|
|
|
|
|
|
class R3DShader
|
|
|
|
{
|
|
|
|
public:
|
2017-08-11 00:41:10 +00:00
|
|
|
R3DShader(const Util::Config::Node &config);
|
2016-03-21 04:10:14 +00:00
|
|
|
|
2017-08-11 11:59:41 +00:00
|
|
|
bool LoadShader (const char* vertexShader = nullptr, const char* fragmentShader = nullptr);
|
|
|
|
void SetMeshUniforms (const Mesh* m);
|
|
|
|
void SetModelStates (const Model* model);
|
|
|
|
void SetViewportUniforms (const Viewport *vp);
|
|
|
|
void Start ();
|
|
|
|
void SetShader (bool enable = true);
|
|
|
|
GLint GetVertexAttribPos (const char* attrib);
|
2018-05-02 20:10:02 +00:00
|
|
|
void DiscardAlpha (bool discard); // use to remove alpha from texture alpha only polys for 1st pass
|
2016-03-21 04:10:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-08-11 00:41:10 +00:00
|
|
|
// run-time config
|
|
|
|
const Util::Config::Node &m_config;
|
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// shader IDs
|
2016-03-21 04:10:14 +00:00
|
|
|
GLuint m_shaderProgram;
|
|
|
|
GLuint m_vertexShader;
|
|
|
|
GLuint m_fragmentShader;
|
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// mesh uniform locations
|
2016-05-04 00:35:07 +00:00
|
|
|
GLint m_locTexture1;
|
|
|
|
GLint m_locTexture2;
|
|
|
|
GLint m_locTexture1Enabled;
|
|
|
|
GLint m_locTexture2Enabled;
|
2016-03-21 04:10:14 +00:00
|
|
|
GLint m_locTextureAlpha;
|
|
|
|
GLint m_locAlphaTest;
|
2017-08-10 15:43:03 +00:00
|
|
|
GLint m_locMicroTexScale;
|
|
|
|
GLint m_locBaseTexSize;
|
|
|
|
GLint m_locTextureInverted;
|
|
|
|
|
|
|
|
// cached mesh values
|
|
|
|
bool m_textured1;
|
2016-05-04 00:35:07 +00:00
|
|
|
bool m_textured2;
|
2016-03-22 23:39:59 +00:00
|
|
|
bool m_textureAlpha; // use alpha in texture
|
|
|
|
bool m_alphaTest; // discard fragment based on alpha (ogl does this with fixed function)
|
|
|
|
float m_fogIntensity;
|
2017-08-10 15:43:03 +00:00
|
|
|
bool m_lightEnabled;
|
|
|
|
float m_shininess;
|
|
|
|
float m_specularValue;
|
|
|
|
bool m_specularEnabled;
|
2017-08-14 09:14:06 +00:00
|
|
|
bool m_fixedShading;
|
2017-08-10 15:43:03 +00:00
|
|
|
|
|
|
|
bool m_layered;
|
|
|
|
float m_microTexScale;
|
|
|
|
float m_baseTexSize[2];
|
|
|
|
bool m_textureInverted;
|
|
|
|
|
|
|
|
// cached model values
|
2017-07-29 16:30:30 +00:00
|
|
|
float m_modelScale;
|
2016-03-21 04:10:14 +00:00
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// are our cache values dirty
|
|
|
|
bool m_dirtyMesh;
|
|
|
|
bool m_dirtyModel;
|
|
|
|
|
|
|
|
// viewport uniform locations
|
2016-03-21 04:10:14 +00:00
|
|
|
GLint m_locFogIntensity;
|
2017-04-05 17:57:38 +00:00
|
|
|
GLint m_locFogDensity;
|
|
|
|
GLint m_locFogStart;
|
|
|
|
GLint m_locFogColour;
|
|
|
|
GLint m_locFogAttenuation;
|
|
|
|
GLint m_locFogAmbient;
|
|
|
|
|
2017-07-29 16:30:30 +00:00
|
|
|
// lighting / other
|
2017-04-05 17:57:38 +00:00
|
|
|
GLint m_locLighting;
|
2017-08-09 16:56:56 +00:00
|
|
|
GLint m_locLightEnabled;
|
2017-08-10 15:43:03 +00:00
|
|
|
GLint m_locSunClamp;
|
|
|
|
GLint m_locIntensityClamp;
|
|
|
|
GLint m_locShininess;
|
|
|
|
GLint m_locSpecularValue;
|
|
|
|
GLint m_locSpecularEnabled;
|
2017-08-14 09:14:06 +00:00
|
|
|
GLint m_locFixedShading;
|
2017-08-10 15:43:03 +00:00
|
|
|
|
|
|
|
GLint m_locSpotEllipse;
|
|
|
|
GLint m_locSpotRange;
|
|
|
|
GLint m_locSpotColor;
|
|
|
|
GLint m_locSpotFogColor;
|
|
|
|
|
|
|
|
// model uniforms
|
|
|
|
GLint m_locModelScale;
|
2017-08-14 09:14:06 +00:00
|
|
|
|
|
|
|
// global uniforms
|
|
|
|
GLint m_locHardwareStep;
|
2018-05-02 20:10:02 +00:00
|
|
|
GLint m_locDiscardAlpha;
|
2017-04-05 17:57:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // New3D
|
2016-03-21 04:10:14 +00:00
|
|
|
|
|
|
|
#endif
|