kwenga Posted March 10, 2016 Share Posted March 10, 2016 I was playing with terrain and shaders in overall, and found major problem. Basically, I don't know how to include both $lightmap and randomly generated grass sprites on the same layer of terrain, which contains transition between two different textures.Example below (single texture): textures/testmap/terrain_0 { q3map_baseshader textures/testmap/terrain_base qer_editorimage textures/yavinvalley/junglefloor.jpg q3map_material ShortGrass q3map_nolightmap cull twosided { map $lightmap } { map textures/yavinvalley/junglefloor.jpg blendFunc GL_DST_COLOR GL_ZERO } { map gfx/sprites/y_grass_tall surfaceSprites vertical 36 36 48 650 ssFademax 4000 ssFadescale 1 ssVariance 1 2 ssWind 0.3 alphaFunc GE192 blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA depthWrite rgbGen vertex } }Single texture, both lightmap and sprites are working very well. No issues with shadows, etc. Main problem (transition): textures/testmap/terrain_0to2 { q3map_baseshader textures/testmap/terrain_base qer_editorimage textures/yavinvalley/junglefloor.jpg { map textures/yavinvalley/junglefloor.jpg } { map textures/yavin/dugdirt.jpg blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA alphaGen vertex } { map $lightmap blendFunc GL_DST_COLOR GL_ZERO } } Here comes the problem. I don't know how to include grass sprites in that part of code. Adding it at the end or in the middle just messes everything up - no shadows, no sprites, many bugs and other unpleasant errors. It's not working anyways. I'm pretty sure its something with blendFunc, and since whole .shader file is still some "magic thing" to me, I can't work it out myself. Help would be really appreciated. Link to comment
kwenga Posted March 13, 2016 Author Share Posted March 13, 2016 So... is it impossible or what? This lack of responses is confusing. I can change whole concept of my map, but I need to know if it is really necessary. Am I the first one, who ever tried doing this sort of stuff with shaders? Link to comment
Langerd Posted March 13, 2016 Share Posted March 13, 2016 Random summon...@@Langerd!https://youtu.be/EyGuBM1ELf4?t=5 INCOMING!!I was playing with terrain and shaders in overall, and found major problem. Basically, I don't know how to include both $lightmap and randomly generated grass sprites on the same layer of terrain, which contains transition between two different textures.Example below (single texture): textures/testmap/terrain_0 { q3map_baseshader textures/testmap/terrain_base qer_editorimage textures/yavinvalley/junglefloor.jpg q3map_material ShortGrass q3map_nolightmap cull twosided { map $lightmap } { map textures/yavinvalley/junglefloor.jpg blendFunc GL_DST_COLOR GL_ZERO } { map gfx/sprites/y_grass_tall surfaceSprites vertical 36 36 48 650 ssFademax 4000 ssFadescale 1 ssVariance 1 2 ssWind 0.3 alphaFunc GE192 blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA depthWrite rgbGen vertex } }Single texture, both lightmap and sprites are working very well. No issues with shadows, etc. Main problem (transition): textures/testmap/terrain_0to2 { q3map_baseshader textures/testmap/terrain_base qer_editorimage textures/yavinvalley/junglefloor.jpg { map textures/yavinvalley/junglefloor.jpg } { map textures/yavin/dugdirt.jpg blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA alphaGen vertex } { map $lightmap blendFunc GL_DST_COLOR GL_ZERO } } Here comes the problem. I don't know how to include grass sprites in that part of code. Adding it at the end or in the middle just messes everything up - no shadows, no sprites, many bugs and other unpleasant errors. It's not working anyways. I'm pretty sure its something with blendFunc, and since whole .shader file is still some "magic thing" to me, I can't work it out myself. Help would be really appreciated. Can You make screenshots? Link to comment
kwenga Posted March 13, 2016 Author Share Posted March 13, 2016 Screenshots won't give you that much of an intel. I know what problem is and I know how to solve it, I just cannot figure out how to include grass thing afterwards. To be fair, I'm not even sure if it is possible, because of the way how .shader file works. This screenshot might be slightly dated, but it still shows how it looks in-game. All bright areas are textured by single textures, both shadows and grass implemented. You can clearly see slightly darker area - that's "terrain_0to2" or other transition from shader file. No lightmap on it. I can easily fix shadows on that, just by adding $lightmap etc. in .shader file, and it will look fine. But that's not the point - I want to put randomly generated sprites on it too, and there it gets complicated or/and impossible. Link to comment
Langerd Posted March 13, 2016 Share Posted March 13, 2016 Screenshots won't give you that much of an intel. I know what problem is and I know how to solve it, I just cannot figure out how to include grass thing afterwards. To be fair, I'm not even sure if it is possible, because of the way how .shader file works. <script pagespeed_no_defer="">//=d.offsetWidth&&0>=d.offsetHeight)a=!1;else{c=d.getBoundingClientRect();var f=document.body;a=c.top+("pageYOffset"in window? window.pageYOffset:(document.documentElement||f.parentNode||f).scrollTop);c=c.left+("pageXOffset"in window?window.pageXOffset:(document.documentElement||f.parentNode||f).scrollLeft);f=a.toString()+","+c;b.b.hasOwnProperty(f)?a=!1:(b.b[f]=!0,a=a<=b.e.height&&c<=b.e.width)}a&&(b.a.push(e),b.d[e]=!0)};p.prototype.checkImageForCriticality=function(b){b.getBoundingClientRect&&q(this,b)};h("pagespeed.CriticalImages.checkImageForCriticality",function(b){n.checkImageForCriticality(b)}); h("pagespeed.CriticalImages.checkCriticalImages",function(){r(n)}); var r=function(b){b.b={};for(var d=["IMG","INPUT"],a=[],c=0;c=a.length+e.length&&(a+=e)}b.g&&(e="&rd="+encodeURIComponent(JSON.stringify(s())),131072>=a.length+e.length&&(a+=e),d=!0);t=a;if(d){c=b.f;b=b.h;var f; if(window.XMLHttpRequest)f=new XMLHttpRequest;else if(window.ActiveXObject)try{f=new ActiveXObject("Msxml2.XMLHTTP")}catch(k){try{f=new ActiveXObject("Microsoft.XMLHTTP")}catch(u){}}f&&(f.open("POST",c+(-1==c.indexOf("?")?"?":"&")+"url="+encodeURIComponent(b)),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(a))}}},s=function(){var b={},d=document.getElementsByTagName("IMG");if(0==d.length)return{};var a=d[0];if(!("naturalWidth"in a&&"naturalHeight"in a))return{};for(var c= 0;a=d[c];++c){var e=a.getAttribute("pagespeed_url_hash");e&&(!(e in b)&&0=b[e].k&&a.height>=b[e].j)&&(b[e]={rw:a.width,rh:a.height,ow:a.naturalWidth,oh:a.naturalHeight})}return b},t="";h("pagespeed.CriticalImages.getBeaconData",function(){return t});h("pagespeed.CriticalImages.Run",function(b,d,a,c,e,f){var k=new p(b,d,a,e,f);n=k;c&&m(function(){window.setTimeout(function(){r(k)},0)})});})(); pagespeed.CriticalImages.Run('/mod_pagespeed_beacon','https://jkhub.org/index.php?s=a83065d0355daa90481b70086912cbfd&app=forums&module=ajax§ion=topics&do=quote&t=7289&p=104582&md5check=ecba2a4d3033837a868480b442547b35&isRte=1,XJjZaj8buz,true,false,ubptxYaErC8'); //]]></script>&&0 This screenshot might be slightly dated, but it still shows how it looks in-game. All bright areas are textured by single textures, both shadows and grass implemented. You can clearly see slightly darker area - that's "terrain_0to2" or other transition from shader file. No lightmap on it. I can easily fix shadows on that, just by adding $lightmap etc. in .shader file, and it will look fine. But that's not the point - I want to put randomly generated sprites on it too, and there it gets complicated or/and impossible. Hmm how about that? textures/morch/sand_blend{ q3map_material dirt q3map_nonplanar q3map_shadeangle 180 { map $lightmap } { map textures/morch/sand_blend blendFunc GL_DST_COLOR GL_ZERO } { map textures/imperial/grass surfaceSprites flattened 48 24 45 400 ssFademax 3000 ssFadescale 2.5 ssVariance 1 2 ssWind 0.8 alphaFunc GE192 blendFunc GL_ONE GL_ZERO depthWrite rgbGen exactVertex }} Link to comment
kwenga Posted March 13, 2016 Author Share Posted March 13, 2016 Em... That's not what I'm asking for.Look at my first post. You have to include two textures plus all that blendfunc stuff (so basically whole text from second quote) AND somehow still find a place for map gfx/sprites part (last {} from first quote). Link to comment
Langerd Posted March 13, 2016 Share Posted March 13, 2016 Hmm.. Cant You just copy and paste first shader and rename it? I am not good shaders though :S@mrwonko@Asgarath83Help D: Link to comment
Xycaleth Posted March 13, 2016 Share Posted March 13, 2016 With your problematic shader, does the problem go away if you remove the surface sprite stage? If so, it might be a bug in the renderer code. Surface sprite stages don't have any interaction with the other stages so if adding it in causes issues, it might be engine related rather than something you're doing wrong. Link to comment
Langerd Posted March 14, 2016 Share Posted March 14, 2016 With your problematic shader, does the problem go away if you remove the surface sprite stage? If so, it might be a bug in the renderer code. Surface sprite stages don't have any interaction with the other stages so if adding it in causes issues, it might be engine related rather than something you're doing wrong.When i have problems with the shaders i always copy and paste lines from shaders that i want. He should just find the shaders with sprites that works with fog. I think the level with swoops has terrain with this kind of shader. Link to comment
kwenga Posted March 14, 2016 Author Share Posted March 14, 2016 @@Langerd, you are still missing a point there. I CAN remove sprite stage, and yes - shadows, light, etc. will work. I can fix that buggy area and make everything look nice and smooth. Well, I could finish map without it. My point is different though. When you're using a shader with a SINGLE texture - grass, mud, stones, whatever, you can simply add that whole gfx/sprites part to your .shader file and it will render it on a surface. It is a common technique, so no witchcraft or magic there.My case is slightly more complicated. This problematic area is covered by shader which contains TWO blending/mixed textures, so it works different. At that point, I have two options - I could add $lightmap to that shader (creates shadows and all good-looking stuff) OR I could add sprites. In separated cases, it is working. However, I want to add BOTH at the same time, so grass AND lightmap. As @@Xycaleth said, it might be engine related... It might be even impossible, but that's why I'm asking here, looking for an advice from some hardcore modders/mappers/other magicians.Besides that. thank you for all responses. Langerd likes this Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now