terrain blending tutorial


(WolfWings) #81

The normal of a vertex on a triangle is, before smoothing, the same as the normal of the triangle itself.

If you’re not using smoothing (-meta and -shade/-shadeangle, or equivilant shader-specific keywords, etc), that’s all a vertex normal is. If you’re using smoothing, and two or more triangles are smoothed together, the vertex normals of any vertices they share are averaged together, resulting in a blend of the vertex normals across the smoothed area instead of distinct gaps. I don’t have the exact math handy for the averaging, but it’s fairly straightforward.


(WolfWings) #82

we can have multi stage shaders where we scroll some layers and not others, but if a stage contains an alpha channel then unfortunately that always seem to scroll with the image, although I wish there was a way to control them separately… if anyone knows of a way, please tell us :slight_smile:

one thing I`ve been doing recently with my water shaders is applying a slight tcmod turb to the lightmap stage, as well as subtlety fade it in and out with a rgbgen wave, and use blendfunc blend on it so it works with the alphamod volume blending… this is great for spot lights pointing at a water surface, as it ups the realism considerably imo :)[/quote]

There’s actually a way to ‘set’ the alpha channel to use for a rendering pass seperately from the RGB channel in 32-bit mode. Remember, the screen buffer has it’s own alpha-channel in that mode at that point, which is updated with the alpha of whatever source texture is rendered to the screen. Much like how I was able to render the depth-layer without rendering any graphics, a similair trick can be done with the alpha channel.

{
    map alphatexture.tga
    tcMod turb 0 0.0625 0 0.1
    blendFunc GL_ZERO GL_ONE
}
{
    map alphatexture.tga
    tcMod scroll 0.0625 0
    blendFunc GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
    // Note the difference between this and the definition of 'blendFunc blend'
    // GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
}
{
    map $lightmap
    blendFunc filter
}

The above should work as a beginning to have seperately-controlled alpha channels. :slight_smile:


(ratty redemption) #83

@WolfWings, thanx although Im not sure I understand how it works yet, but Ill try out your shader and see if I can add it to my own ones.

do you think yours could be used to have a non scrolling alpha channel with a scrolling rgb channel? if so that would be cool :slight_smile:

and are you saying it doesn`t work with the short hand blendfunc blend?


(WolfWings) #84

Okay, I’ll explain the three stages of the above shader in more detail…

The above shader is a ‘turb’ alpha channel with a ‘scroll’ RGB channel.

The last stage is, obviously, a lightmap layer. Do what you will, I just included it out of habit. :slight_smile:

The first stage is actually the stage that’s rendering the alpha-channel into the video buffer. Nothing more. The blendFunc I used makes it leave the RGB buffer unmodified, while still updating the alpha channel.

The second stage is the ‘tricky’ stage, using blendFunc keywords that aren’t listed in the shader manual (likely because they didn’t think anyone had a use for them), but which are perfectly valid. Specifically, note the DST_ALPHA instead of the usual SRC_ALPHA keywords. Those mean use the alpha channel from the video buffer, NOT from the texture you’re rendering. Since we just rendered our own alpha-channel information to the video buffer in the previous pass, we’ve effectively decoupled the alpha channel from the RGB channel of the texture we’re rendering. :slight_smile:


(G0-Gerbil) #85

Heh nice little trick, funny how there’s still plenty to learn even after all this time :slight_smile:


(ratty redemption) #86

@WolfWings, thanx, I think I understand that perfectly now :smiley:

previously I had failed to notice the dst_alpha, as I just assumed you had written the normal src_alpha parts of the blendfunc… in future I`ll pay more attention to the comments added by the author :slight_smile:

can you confirm that gl_zero gl_one will always just write the alpha channel and not rgb? what happens if we use it on a tex which doesn`t contain an alpha channel?

and I agree with Gerbil :slight_smile:

actually almost everyday I tweak something in my shaders in my never ending quest to improve them, lol …luckily for me I love the interaction between tweaking shader scripts and the seeing the results in game.

