X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=tests%2Fglsl%2Freturn_type_conversion.glsl;fp=tests%2Fglsl%2Freturn_type_conversion.glsl;h=3467311c5192290acad27b72afdacf2a4617ad43;hb=f661973abaa7d189a61d76708d0c90cfcdb4b440;hp=0000000000000000000000000000000000000000;hpb=282a10854eda602d874e200c8301cf57d6501e81;p=libs%2Fgl.git diff --git a/tests/glsl/return_type_conversion.glsl b/tests/glsl/return_type_conversion.glsl new file mode 100644 index 00000000..3467311c --- /dev/null +++ b/tests/glsl/return_type_conversion.glsl @@ -0,0 +1,78 @@ +uniform Shadow +{ + mat4 shadow_matrix; +}; +uniform Camera +{ + mat4 viewproj_matrix; +}; +uniform Surface +{ + vec4 color; +}; +uniform mat4 model_matrix; +uniform sampler2DShadow shadow_map; + +#pragma MSP stage(vertex) +layout(location=0) in vec4 position; +void main() +{ + out vec4 world_position = model_matrix*position; + gl_Position = viewproj_matrix*world_position; +} + +#pragma MSP stage(fragment) +layout(location=0) out vec4 frag_out; +float get_shadow() +{ + vec3 shadow_coord = (shadow_matrix*world_position).xyz; + if(shadow_coord.x>=0 && shadow_coord.x<=1 && shadow_coord.y>=0 && shadow_coord.y<=1) + return texture(shadow_map, shadow_coord); + else + return 1; +} +void main() +{ + frag_out = vec4(color.rgb*get_shadow(), color.a); +} + +/* Expected output: vertex +layout(binding=72) uniform Camera +{ + mat4 viewproj_matrix; +}; +layout(location=0) uniform mat4 model_matrix; +layout(location=0) in vec4 position; +layout(location=0) out vec4 world_position; +void main() +{ + world_position = model_matrix*position; + gl_Position = viewproj_matrix*world_position; +} +*/ + +/* Expected output: fragment +layout(binding=71) uniform Shadow +{ + mat4 shadow_matrix; +}; +layout(binding=77) uniform Surface +{ + vec4 color; +}; +layout(location=4, binding=73) uniform sampler2DShadow shadow_map; +layout(location=0) out vec4 frag_out; +layout(location=0) in vec4 world_position; +float get_shadow() +{ + vec3 shadow_coord = (shadow_matrix*world_position).xyz; + if(shadow_coord.x>=0.0&&shadow_coord.x<=1.0&&shadow_coord.y>=0.0&&shadow_coord.y<=1.0) + return texture(shadow_map, shadow_coord); + else + return 1.0; +} +void main() +{ + frag_out = vec4(color.rgb*get_shadow(), color.a); +} +*/