Pixel-Composer/shaders/sh_d3d_geometry/sh_d3d_geometry.fsh

25 lines
748 B
Text
Raw Normal View History

2023-08-30 16:40:45 +02:00
varying vec2 v_vTexcoord;
2023-08-28 12:56:00 +02:00
varying vec4 v_worldPosition;
varying vec3 v_viewPosition;
varying vec3 v_vNormal;
uniform int mat_flip;
2023-08-30 16:40:45 +02:00
uniform int use_normal;
2023-12-06 13:51:22 +01:00
uniform int use_8bit;
2023-08-30 16:40:45 +02:00
uniform float normal_strength;
uniform sampler2D normal_map;
2023-08-28 12:56:00 +02:00
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 );
2023-10-06 11:51:11 +02:00
if(mat_baseColor.a < 0.1) discard;
2023-08-30 16:40:45 +02:00
vec3 normal = v_vNormal;
if(use_normal == 1) normal += (texture2D(normal_map, uv_coord).rgb * 2. - 1.) * normal_strength;
2023-08-30 16:40:45 +02:00
2023-12-06 13:51:22 +01:00
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);
2023-08-28 12:56:00 +02:00
}