I try to make an alternative main battery for Asgard where I want to include a singularity/black hole as eye candy, but I'm stuck on creating a good looking black hole. I knew nothing about shader before but I have read some basics about it on the internet after starting this project. Hope someone in this forum can help me with it. Here are my two questions (sorry they are quite long):
Question 1: What is the correspondence between in game distance and the depth value accessed in the shader from the texture T_maindepth_mips?
Description: To create the black hole effects I use screen space ray tracing in the shader. If a ray propagates some long distance without hitting anything, then I want to terminate tracing and use
environment map instead. So I write something like this
Spoiler
Show
Code: Select all
float hit_z = texelFetch(T_maindepth_mips, uv, 0).x;
if (hit_z < 0)
{
OUT_Color.a=1;
OUT_Color.rgb = textureLod(T_ibl_envmap, out_dir, 0).rgb;
return;
}
[the rest of the code]
Spoiler
Show
Code: Select all
float hit_z = texelFetch(T_maindepth_mips, uv, 0).x;
if (hit_z < 0.000001)
{
OUT_Color.a=1;
OUT_Color.rgb = textureLod(T_ibl_envmap, out_dir, 0).rgb;
return;
}
[the rest of the code]
Question 2: Is it possible to retrieve the glow color from gbuffer?
Description: This is the function I used in the shader to return colors
Spoiler
Show
Code: Select all
vec4 Col_out(vec2 uv)
{
vec3 NORMAL;
RETRIEVE_GBUFFER_UV_NORMAL0(uv, NORMAL);
vec4 col = textureLod(T_gbuffer2, uv, 0);
vec3 view_pos;
RetrieveZBufferViewPos(view_pos, uv);
float SMOOTH = 0;
float METAL = 0;
vec3 GLOW = vec3(0);
col.rgb = GLOW + global_lights(NORMAL, view_pos, col.rgb, METAL, smooth2rough(SMOOTH), false);
col.a=1;
// col.rgb = textureLod(T_maincolor_last, uv, 0).rgb;
return col;
}
Thanks for your patience for reading these loooong questions. If you need I can also provide all the mod files, though they are still highly WIP.