![]() |
[SOLVED] Tree model leaves shader - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3) +--- Forum: Xonotic - Help & Troubleshooting (https://forums.xonotic.org/forumdisplay.php?fid=4) +--- Thread: [SOLVED] Tree model leaves shader (/showthread.php?tid=4874) |
Tree model leaves shader - Justin - 04-28-2014 I created tree model and I made leaves tga texture for it (with alpha channel) I got semi-transparent leaves vidable only from one side of the plane! The leaves are supposed to be fully visable from both sides, with norm and gloss texture. Anyone knows how to make it working properly? Help will be appreciated. This is a shader: Code: textures/map_floating/trees/tree_stem_01 ![]() Edit: It would be also nice to make these leaves animated (moving slightly sideways, as normal leaves should do) anyone knows how to acomplish it? Edit2:About plant and rock models: Do you think they would fit Xonotic style? Should I create few modular models for Xonotic? What kind? RE: Tree model leaves shader - Melanosuchus - 04-28-2014 Have you tried cull none? RE: Tree model leaves shader - Justin - 04-28-2014 ![]() Its better now, but still not satisfactory, thank you! Now the leaves can be visable from under the tree RE: Tree model leaves shader - Melanosuchus - 04-29-2014 Try a different blend function. For alpha blending, blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA RE: Tree model leaves shader - Justin - 04-29-2014 Thank you very much! As you can see its getting better but its still not fully acceptable. Normal maps on leaves are not displayed and for some reason leaves are brighter then in photoshpo (I think). OH! And you can see strange effect around each leaf (sort of hair) Here is the effect: ![]() As you can see, leaves are definitelly to bright, and thats not because their texture. Can this be caused by blending mode/lightmaps? And shader for leaves: textures/map_floating/trees/tree_stem_01 { qer_editorimage textures/map_floating/trees/tree_stem_01 surfaceparm trans surfaceparm nonsolid polygonOffset cull none { map textures/map_floating/trees/tree_stem_01 blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA rgbgen identity } } Mabye you happen to know how to make them moving (bobbing slightly)? EDIT: I think after Im done with this model I will make a tutorial ![]() RE: Tree model leaves shader - Melanosuchus - 04-29-2014 As far as I now, the automatic normal mapping is lost when you create a shader script. I guess q3map_normalImage would explicitly set one but I've never tried this http://q3map2.robotrenegade.com/docs/shader_manual/q3map-global-directives.html#q3map_normalImage I think you can use q3map_lightmapBrightness to dim the lightness http://q3map2.robotrenegade.com/docs/shader_manual/q3map-global-directives.html#q3map_lightmapBrightness I don't see any artefact but on the screenshot but it could be caused by some aliasing on the alpha channel. Maybe experimenting a bit with the blend function can give better results. I've seen shaders that make the surface wave a little but I have no direct experience on that, take a look at this http://toolz.nexuizninjaz.com/shader/shader/section3.htm#3.3 RE: Tree model leaves shader - Justin - 05-03-2014 If only netradiant had simple node system most great programes for editing have nowadays... ![]() ![]() Here are the results: ![]() And strange effect around the leaf edge ![]() RE: Tree model leaves shader - Mario - 05-03-2014 For lighting, all it should need is this in the second set of curly braces: map $lightmap RE: Tree model leaves shader - Justin - 05-03-2014 Thanks. I will try RE: Tree model leaves shader - sev - 05-04-2014 I haven't dealt with these things for quite a while. Your shader for the leaves is named tree_stem_01, are you sure that you are using the right shaders on the right parts of the model? As the leaves don't seem to be lightmapped, have you made sure to set "spawnflags 4" on the misc_model? http://en.wikibooks.org/wiki/Q3Map2/Entity_keys#misc_model_entity The artefacts seem to be caused by a fur shader. Make sure to turn this off: http://q3map2.robotrenegade.com/docs/shader_manual/fur.html This basic shader might work better: Code: textures/yourmap/leaves I advise against making the leaves move. It will likely cause a severe performance penalty. For that matter, you might also want to disable lightmaps altogether and only use vertex lighting. To test performance with different shader settings, you can create a gameplay demo, and then use the timedemo feature (Menu > Demo > Timedemo) to measure performance differences. RE: Tree model leaves shader - Justin - 05-04-2014 YAY! We are making progress!Thank you! Thats the shader and screenshot from my lastest attempt (I renamed map and suddenly shader started working (??) I don't get it. Why did I have to rename the map and .shader file? I thought shader doesn't have to have the same name as maps has, right? Mabye not appling changes to shader file name ''told'' game engine that there was no changes to shader itself? Code: textures/map_floating/trees/tree_stem_01 ![]() I have spawnflags set to 6. Is it okey? One more question: Do I have to rebuild whole level to notice changes in shader in game? Can I just build lightmaps or what? RE: Tree model leaves shader - sev - 05-04-2014 (05-04-2014, 09:41 AM)Justin Wrote: Lightmap sems too dark in some areas.Keep in mind that with "cull none" shaders, the texture is shown on both sides of the surface. IIRC, this means the same lightmap is shown on the front and back. If the surface faces away from the light, both sides are dark. Make sure that the surface normals point outwards, or towards the light source. (05-04-2014, 09:41 AM)Justin Wrote: I will remake normal maps and change "rgbgen identity" into "rgbgen vertex" as you adviced, Sev.rgbGen vertex doesn't mean what you think it does. http://q3map2.robotrenegade.com/docs/shader_manual/stage-directives.html#rgbGen Make sure to look up the keywords you are using in the Q3Map2 manual: http://q3map2.robotrenegade.com/docs/shader_manual/contents.html (05-04-2014, 09:41 AM)Justin Wrote: Also when jumping up into the leaves performance goes down terribly (at least 40 fps decrease) Might be this caused by spawnflags 6 (autoclipping model)?To quote the Q3Map2 wikibook: Q3Map2 Wikibook Wrote:Use of Q3Map2 autoclipping for models is only recommended for large models with relatively few triangles in their mesh (i.e. terrain). The Q3Map2 autoclipping algorithm is a bit of a hack, and can hurt in-game performance when used on small, dense models. I recommend to split the model up into two parts. The stem can be autoclipped and lightmapped (spawnflags 6). The leaves however should be nonsolid (spawnflags 4). RE: Tree model leaves shader - Justin - 05-07-2014 I couldn't hope for more. The current result is satisfactory (for Netradiant stardards at least). The way I did this model, Sev is very low poly. There are huge planes with stem and leaves texture on them so I can not split the model like you mentioned ![]() ![]() Tree screenshot, as a good way to conclude this topic (sorry for bad quality) ![]() Once again: Thank you all for your help. Regards, Justin |