-
Notifications
You must be signed in to change notification settings - Fork 64
Stage-level colorspace keyword for shaders #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Maybe I should add "if" to the keyword name to make it clearer that it is for conditional stages. Like |
Since the necessity of sRGB conversions is not known.
Allows making conditional stages that depend on whether naive or linear blending is used.
3493cb6
to
495777b
Compare
Renamed the keyword from |
I believe I found an use case for this! In Naive build, naive pipeline: Linear build, linear pipeline: Linear build, linear pipeline, naiveColors trick on the glass: We need to do some |
For the textures/grates/fence02
{
qer_trans 0.5
qer_editorimage textures/grates/fence02.tga
surfaceparm trans
surfaceparm nomarks
surfaceparm alphashadow
cull none
nopicmip
nomipmaps
q3map_forceMeta
q3map_lightmapsamplesize 64
if deluxe
{
material textures/grates/fence02.tga textures/grates/fence01_norm.tga textures/grates/fence01_gloss.tga
alphaFunc GE128
blendFunc blend
depthWrite
}
endif
if ! deluxe
{
map textures/grates/fence02.tga
blendfunc blend
alphaFunc GE128
depthWrite
}
{
map $lightmap
rgbGen identity
blendFunc filter
depthFunc equal
}
endif
} |
I don't see the benefit of adding a new type of syntactical construct to the shader grammar like that. (Also would it break q3map2?) Having stage enablement conditions inside the stage is more consistent with prior art in the history of our engine. For example the It's true that it may be useful to allow other conditions beside blend regime. |
That syntax completely skips the stage parsing.
Q3map2 only reads Warsow uses q3map2.
Within stages, not outside stages. |
We don't need run time switching for this specific use case. |
I see that as a bad thing. I would rather parse all the stages all the time, rather than do it C preprocessor style and allow any garbage in the stage. That way designers get immediate feedback if they make a syntax error, regardless of configuration. We can avoid unnecessary image loading by making the image loading lazier as has been discussed recently. (But this is not an urgent feature since I expect very few shaders with distinct images depending on condition.) For the image loading I think the ideal would be that it immediately checks whether a matching file exists, but does not open the file until the shader is determined to be otherwise valid. Regarding "if", I was discussing the possibility of a stage-level, load-time keyword. The point is, given that there is already an |
We can probably also use For your knowledge, that |
An example of complex material using lights/fanlightgrateSC
{
{
forceHighQuality
if ( global0 == 0 )
map lights/fangrate.tga
colored
zeroclamp
}
{
forceHighQuality
if ( global0 == 0 )
map lights/fanblade.tga
colored
zeroclamp
rotate time * -1
}
{
if ( global0 != 0 )
forceHighQuality
map lights/fangrate.tga
red ( Parm0 * acceleratorflashtable2[ ( time - global1 ) / 7 ] )
green ( Parm1 * acceleratorflashtable2[ ( time - global1 ) / 7 ] )
blue ( Parm2 * acceleratorflashtable2[ ( time - global1 ) / 7 ] )
zeroclamp
}
{
if ( global0 != 0 )
forceHighQuality
map lights/fanblade.tga
red ( Parm0 * acceleratorflashtable2[ ( time - global1 ) / 7 ] )
green ( Parm1 * acceleratorflashtable2[ ( time - global1 ) / 7 ] )
blue ( Parm2 * acceleratorflashtable2[ ( time - global1 ) / 7 ] )
zeroclamp
rotate time * -1
}
} |
I think our engine is able to parse this. It appears to be intended for runtime switching. However in our engine Note that for this kind of runtime switching (for example powering on or off buildables), our assets use the Anyway, for the stage-level condition, one more option I haven't mentioned is that we could analyze the expression to see if it is a constant or not, thus reusing I dislike the Warsow preprocessor-style syntax, but for stage level stuff whatever syntax is fine. Which way do you think is best? The current |
That's something I would like to see but I don't want to delay such PR because of that.
We can start with Or we may find another keyword like |
Implement stage-level colorspace keyword as described in #1717 (comment)
Also add a warning if some shaders are loaded too early before the colorspace is known.