You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-3Lines changed: 49 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,8 +87,12 @@ def wave(p=2, i=0):
87
87
again(wave, p=2, i=i+1)
88
88
```
89
89
90
-
> Note: for now only the float and integer datatypes are supported ('f' and 'i').
91
-
> The default datatype is float, hence it is not necessary to specify it.
90
+
The currently supported datatypes are:
91
+
-`f`: float
92
+
-`i`: int
93
+
-`t`: texture.
94
+
95
+
> Note: the default datatype is float, hence it is not necessary to specify it.
92
96
93
97
### Shader live-coding
94
98
@@ -97,12 +101,54 @@ The `claude_server` application has a few configuration options that can be deta
97
101
python -m claude_server -h
98
102
```
99
103
100
-
The two most important options are `--res` and`--frag`, which allow you to pass in and use your own fragment shader.
104
+
The most important option is`--frag`, which allow you to pass in and use your own fragment shader.
101
105
102
106
Claude is designed for live-coding: you can edit your fragment shader while Claude is running, and every time you save it Claude will update its content.
103
107
104
108
Feel free to use the [template shader](resources/template.frag) and [utilities](resources/utils/glsl) provided.
105
109
110
+
### Advanced workflows
111
+
112
+
#### Textures
113
+
114
+
2D textures can be passed to Claude when launching the application by providing a texture folder with the `--tex` option.
115
+
116
+
The file structure must be organized into image packs like this:
117
+
```
118
+
textures
119
+
|_ foo
120
+
| |_ foo1.png
121
+
| |_ foo2.png
122
+
| |_ ...
123
+
|_ bar
124
+
|_ some_bar.jpg
125
+
|_ another_bar.jpg
126
+
|_ ...
127
+
```
128
+
129
+
To access textures in your fragment shader, use a 2D sampler: `uniform sampler2D img;`.
130
+
131
+
Then you can modify the texture referenced by the 2D sampler from a client by using the `t` datatype and the `img_pack:img_index` syntax:
132
+
```python
133
+
@swim
134
+
defanimate(p=1, i=0):
135
+
Claude('img', 'foo:[0:10]', dt='t', i=i)
136
+
again(animate, p=1, i=i+1)
137
+
```
138
+
139
+
> Note: all the images in the input texture folder will be loaded into memory, make sure you do not exceed memory limits.
140
+
141
+
#### Time catching
142
+
143
+
The idea of time catching is to capture the value of the rendering loop time at a given moment and store it into a uniform variable.
144
+
145
+
To access this rendering loop time from a client, use the `cldtime` syntax.
146
+
147
+
This feature is quite useful to create animations:
148
+
- add a float uniform to your shader that will capture time values: `uniform float tReset = 0.;`
149
+
- send time catching messages from a Sardine swim function: `Claude('tReset', 'cldtime', i=i)`
150
+
- use this to animate a property in your shader whenever the time is reset: `prop = mix(p0, p1, 1.-exp(tReset-time));`.
151
+
106
152
## Contributions
107
153
108
154
Claude is at an early development stage, and we're actively seeking contributors to help enhance the project.
0 commit comments