create_shader_from_code
Read create-shaders Skill first. Create a Web effect/transition library asset from inline TypeScript and editable properties; apply with edit_item when requested.
Effects extend EffectProcessor and process one input texture. Transitions extend TransitionProcessor and combine outgoing/incoming textures. Both implement initialize(ctx) and render(ctx), use ctx.compileShader/ctx.renderPass, and return a WebGLTexture. WebGL2 only: no React/JSX, HTML or Desktop Flux API. Read create-shaders for the renderer contract.
initialize(ctx): ctx.compileShader({id, fragmentShader, vertexShader?}). Pass ONE object, never compileShader(id, source); the key is fragmentShader, not fragment. GLSL may be an inline string or a local const string. render(ctx): return ctx.renderPass({id, textures, uniforms?}) using the same id. Effect textures: {u_input:ctx.inputTexture}; transition textures: {u_outgoing:ctx.outgoingTexture,u_incoming:ctx.incomingTexture}, uniforms: {u_progress:ctx.progress}. GLSL ES 300 needs #version 300 es, float precision, out vec4 and void main().
Without vertexShader, the fragment input is in vec2 v_texCoord, not v_uv. A custom varying requires a matching name and type in this pass's explicit vertexShader output; another pass's vertex shader does not supply it.
Read source: inspect_asset includeCode:true. Update source, properties or declarations: edit_asset action:update with inline json. Shader controls are number, boolean, color, select, vec2, font and text; image/video asset properties belong to MG and caption code. Effects can use ctx.textMask for text alpha textures; see code. Preview retries pending fonts and export awaits them. No DOM/font fetching in authored code. Effects may declare Web special-effect protocols; transitions do not receive them. Validation precedes persistence. Verify the saved asset, placement and pixels after authoring.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"type": "<type>",
"code": "<code>",
"name": "<name>"
},
"name": "create_shader_from_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Full inline TypeScript class, without imports, exports, constructor, getMetadata or external I/O. Exactly one EffectProcessor or TransitionProcessor subclass. In initialize(ctx), call ctx.compileShader({id,fragmentShader,vertexShader?}) with ONE object; fragmentShader is an inline GLSL ES 300 string or local const string, not the key fragment or a positional source argument. Without vertexShader, declare in vec2 v_texCoord, not v_uv. Custom varying names and types must match this pass's explicit vertexShader outputs. render(ctx) returns ctx.renderPass({id,textures,uniforms?}) with the same compiled id. Effect textures: {u_input:ctx.inputTexture}; transition textures: {u_outgoing:ctx.outgoingTexture,u_incoming:ctx.incomingTexture}, uniforms include u_progress:ctx.progress. Editable values are ctx.properties. Never pass React, a path or Desktop HTML. Effects can call ctx.textMask({text,fontFamily,fontSize,fontWeight?,fontVariant?,maxWidth?,x?,y?,align?,lineHeight?}) for a host-prepared alpha texture. Coordinates use top-left output pixels; x/y center text by default. | |
| name | Yes | Library asset display name. | |
| type | Yes | Processor kind; must match the base class in code. | |
| projectId | No | Project for this call (full ID or unambiguous prefix). Explicit-timeline calls never change the target of later calls; legacy project selection applies otherwise. | |
| properties | No | Editable shader definitions. Each contains key,label,type,defaultValue; numeric controls may include min,max,step; select requires options; vec2 uses [x,y]. These defaults are persisted on the asset and overridden by applied item.propertyOverrides. | |
| timelineId | No | ||
| description | No | ||
| chatcutSpecialEffectUsed | No | Optional Web-only media-analysis declarations. Omit for ordinary MG/effect/caption work and preserve existing values on unrelated revisions. Transitions and Desktop do not support these readers. caption_v1 is private to caption-owned code. |