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.
User avatar
Darkcrafter
Posts: 562
Joined: Sat Sep 23, 2017 8:42 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Environment map reflections (fake)

Post by Darkcrafter »

Code: Select all

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
Last edited by Darkcrafter on Thu Dec 21, 2023 11:26 am, edited 1 time in total.
User avatar
DELTAtheDboi005
Posts: 218
Joined: Tue Apr 05, 2022 3:43 am
Preferred Pronouns: He/Him

Re: Environment map reflections (fake)

Post by DELTAtheDboi005 »

This looks quite nifty! if I use this, I'll be sure to credit you :)
User avatar
Darkcrafter
Posts: 562
Joined: Sat Sep 23, 2017 8:42 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Environment map reflections (fake)

Post by Darkcrafter »

Thanks, later on I'll share a water shader which is also done in a similar way but with ripple distortions, maybe also derived from someone else (Marisa) shader pack.

https://imgur.com/a/XcyvY9I

Return to “Shaders”