but it can be very time consuming and addictive, especially as there are so many combinations of the different mediums we can try …although for mappers who don`t like working with shaders this could be a nightmare.


(WolfWings) #87

I haven’t ever tried it with a texture without an alpha channel, so I don’t know. I don’t currently have my own computer available to test on, but I’ll letcha know as soon as I do test that idea.

As for confirming the effect of gl_zero gl_one, it’s simpler than that. As far as I can tell (tested with Q3A extensively, but only Q3A) the blendFunc is ignored for alpha-channel writes. BlendFunc, in other words, is only used for the RGB channels of a texture, so yes, gl_zero gl_one will only affect the alpha channel, though it’s actually writing the RGB channels as well. (source0.0+destination1.0=destination)

actually almost everyday I tweak something in my shaders in my never ending quest to improve them, lol …luckily for me I love the interaction between tweaking shader scripts and the seeing the results in game.

but it can be very time consuming and addictive, especially as there are so many combinations of the different mediums we can try …although for mappers who don`t like working with shaders this could be a nightmare.

There’s very little to actually tweak, for me. I figure out what math I actually need the shader to calculate for any given pixel, then break that down into the available operations of clamped addition and multiplication to retain as much detail as possbile. :slight_smile:


(ratty redemption) #88

@WolfWings, thanx for the info :slight_smile:

your lucky you have a head for maths, I really cant imagine working like that, although it would be useful if I could as far as saying time, but Im not complaining as I usually get good results most of the time.

I`m just always curious how I can improve the movement of my tcmods, or the range and amount of fading using the rgb or alpha gens etc… can you accurately predict how those will turn out in your maps, without having to tweak them?

saying that I know if I have a base value of 1 and use an rgbgen wave with an amplitude of 0.5 then it will fade half the amount, but I still have to study the results in game to know if its what I want, but thats because I work visually.


(Mr_Tickles) #89

Hmmm, all sounds really cool, I’m pretty sure I can follow what you have done. maybe. :slight_smile:
Although I’m not too worried about it at the moment as I have to be concentrating on rl stuff for the next few months.

About that vertex normal, and triangle normal stuff. I’m really still lost. Is it the vector to that point? Maybe the definition of the word normal is confused here. (If you want to see what is in my head about it, read a few posts earlier in this thread). I’m not even going to pretend I know what triangle smoothing is, I could make guesses but best I don’t go about it half-arsed.

Ahh, is the vertex normal worked out by considering all the planes going through that point and finding the line which is equally perpendicular from those planes (No, I don’t mean exactly perpendicular (90), but you know what I mean… ;)) Hmmm, maybe not because you said all the vertexes have the same normal.

Or… maybe… is the normal of a tringle the line perpendicular to the hypotenuse of that triangle, easy to think of in 2D, but is it the same principal for 3D?

Bear in mind I am still new to mapping, and am curious so don’t get all arsey with me for being difficult with these questions please :slight_smile: (which I hope i’m not).


(WolfWings) #90

@Ratty_Redemption: First off, I’m autistic, though only a mild form (Aspergers) with numerous years (7 at last count) of counseling to learn coping mechanisms so it’s minor. But, it let me score 750+ out of 800 in the math section of the SAT’s, while I barely hit 500 in the verbal half. =-.-=

And generally, yeah, I can visualize complex combinations of alphaGen and rgbGen in my head, as it’s nothing but adding different waveforms with different minimum and maximum ranges in my head, and applying those waveforms to the equations I’m already working with. Like I said, I’m autistic, with a heavy bias towards math. Three-equation, three-variable differential problems are something I can generally solve in my head, for example, and I can usually factor third or fourth-degree polynomials in my head as well, so linear equations and most 3D computer graphics-related math is pretty easy for me.

Though for your given example… I’d probably have started with a ‘base’ of 0.75, and an amplitude of 0.25, unless there was a specific reason I needed it fully on half the time, fading out a quarter of the time, then fading in again a quarter of the time.

Figuring out lighting values usually takes many times as long as figuring out shaders, because I never seem to be able to understand the relationship between a light of value XYZ with settings ABC and the affect it has on the surrounding world geometry fully, so I need to tweak my lighting through numerous compiles. :slight_smile:

@Mr_Tickles: The ‘normal’ of a triangle is the vector that is perpindular for the plane the triangle occupies. Effectively perpindicular to the entire triangle. No relation what-so-ever to the origin or the distance of the triangle from the origin. At first, all three of the vertexes of a triangle have the same normal as the triangle itself.

When dealing with multiple triangles meeting at a single vertex, the individual vertexes used by each triangle are best thought of seperately, not shared. If two or more triangles that are going to be ‘smoothed together’ (I.E. to allow for smooth lighting across their surfaces like rolling hills instead of cut-gem-like faceted lighting) then the normals for all of the associated triangles are averaged together, and assigned to the vertex they share. (Think about it, most of the time a set of triangles can only share a single vertex, the ‘other’ vertex would have one or more triangles missing, and likely another triangle added to the list of triangles to blend with.)

And don’t worry, I’m a patient teacher, and don’t mind repeating myself in different ways to help someone understand my reasoning. :slight_smile:


(ratty redemption) #91

@WolfWings, very interesting post, both personally and with helping us better understand vertex normals, which I only previously knew the results of smoothing using certain values, not really how it was calculated which is helpful :slight_smile:

and I think your written english is equally as good, if not better then mine, and I usually use a spell checker if I remember, which without my spelling used to be almost as bad as my maths, although I have improved my english over the years but maths is something I really struggle with.

oh and my example of the rgb or alpha wave was just to keep the maths as simple as possible, in my actual shaders I use more subtle ranges.

but I tend to work by copying sections of code from one shader I know works then tweak it to look right with a new one, I guess I rarely work out shaders in my head before testing them in game.

I think it`s interesting to see how us different types of mappers work, and hopefully it will give hope to other less experienced mappers if they fall somewhere between your working methods and mine, as I can see Mr Tickles does :slight_smile:


