23 using std::make_unique;
42 SkyRenderShader::SkyRenderShader(
Renderer* renderer)
64 "shader/" + shaderVersion +
"/framebuffer",
65 "render_vertexshader.vert"
71 "shader/" + shaderVersion +
"/framebuffer/sky",
72 "render_fragmentshader.frag"
178 Engine::ShaderType::SHADERTYPE_SKY,
185 {
"day_top_color",
ShaderParameter(
Color4(0.1f, 0.6f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
186 {
"day_bottom_color",
ShaderParameter(
Color4(0.4f, 0.8f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
187 {
"sunset_top_color",
ShaderParameter(
Color4(0.7f, 0.75f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
188 {
"sunset_bottom_color",
ShaderParameter(
Color4(1.0f, 0.5f, 0.7f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
189 {
"night_top_color",
ShaderParameter(
Color4(0.02f, 0.0f, 0.04f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
190 {
"night_bottom_color",
ShaderParameter(
Color4( 0.1f, 0.0f, 0.2f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
192 {
"horizon_color",
ShaderParameter(
Color4(0.0f, 0.7f, 0.8f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
196 {
"sun_color",
ShaderParameter(
Color4(1.0f, 0.8f, 0.1f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
197 {
"sun_sunset_color",
ShaderParameter(
Color4(10.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
202 {
"moon_color",
ShaderParameter(
Color4(1.0f, 0.95f, 0.7f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
206 {
"clouds_edge_color",
ShaderParameter(
Color4(0.8f, 0.8f, 0.98f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
207 {
"clouds_top_color",
ShaderParameter(
Color4(1.0f, 1.0f, 1.00f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
208 {
"clouds_middle_color",
ShaderParameter(
Color4(0.92f, 0.92f, 0.98f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
209 {
"clouds_bottom_color",
ShaderParameter(
Color4(0.83f, 0.83f, 0.94f, 1.0f)),
ShaderParameter(
Color4(0.0f, 0.0f, 0.0f, 1.0f)),
ShaderParameter(
Color4(1.0f, 1.0f, 1.0f, 1.0f)),
ShaderParameter(
Color4(0.1f, 0.1f, 0.1f, 0.0f)) },
248 if (camera ==
nullptr) camera = engine->
getCamera();
261 sunLight->setupSun(t);
262 moonLight->setupMoon(t);
266 auto sunLightPosition4 = sunLight->getPosition().clone().scale(1.0f / (Math::abs(sunLight->getPosition().getW()) < Math::EPSILON?1.0:sunLight->getPosition().getW()));
267 auto sunLightPosition =
Vector3(sunLightPosition4[0], sunLightPosition4[1], sunLightPosition4[2]);
268 auto sunLightDirection = sunLightPosition.clone().normalize().scale(-1.0f);
270 auto moonLightPosition4 = moonLight->getPosition().clone().scale(1.0f / (Math::abs(moonLight->getPosition().getW()) < Math::EPSILON?1.0:moonLight->getPosition().getW()));
271 auto moonLightPosition =
Vector3(moonLightPosition4[0], moonLightPosition4[1], moonLightPosition4[2]);
272 auto moonLightDirection = moonLightPosition.clone().normalize().scale(-1.0f);
const Vector3 & getSideVector() const
const Vector3 & getForwardVector() const
const Vector3 & getUpVector() const
Color 4 definition class.
Light * getLightAt(int32_t idx)
Returns light at idx (0 <= idx < 8)
static Engine * getInstance()
Returns engine instance.
static FrameBufferRenderShader * getFrameBufferRenderShader()
static TextureManager * getTextureManager()
const ShaderParameter getShaderParameter(const string &shaderId, const string ¶meterName)
Returns shader parameter for given shader id and parameter name, if the value does not exist,...
static void registerShader(ShaderType type, const string &shaderId, const vector< Shader::ParameterDefaults > ¶meterDefaults={}, bool internal=false)
Register shader.
Shader parameter model class.
const array< float, 3 > getColor3ValueArray() const
bool getBooleanValue() const
float getFloatValue() const
Frame buffer render shader.
int32_t uniformCloudsScale
int32_t uniformHorizonColor
int32_t uniformCloudsSpeed
~SkyRenderShader()
Public destructor.
int32_t uniformCloudsDirection
int32_t uniformLightScatteringPass
int32_t uniformDayTopColor
void initialize()
Initialize.
void unloadTextures()
Unload textures.
int32_t uniformCloudsBottomColor
int32_t uniformLIGHT0_ENABLED
int32_t uniformNightBottomColor
int32_t uniformCloudsCutoff
int32_t uniformSunsetTopColor
int32_t uniformCloudsEdgeColor
int32_t uniformNightTopColor
int32_t uniformStarsSpeed
void render(Engine *engine, bool lightScatteringPass, Camera *camera=nullptr)
Render.
int32_t uniformLIGHT0_DIRECTION
int32_t uniformSideVector
int32_t uniformSunColorFactor
int32_t uniformSunSunsetColor
int32_t uniformMoonColorFactor
int32_t uniformSunsetBottomColor
int32_t uniformDayBottomColor
int32_t uniformCloudsMiddleColor
int32_t uniformForwardVector
int32_t uniformLIGHT1_ENABLED
int32_t uniformCloudsTopColor
int32_t uniformLIGHT1_DIRECTION
int32_t uniformHorizonBlur
void loadTextures(const string &pathName)
Load textures.
int32_t uniformStarsTexture
int32_t uniformCloudsBlur
int32_t uniformCloudsWeight
int32_t uniformAspectRatio
int32_t uniformCloudsFuzziness
void removeTexture(Texture *texture)
Removes a texture from manager.
TextureManager_TextureManaged * addTexture(const string &id, bool &created)
Adds a texture to manager.
virtual void setTextureUnit(int contextIdx, int32_t textureUnit)=0
Sets up texture unit.
virtual int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string())=0
Loads a shader.
int32_t SHADER_FRAGMENT_SHADER
virtual void enableCulling(int contextIdx)=0
Enable culling.
virtual void enableDepthBufferTest()=0
Enable depth buffer test.
virtual void enableDepthBufferWriting()=0
Enable depth buffer writing.
virtual void unbindBufferObjects(int contextIdx)=0
Unbind buffer objects.
int32_t SHADER_VERTEX_SHADER
virtual int32_t createProgram(int type)=0
Creates a shader program.
virtual bool isUsingProgramAttributeLocation()=0
virtual void setProgramAttributeLocation(int32_t programId, int32_t location, const string &name)=0
Bind attribute to a input location.
virtual void setProgramUniformInteger(int contextIdx, int32_t uniformId, int32_t value)=0
Set up a integer uniform value.
virtual bool linkProgram(int32_t programId)=0
Links attached shaders to a program.
virtual void bindTexture(int contextIdx, int32_t textureId)=0
Binds a texture with given id or unbinds when using ID_NONE.
virtual void disableDepthBufferWriting()=0
Disable depth buffer writing.
void setLighting(int contextIdx, int32_t lighting)
Set current lighting model.
virtual void attachShaderToProgram(int32_t programId, int32_t shaderId)=0
Attaches a shader to a program.
virtual int32_t getProgramUniformLocation(int32_t programId, const string &name)=0
Returns location of given uniform variable.
virtual void drawTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset)=0
Draw triangles from buffer objects.
virtual void disableCulling(int contextIdx)=0
Disable culling.
int32_t CONTEXTINDEX_DEFAULT
virtual void bindTextureCoordinatesBufferObject(int contextIdx, int32_t bufferObjectId)=0
Bind texture coordinates buffer object.
virtual void useProgram(int contextIdx, int32_t programId)=0
Use shader program.
virtual void setProgramUniformFloatVec3(int contextIdx, int32_t uniformId, const array< float, 3 > &data)=0
Set up a float vec3 uniform value.
virtual void bindVerticesBufferObject(int contextIdx, int32_t bufferObjectId)=0
Bind vertices buffer object.
virtual void disableDepthBufferTest()=0
Disable depth buffer test.
virtual const string getShaderVersion()=0
virtual void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value)=0
Set up a float uniform value.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
const array< float, 3 > & getArray() const
Vector4 class representing vector4 mathematical structure and operations with x, y,...
virtual void releaseReference()
Releases a reference, thus decrementing the counter and delete it if reference counter is zero.