Anonymous Login
2021-09-24 15:01 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001206OpenClonkEngine - C4Scriptpublic2016-11-12 23:28
Assigned ToLuchs 
Product Version 
Target VersionFixed in Version8.0 
Summary0001206: Script functions to affect shaders at runtime
DescriptionIt's already possible to overload shaders in local Graphics.ocg files in scenarios. This potentially offers great possibilities for scenario authors to create special effects. However, you cannot really control them at runtime by script. I would like to see:
* Functions to set variables in the shader from script
* Options to have multiple sets of shaders which differ by values for #defines and between which you can switch.
TagsNo tags attached.
Attached Files




Luchs (administrator)

I added AddFragmentShader() [1] which allows adding (and also removing) shader slices during runtime. It could be used for the second point, although it involves re-compiling the shader on each switch.



occ (reporter)

Hi! There's been a check-in that references this bug. For more information you can visit the repository browser at this address:

Changeset 6847e50 by Lukas Werling <>
Implement setting shader uniforms from script (0001206)

Uniform variables are read from the "Uniforms" proplist set on Scenario
or on individual objects. Proplist keys are uniform names. Values can
either be an int or an array of one to four ints in C4Script. In GLSL,
the uniforms then need a matching type (int/ivec2/ivec3/ivec4). There is
no error reporting; uniforms are only set if both name and type match.

The implementation walks the "Uniforms" proplists on each Draw call. We
may need to cache the uniform maps if this turns out to be too slow.


Luchs (administrator)

It's now possible to load custom shaders and to set uniforms globally, per definition, or per object. This should be enough for most graphical effects, I think.

-Issue History
Date Modified Username Field Change
2015-01-01 20:19 Sven2 New Issue
2016-10-30 11:45 Luchs Note Added: 0005476
2016-10-30 11:46 Luchs Status new => acknowledged
2016-11-12 21:10 occ Note Added: 0005490
2016-11-12 23:28 Luchs Assigned To => Luchs
2016-11-12 23:28 Luchs Status acknowledged => resolved
2016-11-12 23:28 Luchs Resolution open => fixed
2016-11-12 23:28 Luchs Fixed in Version => 8.0
2016-11-12 23:28 Luchs Note Added: 0005491
+Issue History