Xonotic Forums
Custom shaders not working properly - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10)
+--- Forum: Xonotic - Editing and Concept Art (https://forums.xonotic.org/forumdisplay.php?fid=11)
+--- Thread: Custom shaders not working properly (/showthread.php?tid=3348)



Custom shaders not working properly - exidl - 08-05-2012

Hello,

I'm trying to apply a normal map on a wall and an environment map on a floor, both of them don't work at all, I don't know if there's something additional to do.

Here is the setup :

I've ran the map then executed the command "envmap kf_test 512".
My env textures are located at ~/.xonotic/data/env, they are named
Code:
kf_testbk.tga  kf_testdn.tga  kf_testft.tga  kf_testlf.tga  kf_testnx.tga  kf_testny.tga  kf_testnz.tga  kf_testpx.tga  kf_testpy.tga  kf_testpz.tga  kf_testrt.tga  kf_testup.tga

I'm using this code for the floor shader :
Code:
textures/Kafka/Floor01_env
{
        qer_editorimage textures/Kafka/Floor01
        dpreflectcube env/kf_test
        {
                map textures/Kafka/Floor01
        }
        {
                map $lightmap
                rgbgen identity
                tcgen lightmap
        }
}

And the shader is correctly applied in NetRadiant, but it's still the same texture in the game Sad

[Image: obgiul.jpg]

For the wall, I've used the GIMP with the normalmap plugin, I've saved the main texture as textures/Kafka/Brick08.tga and the result as textures/Kafka/Brick08_norm.tga, I've added a gloss texture for it too.

Here are the files I'd like to use :

Diffuse :
[Image: KxZrss.png]

Gloss :
[Image: 5mDR3.png]

Normal :
[Image: p8vlCs.jpg]

It doesn't work, I wonder what's going on...

Has anyone got an idea please ?

Best regards.


RE: Custom shaders not working properly - Maddin - 08-06-2012

If I remember correctly you don´t need a shader for textures like this. Important are the suffixes of your texture names. Normalmaps use the suffix "_norm", glossmaps/specularmaps "_gloss" and diffuse only the name. E.g.:

yourtexture.tga
yourtexture_gloss.tga
yourtexture_norm.tga

Also be sure you turned on normalmapping in your game settings!!!


RE: Custom shaders not working properly - exidl - 08-06-2012

Thanks Maddin, I've just realized that the normal map was too weak to produce a 3d relief on the walls.
I've finally got the reflection working on the floor, thanks to Morphed on IRC for telling me to use reflection map.

[Image: kXxdbl.jpg]

But the reflection is following me like a skybox, is there a way to produce some kind of "static" reflection on the floor ?
How can I make the reflect less visible ? I've tried to lower the reflection map's opacity but it's still the same.


RE: Custom shaders not working properly - Maddin - 08-06-2012

What do you mean by reflection? Glossmapping (same as specularmapping), environment mapping or a mirror effect?


RE: Custom shaders not working properly - exidl - 08-06-2012

I'd just like some mirror effect, like the water in solarium but static if it can save some performance, I'm pretty new in shading so I don't really know the right terms for that.


RE: Custom shaders not working properly - Maddin - 08-06-2012

To fake a mirror you use environment maps.

Code:
textures/pathto/texture
{
    qer_editorimage textures/pathto/editorimage
    {
        map textures/pathto/environmentimage        //this is the image which shows up as the environment map
        tcGen environment        //causes this stage to be an environment map
    }
    {
        map textures/pathto/maskimage        //must be an image with an alpha channel and transparent areas where you want the env map to show up
        alphaFunc GT0
    }
    {
        map $lightmap
        rgbGen identity
        tcGen lightmap
        blendfunc filter
    }

Haven´t tested the shader but it should work. Tongue

Also do not forget to add your shaderfilename to the shaderlist.txt file. Otherwise your shaders won´t work.


RE: Custom shaders not working properly - hutty - 08-07-2012

you are trying to get the impossible mappers utopia ....

envoriment map (also known as cube maps) is what you currently have ... they work best in small places ... or when used weakly (and blured)

what you want is a mirror ... using a mirror can be bad on performance ... however ... if your map is constructed correctly you can get away with using mirros with almost no performance loss (look at drain for an example of this)

the other method is to make your floor semi transparent ... and then put an upside down copy of your room underneath it ... that may work better for larger rooms ....


RE: Custom shaders not working properly - exidl - 08-07-2012

Many thanks both of you for your hints,
I've understood the shading system much better than before, I'm now using the "dp_reflect" keyword for a good-looking reflection, and I'm aware that it would lower the performance a lot, but I'll apply then the environment map as you said later.


RE: Custom shaders not working properly - Maddin - 08-07-2012

Btw: To make the environment map looking most suitable take a screenshot of your scene where the shader will be applied and use it (after some image editing of course) as your environment map. Wink


RE: Custom shaders not working properly - hutty - 08-07-2012

or even better ... use the console command in xonotic to take a 360 box screenshot ...

but then ... it really depends on what type of envorment map you need ...

the windows in redplanet are only viewed from one direction ... so maddins method was used there


RE: Custom shaders not working properly - Maddin - 08-08-2012

Just a dump question: How to take that 360° screenshot? Tongue


RE: Custom shaders not working properly - hutty - 08-08-2012

Quote:You can produce such a texture with this console command: envmap map/mapname/reflect1 512
Which will produce files such as:
map/mapname/reflect1px.tga map/mapname/reflect1py.tga map/mapname/reflect1pz.tga map/mapname/reflect1nx.tga map/mapname/reflect1ny.tga map/mapname/reflect1nz.tga
map/mapname/reflect1ft.tga map/mapname/reflect1rt.tga map/mapname/reflect1bk.tga map/mapname/reflect1lf.tga map/mapname/reflect1up.tga map/mapname/reflect1dn.tga


from

http://dpwiki.slipgateconstruct.com/index.php?title=Material_creation_for_DP