Environment map reflections (fake)

Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Darkcrafter
Posts: 537
Joined: Sat Sep 23, 2017 8:42 am
Graphics Processor: nVidia with Vulkan support

Environment map reflections (fake)

Post by Darkcrafter »

Code: Select all

//Fake simple environment map reflection shader mod by Darkcrafter_VTar
//Based on Elementalism water shader made in a Marisa shader fashion
//This time allows mixing base texture and reflections
//material.Base * by a decimal value - adjusts brightness of base texture (albedo)
//addEnv * by a decimal value - adjust brightness of a reflective texture (fake env map)

Material material;

void SetupMaterial(inout Material material)
{

    vec2 texCoord = vTexCoord.st;

    material.Base = getTexel(texCoord);

	vec4 addEnv = texture(tex_envmap, (normalize(uCameraPos.xyz - pixelpos.xyz).xy));

	material.Base = (material.Base*0.7) + (addEnv*0.3);

}
GLDEFS implementation for a regular game texture:

Code: Select all

material texture "DEM1_5"
{
    Shader "shaders/EnvMapReflFake.gl"
	texture tex_envmap "Textures/Environments/Your_Environment_Map_Name.jpg"
}
GLDEFS implementation for a 3D model texture:

Code: Select all

material texture "Models/Floors/DEM1_5_On_My_Model.png"
{
    Shader "shaders/EnvMapReflFake.gl"
	texture tex_envmap "Textures/Environments/Your_Environment_Map_Name.jpg"
}
Looking forward to improve the shader with a reflection map mask.

The shader example, short test map, screenshot here

Return to “Shaders”