Pixel-Composer/shaders/sh_d3d_geometry/sh_d3d_geometry.fsh
2023-12-07 21:08:09 +07:00

25 lines
748 B
GLSL

varying vec2 v_vTexcoord;
varying vec4 v_worldPosition;
varying vec3 v_viewPosition;
varying vec3 v_vNormal;
uniform int mat_flip;
uniform int use_normal;
uniform int use_8bit;
uniform float normal_strength;
uniform sampler2D normal_map;
void main() {
vec2 uv_coord = v_vTexcoord;
if(mat_flip == 1) uv_coord.y = -uv_coord.y;
vec4 mat_baseColor = texture2D( gm_BaseTexture, uv_coord );
if(mat_baseColor.a < 0.1) discard;
vec3 normal = v_vNormal;
if(use_normal == 1) normal += (texture2D(normal_map, uv_coord).rgb * 2. - 1.) * normal_strength;
gl_FragData[0] = vec4(v_worldPosition.xyz, mat_baseColor.a);
gl_FragData[1] = vec4(v_viewPosition, mat_baseColor.a);
gl_FragData[2] = vec4(normalize(normal), mat_baseColor.a);
}