(WolfWings) #92

@ratty redemption: Unfortunately, while my typewritten English is okay, my handwritten English is horrible, and my verbal English is akward and uncomfortable for me still. :slight_smile:

And I’d probably be a better mapper… if I had the creativity to actually figure out a solid layout for a map in the first place. I have no problem building complex constructions with high levels of detail… but I’m horrible at thinking of a remotely decent layout to build in the first place. :stuck_out_tongue:

I do seem to be able to help others, and I enjoy helping others when, where, and however I can. While I seem to have a distinct lack of actual projects for myself, I keep finding myself with ‘Thanks to’ credits in way too many things over the years. laughs


(Mr_Tickles) #93

Well, after feeling thoroughly put down, I have to say, thanks ;). That has explained it. It makes sense now that someone has actually said the normal is of the plane. The way everyone has described it in the past has either been the normal of a point… what the hell is that? Or the normal of a volume… which is equally as ridiculous.
By smoothing I thought you meant something exotic like creating a 3D curve in place of the two adjoining triangles which I was to say the least a bit baffled at… but if it’s only the lighting, or shading, that’s fine.

Lol, Ratty, I’m sure there are mappers out there whose methods also fall between your methods and Wolfwings, and they could have created some of the maps that we know and love.
True, I am an inexperienced mapper, but I’m glad there’s a slight glimmer of hope for me out there somewhere…

Wolfwings, a language is for communicating and you seem to be doing well enough at that, so imo you have no problems what so ever.

Thanks for the help :slight_smile:


(ratty redemption) #94

Unfortunately, while my typewritten English is okay, my handwritten English is horrible, and my verbal English is akward and uncomfortable for me still.

@WolfWings, I do understood and I sincerely think your doing well with this medium :drink:

I too struggle with handwriting due to developing a cataract in one eye during my late teenage years, which although not being a major problem working on a monitor, it did fook up my depth perception and I could no longer focus when handwriting, or using real world art mediums like pens, paints or craft knives... I`ve been told I`ll be able to have it operated on when I choose, which is cool, but I`m in no hurry.

luckily I`ve always been more graphical orientated then fine art, so pc`s turned out to be a perfect medium for me, especially as I can zoom into textures while digital 'painting' or manipulating them, same with 3d modeling and nowadays mapping, so all things considered I can`t complain ...and if anything it made me very determined to do the best work I can :)

And I’d probably be a better mapper… if I had the creativity to actually figure out a solid layout for a map in the first place. I have no problem building complex constructions with high levels of detail… but I’m horrible at thinking of a remotely decent layout to build in the first place.

so it`s not like you have a short attention span? it`s more you find it difficult to imagine how all the various parts of your map will fit together and how the gameplay will flow?

again, luckily for me that is an area I seem to excel in, well I find it easy to mentally plan out, and have been concept designing a full title game with an indonesian email friend of mine for the last couple of years.

