How to use the outputs of GL Mesh Shader, C (color buffer) and D (depth buffer)?
I haven’t found any Grasshopper componets use C and D as inputs.
What are C and D use cases?
Actually, my purpose is to get an image drawn by a shader. I use DisplayPipeline.DrawToBitmap API to capture the viewport. It works in Grasshopper.
However, when I send the gh file to compute.rhino3d by calling Grasshopper.EvaluateDefinition, DrawToBitmap always returns 0.
I thought I could modify the souce code of ghgl and draw an image like SetupTooltip as an output of GL Mesh Shader. Is there any eaiser method?
Hi @su.eugene, I’m after the same thing, so I tried modifying ghgl as you suggested. I added a new component that accepts the C and D inputs and tries to extract the bitmap associated with them. The SolveInstance function looked like this
var id = "";
if (!DA.GetData("Id", ref id)) { return; }
var parent = Params.Input.First().Sources.First().Attributes.Parent.DocObject;
Bitmap bitmap = PerFrameCache.GetTextureImage(
parent as GLShaderComponentBase,
id.Contains("color"));
DA.SetData("Bitmap", bitmap);
At the end of the day the result was no different to your original method (DisplayPipeline.DrawToBitmap), and if I disabled the display on the shader component the output bitmaps didn’t update anyway. So I suppose it relies on the screen redrawing.
when I send the gh file to compute.rhino3d by calling Grasshopper.EvaluateDefinition, DrawToBitmap always returns 0.
Based on the finding above, I don’t think its possible to compute the shader headless - @stevebaer might be able to comment.