Not logged inOpenClonk Forum
Up Topic General / Feedback and Ideas / Shaders per texture
- - By Newton [de] Date 2016-01-19 20:08 Edited 2016-01-19 20:11
I have an idea about where to go from now regarding the textures and light system we have in place.

I'd like to propose to make it possible to define a custom shader (slice) for each texture, i.e. the engine would test if there is a file called lava_red.c in the Material.ocg next to the lava_red.jpg, if there is, the shader is applied for this texture.
This'd create a straightforward framework to make many (slightly) different shaders for all the different kinds of textures¹ and would remove the necessity to define shader parameters in the OCM material definition and thus also remove the necessity that shaders like the shiny gold be implemented centrally.

Reason:
When I looked at Hideout.ocs, I noticed that the shiny effect of the gemstones cannot be applied to the background gemstones. Why? Because I have to specify those shininess parameters in the OCM material definition and not per texture. And the material is Tunnel - I do not want the normal tunnel to shine. Of course there is a workaround for that - simply create an own material for the background gemstones.

But that fact made me contemplate about what belongs to a texture definition and what belongs to a material definition. I think the best definition is that the material definition defines the behaviour of the material in the game world while the textures define the visuals of the material, how it looks like. But the shininess of the material is something visual, so I guess it is only in the OCM because there is not such a thing as a texture definition file.

What do you think of that? Do you think it is technically feasible?

¹ lava noise, firestone glow, bubbles in the acid, wavy reflection-things in the water, ...
Parent - - By PeterW [gb] Date 2016-01-19 20:13 Edited 2016-01-19 20:16
Unfortunately, not quite as easy as it might seem - the whole landscape is just one big textured rectangle as far as rendering is concerned. To implement this we would either have to sub-divide this big rectangle first (and/or make multiple passes) or combine the different shaders into one big shader.

Maybe create a different material definition for shiny Tunnel? The thing is - the engine passes the shininess parameters to the engine per material-texture combination, so technically it would be easy to make the shader do the right thing. However, the "proper" place for this would now be the TexMap, which doesn't exactly have an extensible format...
Parent - - By Newton [de] Date 2016-01-19 20:17
Too bad. And would the second option be possible if the texture shaders were written in a special way? I.e. the shader is compiled into the "whole shader" but somehow skipped for other textures than the one it is written for.
Parent - By PeterW [gb] Date 2016-01-19 20:28
Would basically boil down to generating a big "if". Possible, but the applications you listed don't quite convince me that we need this - you should be able to implement most of them fairly well using texture animations (especially animated normal maps) and existing material properties.
Parent - By Sven2 [us] Date 2016-01-19 21:30
From a scripters point-of-view that seems nice, but performance-wise having a ton of ifs in the shader is probably bad. It might be better to divide drawing into several passes then.

It would be cool to have multiple passes for stuff like e.g. semi-transparent water drawn on top of clonks anyway (obviously, this should be optional and turned off automatically when the drawing frame rate is low).
Up Topic General / Feedback and Ideas / Shaders per texture

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill