1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "common/core.h"
/*uniforms*/
#define _object2world UM4(0)
#define _light UV3(0)
#define _albedo_tex UTEX(0)
#define _noraml_tex UTEX(1)
#define _roughness_tex UTEX(2)
#define _metalness_tex UTEX(3)
/*varyings*/
#define _texcoord reg_v2_00
#define _normal reg_v3_05
#define _rough reg_num_00
#define _world_pos reg_v3_00
#define _depth_pos reg_v3_01
#define _clip_pos reg_v2_01
#define _world_normal reg_v3_02
#define _world_tangent reg_v3_03
#define _world_bitangent reg_v3_04
static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) {
static Vec4 p; p.xyz = in->vertex->position; p.w = 1;
object2clip(&p, clipcoord);
Vec3 worldnormal = mat4_mulvec3(*_object2world, in->vertex->normal);
worldnormal = vec3_normalize(worldnormal);
//*rough = 1 - internal_vec3_dot(&worldnormal, light);
//*vnormal = in->vertex->normal;
*_texcoord = in->vertex->texcoord;
_clip_pos->x = clipcoord->z;
_clip_pos->y = clipcoord->w;
}
static bool frag(UniformCollection* uniforms, Vec4* color) {
//internal_vec3_normalize(light, light);
//internal_vec3_normalize(vnormal, vnormal);
//float roughness = *rough;
//(*color).r = 1;
//(*color).g = 1;
//(*color).b = 1;
//(*color).a = 1;
//return 1;
//float rough = 1- internal_vec3_dot(&in->normal, light);
float depth = _clip_pos->x / _clip_pos->y;
depth = (depth + 1) / 2;
depth = linear01Depth(depth);
Vec4 c = tex2d(_albedo_tex, _texcoord);
//Color32 nc = tex2d(noramltex, in->texcoord);
//internal_vec3_scale(&c, roughness, &c);
*color = vec4_saturate(c);
//*color = vec4(depth, depth, depth, 1);
//internal_vec3_scale(color, 1 - depth, color);
return 1;
}
Program ssr_built_in_shader_pbr = {
vert, frag,
VARYING_NUM_00 |
//VARYING_V3_00 |
//VARYING_V3_01 |
//VARYING_V3_02 |
//VARYING_V3_03 |
//VARYING_V3_04 |
//VARYING_V4_00 |
VARYING_V2_00 |
VARYING_V3_05 |
VARYING_V2_01
};
|