what I find interesting is his gaming back ground is more rpg and rts then first person shooters, and I enjoy his very tactical approach to game design.

whereby I`m more used to setting up special effects like explosions, script movers, and cinematic style camera cut scenes, as well as designing moody and atmospheric looking maps... he and I think we make a good team and we intend to eventually sell our concept work.

I do seem to be able to help others, and I enjoy helping others when, where, and however I can. While I seem to have a distinct lack of actual projects for myself, I keep finding myself with ‘Thanks to’ credits in way too many things over the years. laughs

I don`t pretend to understand exactly what it must be like for you, but I do think it sounds like your getting a lot of good interaction through helping teach others, the more technical side of mapping, which in turn is probably helping your autism, yes? :)

Lol, Ratty, I’m sure there are mappers out there whose methods also fall between your methods and WolfWings, and they could have created some of the maps that we know and love.
True, I am an inexperienced mapper, but I’m glad there’s a slight glimmer of hope for me out there somewhere…

@Mr Tickles, although I haven`t seen any of your finished work yet, I can tell that you have a good technical mind for mapping.

partly as your inquisitive and obviously inspired to see what can be done with these game engines, whether it be reproducing established effects or helping develop new ones.

imo, that`s a very good foundation to build on, as opposed to some gamers who fancy building a map or two, then get deterred by how technical and time consuming the whole process is.

Im sure WolfWings would agree, you dont seem at all put off by not understanding the odd technical thing at first, and I think its admirable that you persist in your understanding of the engines, as I genuinely believe your not trying to be a smart arse, or ask questions you dont really want answers to, in fact I doubt anyone in here is thinking you have an obstructive agenda.

further more, if you can acquire good construction skills and develop an artistic way of visualizing maps, then you could have a successful mapping future ahead of you, same goes for any would be mod makers, mappers who get inspired by the kind of things we do.

for me my biggest motivation is designing and building virtual worlds I would want to visit or live in.

that is why I spend a lot of time on detail and strive to make them as believable as possible, even if fantasy or sci-fi which tbh I`m more into then ww2 type gameplay, although I do like weathered or run down old buildings and love out door type maps, which rtcw and et are good at doing, even if their not as powerful as some of the more recent engines, there is still a lot we can do with them :slight_smile:


(Mr_Tickles) #95

Well, thanks for those words Ratty. Much appreciated.
I can understand why you prefer the Sci-fi or fantasy, is it because there are so many different veins available to you? Meaning that you’re not restricted to a particular theme, and furthermore with the Sci-fi you can have more advanced technology where it is fun to play about with shaders :wink:

Well, I’m disappearing for a few months over the summer starting from the 19th, but will hopefully be able to check these forums out now and again and will hopefully get back on track after the break.


(ratty redemption) #96

@Mr_Tickles, cool and your right about sci-fi and fantasy maps being less restrictive for me to work with, sci-fi being my fav as it allows me to get away with having psychedelic or neon colored shaders, be they 2d multi layered plasma clouds, force fields or just funky neon lights :wink:

and while your away, try and watch this forum for the pics Rought and I will be posting soon… Ive been doing some very cool looking water and a few volume blended rocks for his latest map which is nearly finished, and were going to release the source files when were ready, even if its just the parts I did in the form of sample maps, along with the shaders and new custom tex I`ve made.

speaking of which do you think it would be sensible for me to post both the water and rock blending in this thread or split the water stuff into another thread, like the one NOP and me started a while back?

