raytk icon indicating copy to clipboard operation
raytk copied to clipboard

shader export (ShaderToy, ISF, etc)

Open t3kt opened this issue 5 years ago • 2 comments

Consolidate a network of rops into a self-contained shader that can be used without the raytk framework. ShaderToy export would require switching the params to global constants / macros. ISF export would let parameters be specified as actual parameters.

t3kt avatar Nov 21 '20 22:11 t3kt

ENHANCEMENTS - EXPORT TO ISF / SYNAESTHESIA

when a user selects “expose parameter” in the shift-alt-r menu

  • Add “export” button in a new export tab on the parent component

When the export button is hit:

  • Construct a JSON header in ISF format :
  • Parse the parent component 'Scene" tab parameters : type, name, label, min, max, and default values can be directly used in constructing the exported ISF JSON header,
  • convert the active RayTK shader uniforms into const, imternal variables, defines, and whatever else is needed to preserve the integrity of the functionality where possible

The ISF format is: JSON header that can be directly generated from the parent TOX : “NAME” - string to be used for the name of the uniform “MIN” - for the minimum value range “MAX” - for the maximum value range And “DEFAULT” - for the default value upon loading And “TYPE” - for the type of uniform input being defined

When a Texture input is exposed from the raytk shift-alt-r options menu - generate a sampler2d uniform and corresponding parent component input with the textures connected switch for cube map option? Solution for fields or other complex inputs?

  • [ ] LFO - gets converted to glsl LFO (with tempo sync option?)
  • [ ] Speed - gets converted to TIME * Speed
  • [ ] New Envelope modulator, attack decay
  • [ ] ( possibly useful : also have a "slide" shader that functions like attack / decay of complex TOP inputs, very useful for spectrum smoothing an envelope smoothing of a spectrum : Slide ISF shader)

ISF Outputs - ISF format supports render passes, any enabled raytk 3D render output passes as render passes in the ISF

To facilitate this

  • [ ] Add if then for each pass
  • [ ] Add JSON with pass name/info
  • [ ] Create RayTK nodes for GLSL based 2D compositing internally - composite modes like add (+) and Multiply (*) etc :
  • [ ] PhotoshopMath.GLSL
  • [ ] Create raytk GLSL based brightness, contrast, saturation, levels, gamma node (also included in the above GLSL link from my dropbox)
  • [ ] Matte can be done with alpha
  • [ ] Depth of field / bokeh blur

Useful references: ISF SPEC README GITHUB Converting non ISF GLSL shaders to ISF

MacroMachines avatar May 08 '25 21:05 MacroMachines

For time-based things, there is already a system for that with the lfoField and timeField. They depend on a set of uniforms which could be replaced with aliases.

For texture inputs maybe there could be a setting that gets saved in the config table indicating that a specific textureFields should be replaced with host-provided inputs.

I'd like to remove the expose parameter dialog in general since it's largely covered by FunctionStore tools. But maybe we could replace it with a more specialized UI for export. There would need to be some sort of storage for metadata about the parameters within the scene. That could be in a config table DAT or something. We'll need to the parse that, validate it, and link scene parameters to the relevant operator parameters. We will also need a UI for validation results in general since there will inevitably be scenarios where people try to export scenes that contain unsupported stuff. So maybe we have an export dialog that creates/edits that table, runs validation, shows the results, and executes the export process.

The render pass system sounds like it would add a lot of complexity. There would need to be new operators for compositing which would only really be useful for export since that could all be done with a composite TOP in touch. It would also need to be able to compile not just one but multiple full scene shaders and merge them into a single shader without conflicts between globally declared symbols. So maybe we skip that for now.

t3kt avatar May 12 '25 21:05 t3kt