Skip to content

Commit e6699b4

Browse files
committed
update README.md
1 parent 72b6ef6 commit e6699b4

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

README.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ def wave(p=2, i=0):
8787
again(wave, p=2, i=i+1)
8888
```
8989

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.
9296
9397
### Shader live-coding
9498

@@ -97,12 +101,54 @@ The `claude_server` application has a few configuration options that can be deta
97101
python -m claude_server -h
98102
```
99103

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.
101105

102106
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.
103107

104108
Feel free to use the [template shader](resources/template.frag) and [utilities](resources/utils/glsl) provided.
105109

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+
def animate(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+
106152
## Contributions
107153

108154
Claude is at an early development stage, and we're actively seeking contributors to help enhance the project.

0 commit comments

Comments
 (0)