either way, I`ll be updating this one with your previous suggestions, and eventually getting round to preparing a neater html version.


(Mr_Tickles) #97

Well, the title of this thread is “Terrain Blending Tutorial”. However it would be really good to keep all the blending in the same place, whether or not it’s terrain or water. You could always update the old water blending tutorial you did with the water stuff you have done recently and the rock blending here. But I think new thread for each would be cool, but then place links either in your sig (along with the q3map2 manual) or in the first post of the tutorials. Lol, I don’t know, completely up to you, but I would make sure one is accessible from the other :wink:

Yep, I’ll definately try to keep an eye on the forums while i’m gone, and am looking forward to the pics now :slight_smile:

I’ve recently posted a message on another forum (my university’s computer science forum) asking if people want to join together to make a bit of a mapping, modding, modelling team and I will try to make a list of good tutorials to get them started. I will definately include your terrain blending :wink: (needless to say I’ve already linked to the SD forums) I’m going to post a guide on how to get started a bit later…

Looking forward to the html version :wink:
Right, now to go check out the water tutorial you linked to :slight_smile:


(ratty redemption) #98

@Mr Tickles, thanx for the suggestions and cool that your trying to get more people involved from your uni.

I think though, once Rought`s "the well of youth" map is finished, I`ll start a new thread and try to describe a step by step guide for making a rock pool, as that contains terrain and water construction and blending, then describe how the shaders can be tweaked to suit different maps.

this new tutorial would include a few sample maps, perhaps with different stages of the build and link to the other threads although I think they eventually will become redundant if the combined one goes well.

might be quicker me doing that, then updating and tidying up these current threads, also we could keep the new one just technical while still chatting off topic in the old ones if need be :)

I wish I could post the temp map pics I have of the new water, but I don`t think Rought would appreciate that, and besides they will look even better when added to his already very artistic and moody looking map.

so I`ll just say that the ripple, light ray part of the new water looks similar to the old water I made, only this time I made all the tex from scratch, and the shader has been tweaked a lot so the water now has a better environmental 'sheen' effect, and the lightmap makes the water look great under lights.

I`m also making a muddy sewer water for Rought using some of the cloud layers from the clean water version, which again will work well with the lightmapped shader.

as for the new waterfalls, the way I`ve got the lightmap to work is beautiful I think as it subtlety changes and appears to make the water look less like a solid surface.

(Lil Killa) #99

Could you add a link to an example map with shaders/textures? I’m lost on just about everything…

EDIT::

I found out how to do it using this tutorial.

I have one question though… One part of the tutorial tells you to make a shader similar to this:


textures/lk_island/grass
{
	qer_editorimage textures/lk_island/grass.tga
	q3map_lightmapsampleoffset 16
	q3map_shadeangle 178
	q3map_nonplanar
	q3map_forcemeta
	q3map_tcgen ivector ( 512 0 0 ) ( 0 512 0 )

	{
		map textures/lk_island/grass.tga
	}
	{
		map $lightmap
		blendfunc GL_DST_COLOR GL_ZERO
		rbgGen identity
	}
}

I was wondering if it was needed. If it is or if it does something I might want/need how could you go about fixing it so that it actually works?

Also… how can I change the length of the fade/merge?

Also… (yeah… another edit) what is the difference between the methode I used in the above tut and the tut on this thread?

Thanks
LK


(ratty redemption) #100

Could you add a link to an example map with shaders/textures? I’m lost on just about everything…

EDIT::

I found out how to do it using this tutorial.

the problem with releasing sample maps for the above tutorials is they are part of a large test map which I kept changing, but for my next set of tutorials Im going to build small separate sample maps as I write the tutorials, and that way they can be released with them... sorry I didnt do this before but I didn`t plan out the tutorials very well… hopefully the next ones will be better in that sense.

and that link you posted to is Dime`s tutorial which is quite a good one.

I have one question though… One part of the tutorial tells you to make a shader similar to this:

snip…

I was wondering if it was needed. If it is or if it does something I might want/need how could you go about fixing it so that it actually works?

that is a standard phong shaded, lightmapped grass shader, it isn`t needed for alpha volume blending as such, but dime used it in his example to blend his road onto.

iow, you could replace that shader with what ever you want to blend onto, eg a volume blended gravel road ‘on top’ of a sand shader.

and to get working in your maps, you can probably just replace the paths to the tex images you want to use, eg a sand tex image… that`s the good thing about this type of shader and blending, it will work in any q3 engine game with a recent version of q3map2 and the right paths used in the shaders.

Also… how can I change the length of the fade/merge?

that`s more tricky as it depends on the length, and sometimes angle, of the blend brushes, the ones with the alphagen vertex or alphagen oneminusvertex shader keywords.

with ‘linear’ volume blends which don`t use ‘speckled’ alpha channeled tex, the verts of the blend brushes can be faded from fully opaque to fully transparent, so over a long brush the fade will be very gradual.

but with ‘speckled’ alpha channeled, volume blending like in my tutorials the angles of the brush faces affect where the shaders alphagen vertex cuts off the blend, similar to how dot product blending works ... I think thats why most people prefer to work with the linear blending as it`s easier to predict the results and require less tweaking.

hth