RuntimeData/shader/gbuffer intro.txt
2020-05-22 19:59:34 +08:00

46 lines
1.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[attr] //该段用于描述该材质最终会需要那些数据
vec3 BaseColor;
vec3 Normal;
float Metallic;
float Roughness;
[framebuffer] //该段用于描述当前shader会输出到几个Framebuffer上
//如果是前向渲染一般只有一个Framebuffer
vec4 FinalColor;
//如果是延迟渲染则代表GBuffer可能存在多个framebuffer
vec4 gb_color_metallic;
vec4 gb_normal_roughness;
[attr_to_fb] //该段用于描述attr如何转换到framebuffer上
//如果是UI之类直接上色的那会比较颜色
FinalColor=vec4(BaseColor,1.0);
//如果是前向渲染
FinalColor=BRDF(BaseColor,Normal,Metallic,Roughness);
//如果是延迟渲染
gb_color_metallic =vec4(BaseColor,Metallic);
gb_normal_roughness =vec4(Normal, Roughness);
[gb_to_attr] //该段为延迟渲染独有用于表示如何从gbuffer分解成独立数据
vec4 gb_cm=texture(gb_color_metallic,FragmentPosition);
vec4 gb_nr=texture(gb_normal_roughness,FragmentPosition);
BaseColor =gb_cm.rgb;
Metallic =gb_cm.a;
Normal =gb_nr.rgb;
Roughness =gb_nr.a;
gl_FragColor=BRDF(BaseColor,Normal,Metallic,Roughness);