ParseShader: load extra maps the DarkPlaces way if r_dpMaterial enabled#159
ParseShader: load extra maps the DarkPlaces way if r_dpMaterial enabled#159illwieckz merged 1 commit intoDaemonEngine:masterfrom
Conversation
|
By not working I mean the engine reports to find the extra texture files, but unfortunately it only renders diffuse maps. |
a22a173 to
6165bc8
Compare
|
I think there is a special command to list opened files, does someone remember it? |
|
For information this is how it looks on console: That's why it seems to work: the files are found. But what's painted on screen obviously proves that only diffusemap is rendered. |
|
At this point the engine code claims to turn this: textures/phillipk2x/computer-pk02_switches01c
{
qer_editorimage textures/phillipk2x/computer/pk02_switches01c
dpoffsetmapping - .68120712951256245813 match8 89.89403100000000000000
dpglossintensitymod 3
dpglossexponentmod 4
q3map_bouncescale 1.25
{
map textures/phillipk2x/computer/pk02_switches01c
}
{
map $lightmap
rgbgen identity
tcgen lightmap
blendfunc filter
}
}into this ( textures/phillipk2x/computer-pk02_switches01c
{
qer_editorimage textures/phillipk2x/computer/pk02_switches01c
q3map_bouncescale 1.25
{
map textures/phillipk2x/computer/pk02_switches01c
}
{
map $lightmap
rgbgen identity
tcgen lightmap
blendfunc filter
}
glowMap textures/phillipk2x/computer/pk02_switches01c_glow
normalMap textures/phillipk2x/computer/pk02_switches01c_norm
specularMap textures/phillipk2x/computer/pk02_switches01c_gloss
}Note that the code runs after everything else is parsed, hence right before the ending I also verified those files are loaded: |
|
To get a testbed, people may copy (or symlink) p="$(ls 'xonotic-'*'-maps.pk3' | tail -n 1)"
b='xonotic-maps'
listMaps () {
unzip -l "${p}" \
| tail -n +4 \
| head -n -2 \
| egrep '\.bsp$' \
| sed -e 's|^.* maps/||;s|\.bsp$||'
}
filterSystem () {
egrep -v '^_'
}
filterInvalid () {
egrep -v '_'
}
ln -sfv "${p}" "${b}_0.dpk"
for m in $(listMaps | filterSystem | filterInvalid)
do
d="map-${m}_0.dpkdir"
mkdir -pv "${d}"
echo "${b}" > "${d}/DEPS"
donethen run dæmon this way: daemon -pakpath /path/to/xonotic/pkg \
-set logs.logLevel.default debug \
-set language en \
-set developer 1 \
+set g_neverEnd 1 \
+devmap solarium |
f206219 to
1a857ad
Compare
|
When I print textures/exomorphx/light-metal_light03
{
qer_editorimage textures/exomorphx/light/metal_light03
dpoffsetmapping - 5.05836666682224888188 match8 160.48228200000000000000
dpglossintensitymod 2
dpglossexponentmod 4
dpreflectcube env/exomorph/exomorph
surfaceparm metalsteps
q3map_bouncescale 1.50
{
map textures/exomorphx/light/metal_light03
}
{
map $lightmap
rgbGen identity
tcGen lightmap
blendfunc filter
}
}produces: Five stages because of the two original stages plus the three computed ones: |
|
If I hack stuff by disabling the color map stage and creating a brand new diffuse map stage instead with the same texture path, it works, but it's a hack since we lose all the other keywords that may be there (like Note that the lighting is wrong because Xonotic uses sRGB lightmaps and Dæmon does not support them yet. without hackwith hack |
|
Note that since Xonotic ships a heightmap with almost all its normalmap, I enabled temporarily parallax on all shaders just to have a look. It works (and I haven't experienced preformance issue) but I discovered that xonotic heightmaps are upside down, or our engine is. Perhaps it's a trick to not have to detect the presence of heightmap hidden in alpha channel of normalmap, as a missing alphachannel would mean a flat surface at the good level. Currently our engine displays a flat surface at the wrong level if we enable parallax on a normalmap without heightmap in alpha channel. |
|
If you actually write the second shader in this comment in a file, does it do what you want? |
|
I have not tried but I'm now almost sure it won't work because this is a colorMap stage: {
map textures/exomorphx/light/metal_light03
}and a diffuseMap stage looks like this: diffuseMap textures/exomorphx/light/metal_light03or {
stage diffuseMap
map textures/exomorphx/light/metal_light03
}and the engine code is explicit: normalMap, glowMap, specularMap and others only work with diffuseMap stage, not colormap stage. Daemon/src/engine/renderer/tr_shader.cpp Lines 3768 to 3783 in be89425 So what we need is to transform the colorMap into a diffuseMap. I don't know why but setting the diffuseMap bits in a colorMap stage does not do the trick. The hacky way that works is to disable the colorMap and load a brand new diffuseMap that is activated instead. That's how I produced those pictures above, the problem is that sometime those colorMap stages ship more information that are then lost. For example the colorMap of the solarium water is this one: If I create a diffuseMap using the Edit: I'm like 99.99% sure of what I just wrote in this comment. |
|
I implemented the detection and auto enablement of heightmap in normalmap alpha channel. I added a hack that reverses |
f30e76c to
d14f4c2
Compare
|
The code looks OK to me now, I added a This I removed from this PR all the related stuff that was useful for testing purpose but must be done in dedicated PR, like attempt to fix parallax mapping or code to detect heightmap in normalmap. |
|
It looks like there are still some commits from one of the other PRs, can you remove those? |
|
@slipher, yeah, those commits were required for that patch to be applied, but once they have been merged on master they just disappeared from there. |
11650b6 to
192947a
Compare
|
all remarks are now fixed |
273087b to
1d958fc
Compare
| static char whenTokens[ MAX_STRING_CHARS ]; | ||
|
|
||
| // DarkPlaces material compatibility | ||
| static Cvar::Cvar<bool> r_dpMaterial("r_dpMaterial", "Enable DarkPlaces material compatibility", Cvar::NONE, false); |
There was a problem hiding this comment.
@slipher, do you think this requires the annoying #ifdef BUILD_ENGINE magic too?
if r_dpMaterial is set to on, load extra textures the DarkPlaces way by looking for extra files with special suffixes like _norm or _gloss










If
r_dpMaterialis set toon, load extra textures the DarkPlaces way by looking for extra files with special suffixes like_normor_gloss.