added fog
This commit is contained in:
parent
846eff8b11
commit
410c62baa9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -39,6 +39,8 @@
|
|||||||
<None Include="shaders\shader_color.vert" />
|
<None Include="shaders\shader_color.vert" />
|
||||||
<None Include="shaders\shader_tex.frag" />
|
<None Include="shaders\shader_tex.frag" />
|
||||||
<None Include="shaders\shader_tex.vert" />
|
<None Include="shaders\shader_tex.vert" />
|
||||||
|
<None Include="shaders\skybox.frag" />
|
||||||
|
<None Include="shaders\skybox.vert" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{10701B86-9B0B-46A1-85DA-6238CBCC507B}</ProjectGuid>
|
<ProjectGuid>{10701B86-9B0B-46A1-85DA-6238CBCC507B}</ProjectGuid>
|
||||||
|
@ -97,5 +97,11 @@
|
|||||||
<None Include="shaders\shader_tex.vert">
|
<None Include="shaders\shader_tex.vert">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="shaders\skybox.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\skybox.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -6,11 +6,27 @@ uniform vec3 lightDir;
|
|||||||
in vec3 interpNormal;
|
in vec3 interpNormal;
|
||||||
in vec2 interpTexCoord;
|
in vec2 interpTexCoord;
|
||||||
|
|
||||||
|
float near = 00.01f;
|
||||||
|
float far = 100.0f;
|
||||||
|
|
||||||
|
float linearizeDepth(float depth)
|
||||||
|
{
|
||||||
|
return (2.0 * near * far) / (far + near - (depth * 2.0 - 1.0) * (far - near));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float logisticDepth(float depth, float steepness, float offset)
|
||||||
|
{
|
||||||
|
float zVal = linearizeDepth(depth);
|
||||||
|
return (1 / (1 + exp(-steepness * (zVal - offset))));
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 modifiedTexCoord = vec2(interpTexCoord.x, 1.0 - interpTexCoord.y); // Poprawka dla tekstur Ziemi, ktore bez tego wyswietlaja sie 'do gory nogami'
|
vec2 modifiedTexCoord = vec2(interpTexCoord.x, 1.0 - interpTexCoord.y); // Poprawka dla tekstur Ziemi, ktore bez tego wyswietlaja sie 'do gory nogami'
|
||||||
vec3 color = texture2D(textureSampler, modifiedTexCoord).rgb;
|
vec3 color = texture2D(textureSampler, modifiedTexCoord).rgb;
|
||||||
vec3 normal = normalize(interpNormal);
|
vec3 normal = normalize(interpNormal);
|
||||||
float diffuse = max(dot(normal, -lightDir), 0.0);
|
float diffuse = max(dot(normal, -lightDir), 0.0);
|
||||||
gl_FragColor = vec4(color * diffuse, 1.0);
|
float depth = logisticDepth(gl_FragCoord.z, 0.5f, 4.0f);
|
||||||
}
|
gl_FragColor = vec4(color * diffuse, 1.0) * (1.0f - depth) + vec4(depth * vec3(5.0f/255.0f, 35.0f/255.0f, 95.0f/255.0f), 1.0f);
|
||||||
|
}
|
@ -6,7 +6,23 @@ in vec3 texCoords;
|
|||||||
|
|
||||||
uniform samplerCube skybox;
|
uniform samplerCube skybox;
|
||||||
|
|
||||||
|
float near = 00.01f;
|
||||||
|
float far = 10.f;
|
||||||
|
|
||||||
|
float linearizeDepth(float depth)
|
||||||
|
{
|
||||||
|
return (2.0 * near * far) / (far + near - (depth * 2.0 - 1.0) * (far - near));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float logisticDepth(float depth, float steepness, float offset)
|
||||||
|
{
|
||||||
|
float zVal = linearizeDepth(depth);
|
||||||
|
return (1 / (1 + exp(-steepness * (zVal - offset))));
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = texture(skybox, texCoords);
|
float depth = logisticDepth(gl_FragCoord.z, 0.5f, 4.0f);
|
||||||
|
FragColor = texture(skybox, texCoords) * (1.0f - depth) + vec4(depth * vec3(5.0f/255.0f, 35.0f/255.0f, 95.0f/255.0f), 1.0f);
|
||||||
}
|
}
|
@ -365,12 +365,12 @@ void renderScene()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// narysuj teren z pliku terenu
|
// narysuj teren z pliku terenu
|
||||||
drawObjectTexture(terrainContext, glm::translate(glm::vec3(0, -20, 0)) * glm::rotate(glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.5f)), textureGround);
|
//drawObjectTexture(terrainContext, glm::translate(glm::vec3(0, -20, 0)) * glm::rotate(glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.5f)), textureGround);
|
||||||
drawObjectTexture(terrainContext, glm::translate(glm::vec3(130, -20, 0)) * glm::rotate(glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.5f)), textureGround);
|
//drawObjectTexture(terrainContext, glm::translate(glm::vec3(130, -20, 0)) * glm::rotate(glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.5f)), textureGround);
|
||||||
drawObjectTexture(terrainContext, glm::translate(glm::vec3(-130, -20, 0)) * glm::rotate(glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.5f)), textureGround);
|
//drawObjectTexture(terrainContext, glm::translate(glm::vec3(-130, -20, 0)) * glm::rotate(glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(1.5f)), textureGround);
|
||||||
|
|
||||||
// narysuj p³ask¹ powierzchniê
|
// narysuj p³ask¹ powierzchniê
|
||||||
//drawPlaneTexture(planeContext, glm::rotate(glm::radians(120.f), glm::vec3(1.f, 1.f, 1.f)), textureGround);
|
drawPlaneTexture(planeContext, glm::rotate(glm::radians(120.f), glm::vec3(1.f, 1.f, 1.f)), textureGround);
|
||||||
|
|
||||||
// rysowanie skyboxa
|
// rysowanie skyboxa
|
||||||
drawObjectSkybox(skyboxContext);
|
drawObjectSkybox(skyboxContext);
|
||||||
@ -441,7 +441,7 @@ void init()
|
|||||||
textureFish = Core::LoadTexture("textures/TropicalFish01.jpg");
|
textureFish = Core::LoadTexture("textures/TropicalFish01.jpg");
|
||||||
textureBubble = Core::LoadTexture("textures/bubble.png");
|
textureBubble = Core::LoadTexture("textures/bubble.png");
|
||||||
textureShip = Core::LoadTexture("textures/txt-subm-1.jpg");
|
textureShip = Core::LoadTexture("textures/txt-subm-1.jpg");
|
||||||
textureGround = Core::LoadTexture("textures/terrain.jpg");
|
textureGround = Core::LoadTexture("textures/ground.jpg");
|
||||||
|
|
||||||
// SKYBOX
|
// SKYBOX
|
||||||
// Create VAO, VBO, and EBO for the skybox
|
// Create VAO, VBO, and EBO for the skybox
|
||||||
|
Loading…
Reference in New Issue
Block a user