X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=tests%2Fglsl%2Fconstructors.glsl;fp=tests%2Fglsl%2Fconstructors.glsl;h=fe7ca48ab65513ad9e2ce42eec42c0be40bddbc4;hb=3f44e477f81983c66947fe8a6d8640a3b2f9e0b3;hp=0000000000000000000000000000000000000000;hpb=03880839dcd2c067061ac5491083159a9fd06611;p=libs%2Fgl.git diff --git a/tests/glsl/constructors.glsl b/tests/glsl/constructors.glsl new file mode 100644 index 00000000..fe7ca48a --- /dev/null +++ b/tests/glsl/constructors.glsl @@ -0,0 +1,58 @@ +uniform mat4 model; +uniform mat4 view_projection; +uniform vec3 light_dir; +uniform sampler2D normalmap; + +#pragma MSP stage(vertex) +layout(location=0) in vec3 position; +layout(location=1) in vec3 normal; +layout(location=2) in vec3 tangent; +layout(location=3) in vec3 binormal; +layout(location=4) in vec2 texcoord; +void main() +{ + mat3 normal_matrix = mat3(model); + mat3 tbn_matrix = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal); + out vec3 tbn_light_dir = tbn_matrix*light_dir; + gl_Position = view_projection*model*vec4(position, 1); + passthrough; +} + +#pragma MSP stage(fragment) +layout(location=0) out vec4 frag_color; +void main() +{ + vec3 normal = vec3(texture(normalmap, texcoord))*2.0-1.0; + frag_color = vec4(vec3(dot(normal, normalize(tbn_light_dir))), 1); +} + +/* Expected output: vertex +uniform mat4 model; +uniform mat4 view_projection; +uniform vec3 light_dir; +layout(location=0) in vec3 position; +layout(location=1) in vec3 normal; +layout(location=2) in vec3 tangent; +layout(location=3) in vec3 binormal; +layout(location=4) in vec2 texcoord; +out vec3 tbn_light_dir; +out vec2 _vs_out_texcoord; +void main() +{ + mat3 normal_matrix = mat3(model[0].xyz, model[1].xyz, model[2].xyz); + tbn_light_dir = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal)*light_dir; + gl_Position = view_projection*model*vec4(position, float(1)); + _vs_out_texcoord = texcoord; +} +*/ + +/* Expected output: fragment +uniform sampler2D normalmap; +layout(location=0) out vec4 frag_color; +in vec2 _vs_out_texcoord; +in vec3 tbn_light_dir; +void main() +{ + frag_color = vec4(vec3(dot(vec3(texture(normalmap, _vs_out_texcoord).xyz)*2.0-1.0, normalize(tbn_light_dir))), float(1)); +} +*/