albedo with refractions and reflactions of the cubemap
This commit is contained in:
parent
4f4eb2f496
commit
71c942d88e
18
shader.fs
18
shader.fs
@ -19,24 +19,20 @@ const float diamond_ri = 2.42;
|
||||
void main()
|
||||
{
|
||||
// Regular shading
|
||||
FragColor = texture( texture_diffuse1, TexCoords) ;
|
||||
vec4 albeno = texture( texture_diffuse1, TexCoords) ;
|
||||
|
||||
|
||||
// Reflective shading
|
||||
/*
|
||||
vec3 I = normalize(Position - cameraPos);
|
||||
vec3 R = reflect(I, normalize(Normal));
|
||||
|
||||
FragColor = vec4(texture(skybox,R).rgb, 1.0);
|
||||
*/
|
||||
|
||||
vec4 reflections = vec4(texture(skybox,R).rgb, 1.0);
|
||||
|
||||
// Refractive shading
|
||||
/*
|
||||
float ratio = air_ri/water_ri;
|
||||
vec3 I = normalize(Position-cameraPos);
|
||||
vec3 R = refract(I, normalize(Normal), ratio);
|
||||
FragColor = vec4(texture(skybox, R).rgb, 1.0);
|
||||
*/
|
||||
float ratio = air_ri/diamond_ri;
|
||||
vec3 I2 = normalize(Position-cameraPos);
|
||||
vec3 R2 = refract(I2, normalize(Normal), ratio);
|
||||
vec4 refractions = vec4(texture(skybox, R2).rgb, 1.0);
|
||||
|
||||
FragColor = vec4(albeno.rgb + (refractions.rgb * 0.5) + (reflections.rgb * 0.8), 1.0);
|
||||
}
|
@ -10,7 +10,9 @@ Cubemap::~Cubemap(){
|
||||
}
|
||||
|
||||
void Cubemap::Bind(){
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
|
||||
|
||||
};
|
||||
|
||||
void Cubemap::Unbind(){
|
||||
|
@ -188,12 +188,17 @@ void Skybox_pass (GLuint& SkyboxVAO, Shader& skyboxShader, Cubemap& skycubemap)
|
||||
void drawScene_pass(Shader& shader, Model& Object, Cubemap& skybox)
|
||||
{
|
||||
shader.use();
|
||||
|
||||
shader.setVec3("cameraPos", camera.Position);
|
||||
|
||||
glActiveTexture(GL_TEXTURE11);
|
||||
skybox.Bind();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
|
||||
shader.setMat4("model", model);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setInt("skybox",11);
|
||||
|
||||
Object.Draw(shader);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user