Closed greenfork closed 4 weeks ago
https://shirakumo.github.io/trial/shaders.html
This code:
(define-shader-entity my-object (vertex-entity) ()) (define-class-shader (my-object :fragment-shader) "out vec4 color; void main(){ color = vec4(0, 1, 0, 1); }") (compute-effective-shaders (find-class 'my-object))
Does not result in
(:VERTEX-SHADER "layout(location = 0) in vec3 position; uniform mat4 model_matrix; uniform mat4 view_matrix; uniform mat4 projection_matrix; void _GLSLTK_main_1(){ gl_Position = (projection_matrix * (view_matrix * (model_matrix * vec4(position, 1.0)))); } void main(){ _GLSLTK_main_1(); }" :FRAGMENT-SHADER "out vec4 color; void _GLSLTK_main_primary_1(){ color = vec4(1.0, 1.0, 1.0, 1.0); } void _GLSLTK_main_1(){ color = vec4(0, 1, 0, 1); } void main(){ _GLSLTK_main_1(); }")
and instead results in:
(:VERTEX-SHADER ((GLSL-TOOLKIT:SHADER (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER (GLSL-TOOLKIT:LAYOUT-QUALIFIER (GLSL-TOOLKIT:LAYOUT-QUALIFIER-ID "location" 0)) :IN) (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC3) "position" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :UNIFORM) (GLSL-TOOLKIT:TYPE-SPECIFIER :MAT4) "model_matrix" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :UNIFORM) (GLSL-TOOLKIT:TYPE-SPECIFIER :MAT4) "view_matrix" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :UNIFORM) (GLSL-TOOLKIT:TYPE-SPECIFIER :MAT4) "projection_matrix" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :OUT) (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC3) "v_world_position" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :OUT) (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC3) "v_view_position" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:FUNCTION-DEFINITION (GLSL-TOOLKIT:FUNCTION-PROTOTYPE GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:TYPE-SPECIFIER :VOID) "main") (GLSL-TOOLKIT:COMPOUND-STATEMENT (GLSL-TOOLKIT:MODIFIED-REFERENCE "maybe_call_next_method" (GLSL-TOOLKIT:CALL-MODIFIER)) (GLSL-TOOLKIT:VARIABLE-DECLARATION GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC4) "world_position" GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:MULTIPLICATION "model_matrix" (GLSL-TOOLKIT:MODIFIED-REFERENCE :VEC4 (GLSL-TOOLKIT:CALL-MODIFIER "position" 1.0)))) (GLSL-TOOLKIT:VARIABLE-DECLARATION GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC4) "view_position" GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:MULTIPLICATION "view_matrix" "world_position")) (GLSL-TOOLKIT:ASSIGNMENT "gl_Position" := (GLSL-TOOLKIT:MULTIPLICATION "projection_matrix" "view_position")) (GLSL-TOOLKIT:ASSIGNMENT "v_world_position" := (GLSL-TOOLKIT:MODIFIED-REFERENCE "world_position" (GLSL-TOOLKIT:FIELD-MODIFIER "xyz"))) (GLSL-TOOLKIT:ASSIGNMENT "v_view_position" := (GLSL-TOOLKIT:MODIFIED-REFERENCE "view_position" (GLSL-TOOLKIT:FIELD-MODIFIER "xyz"))))))) :FRAGMENT-SHADER ((GLSL-TOOLKIT:SHADER (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :OUT) (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC4) "color" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:FUNCTION-DEFINITION (GLSL-TOOLKIT:FUNCTION-PROTOTYPE GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:TYPE-SPECIFIER :VOID) "main") (GLSL-TOOLKIT:COMPOUND-STATEMENT (GLSL-TOOLKIT:ASSIGNMENT "color" := (GLSL-TOOLKIT:MODIFIED-REFERENCE :VEC4 (GLSL-TOOLKIT:CALL-MODIFIER 1.0 1.0 1.0 1.0)))))) (GLSL-TOOLKIT:SHADER (GLSL-TOOLKIT:VARIABLE-DECLARATION (GLSL-TOOLKIT:TYPE-QUALIFIER :OUT) (GLSL-TOOLKIT:TYPE-SPECIFIER :VEC4) "color" GLSL-TOOLKIT:NO-VALUE) (GLSL-TOOLKIT:FUNCTION-DEFINITION (GLSL-TOOLKIT:FUNCTION-PROTOTYPE GLSL-TOOLKIT:NO-VALUE (GLSL-TOOLKIT:TYPE-SPECIFIER :VOID) "main") (GLSL-TOOLKIT:COMPOUND-STATEMENT (GLSL-TOOLKIT:ASSIGNMENT "color" := (GLSL-TOOLKIT:MODIFIED-REFERENCE :VEC4 (GLSL-TOOLKIT:CALL-MODIFIER 0 1 0 1))))))))
The doc example is not keeping up with the code.
try
(shader-source (make-instance 'my-object))
https://shirakumo.github.io/trial/shaders.html
This code:
Does not result in
and instead results in: