allow attach a whole texture cubemap to an fbo
I was following the learnopengl tutorial at https://learnopengl.com/Advanced-Lighting/Shadows/Point-Shadows
And they do say and do the following
Normally we'd attach a single face of a cubemap texture to the framebuffer object and render the scene 6 times, each time switching the depth buffer target of the framebuffer to a different cubemap face. Since we're going to use a geometry shader that allows us to render to all faces in a single pass we can directly attach the cubemap as a framebuffer's depth attachment using glFramebufferTexture:
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthCubemap, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
And I don't think this is supported in cepl atm.
Oh wow! Yeah I'm not sure if we support layered rendering https://www.khronos.org/opengl/wiki/Geometry_Shader#Layered_rendering but I definitely need to look into it Thanks!
Hmm yeah so maybe we support the glsl part, but the I don't think we support the layered attachments. I definitely need to add that
Making good progress on this. Will push a branch testing this soon
Work continues on https://github.com/cbaggers/cepl/tree/feature/layered-sets. It seems like I can make an fbo with a layered-set as an attachment now. I need to write tests for this but that means I really should add pull-g for layered-sets.
A natural thing to want to do would be to pull from a single layer-face of the layered-set but we don't (iirc) yet have a means to represent subsections of textures which means we can't get the layers from a 3d-texture.
Hmm, actually I just checked and you can't just download part of a texture anyway so maybe that is fine.
So pull-g for the whole layered-set should be fine (as we can download pixels given a mipmap level), and that would be enough for this feature to be tested. The rest will have to be moved to a separate issue
awesome! I didn't know how to hack this so I settled for shadow volumes (which uses stencil buffers which worked fine using gl: calls)
There just seems to be an issue with varjo for the geometry shader
(defun-g shadowmap-point-geom (&uniform (shadow-matrices (:mat4 6)))
(declare (output-primitive :kind :triangle-strip
:max-vertices 18))
(dotimes (face 6)
(setf gl-layer face)
(dotimes (i 3)
(let ((pos (gl-position (aref gl-in i))))
(emit () (* (aref shadow-matrices face) pos))))
(end-primitive))
(values))
Varjo: Assignment failed as GL-LAYER is readonly
[Condition of type VARJO-CONDITIONS:ASSIGNING-TO-READONLY]
Restarts:
0: [CONTINUE] Retry assertion.
1: [RETEST-ASSUMING-STAGE] VARJO.INTERNALS::RETEST-ASSUMING-STAGE
2: [RETEST-ASSUMING-VERTEX-STAGE] VARJO.INTERNALS::RETEST-ASSUMING-VERTEX-STAGE
3: [RETEST-ASSUMING-TESSELLATION-CONTROL-STAGE] VARJO.INTERNALS::RETEST-ASSUMING-TESSELLATION-CONTROL-STAGE
4: [RETEST-ASSUMING-TESSELLATION-EVALUATION-STAGE] VARJO.INTERNALS::RETEST-ASSUMING-TESSELLATION-EVALUATION-STAGE
5: [RETEST-ASSUMING-GEOMETRY-STAGE] VARJO.INTERNALS::RETEST-ASSUMING-GEOMETRY-STAGE
--more--
Backtrace:
0: (SB-KERNEL:ASSERT-ERROR (AND VARJO.INTERNALS::IS-SSBO (> (LENGTH #) 1)) NIL NIL VARJO-CONDITIONS:ASSIGNING-TO-READONLY :VAR-NAME GL-LAYER)
1: (VARJO.INTERNALS:MAKE-ENV-WITH-PLACE-MODIFICATION #<VARJO.INTERNALS:COMPILED {100B6A6903}> #<FLOW-ID 5> #<VARJO.INTERNALS::ENVIRONMENT {100B6A5F03}> (SETF GL-LAYER FACE))
2: (VARI.CL::VS-%MODIFY-PLACE #<VARJO.INTERNALS::ENVIRONMENT {100B6A5F03}> #<unused argument> SETF = GL-LAYER FACE)
3: (VARJO.INTERNALS::COMPILE-SPECIAL-FUNCTION #<V-FUNCTION VARI.CL::%MODIFY-PLACE (VARJO.INTERNALS::T*) -> #<FUNCTION VARI.CL::VS-%MODIFY-PLACE>> (SETF = GL-LAYER FACE) #<VARJO.INTERNALS::ENVIRONMENT {10..
4: (VARJO.INTERNALS::COMPILE-FUNCTION-CALL #<V-FUNCTION VARI.CL::%MODIFY-PLACE (VARJO.INTERNALS::T*) -> #<FUNCTION VARI.CL::VS-%MODIFY-PLACE>> (SETF = GL-LAYER FACE) (SETF = GL-LAYER FACE) #<VARJO.INTERN..
5: (VARJO.INTERNALS::COMPILE-CALL-WITH-SINGLE-FUNCTION #<V-FUNCTION VARI.CL::%MODIFY-PLACE (VARJO.INTERNALS::T*) -> #<FUNCTION VARI.CL::VS-%MODIFY-PLACE>> (SETF = GL-LAYER FACE) (SETF = GL-LAYER FACE) #<..
6: ((:METHOD VARJO.INTERNALS:COMPILE-FORM (T T)) (VARI.CL::%MODIFY-PLACE SETF = GL-LAYER FACE) #<VARJO.INTERNALS::ENVIRONMENT {100B6A5F03}>) [fast-method]
7: ((:METHOD VARJO.INTERNALS:COMPILE-FORM (T T)) (SETF GL-LAYER FACE) #<VARJO.INTERNALS::ENVIRONMENT {100B6A5F03}>) [fast-method]
8: (VARJO.INTERNALS:COMPILE-PROGN ((SETF GL-LAYER FACE) (DOTIMES (I 3) (LET # #)) (END-PRIMITIVE)) #<VARJO.INTERNALS::ENVIRONMENT {100B695C13}>)
Cool! And making that writable will be easy
We also need to make stencil stuff work so that can be done just using cepl