ydnar: blending method


(dime1622) #1

i grabbed the shader and put it into my scripts dir (after fixing the scale values) and then dropped the textures into the common dir, but the problem is realizing how to use them. i checked rgoers map and he had that standing wall that had the alpha0 sitting at the bottom, and it alphaed itself, but i tried something similar and it didnt work. i guess i dont understand how the brushes are supposed to go together, and i cant find a map file in the q3map2 forum that would show how.

i still need to add the shader file name into the shader list tho, right? im just missing how to put it all together, how to have the base texture but the other tex sitting right on top. thanks for your help!

dime


(dime1622) #2

basically im asking how this is accomplished:

i guess this question isnt just for ydnar, but anyone who can answer it


(MadJack) #3

This is the dotproduct2 feature of q3map2 iirc. Search the forum for dotproduct and you’ll hit some interesting threads. I’ll probably use dotproduct2 later on to replace the terrain in my map.


(dime1622) #4

thats not dotproduct, because dotproduct is based on the normal vector of each face. ydnar mentioned that the above picture was a result of the new method of blending. dotproduct completely relies on the slope of the face to determine how much shading there is.


(ydnar) #5

There are actually two q3map_alphaMod volume brushes, scaling the volume per-vertex inside the brush.

The map here: http://www.shaderlab.com/q3map2/samples/shaderlab_1337.zip has an example of how this works. You’ll need this zip here: http://www.shaderlab.com/q3map2/samples/common_alphascale.zip (fix the alphaMod scale values in the shader tho).

shot:

y


(MadJack) #6

My bad, I should have searched.


(dime1622) #7

yeah i grabbed that map but am baffled as to how it works… still more interested in terrain tho


(obsidian) #8

First of all, you’ll need a blending shader (typically blendFunc add, filter or blend) along with alphaGen vertex or rgbGen vertex. This will be your blending terrain shader or blending water, fire, whatever. Pretty much anything that has a blendFunc can use this.

In Radiant,build your terrain as you normally would, but instead of relying on using an alphamap or dotproduct in your shader, you can place the alphaMod volume brushes throughout to mark specific areas of blending. The way this works is that any vertex points of your terrain mesh that overlaps within the alphaMod volume brushes will be targeted for blending, subjecting to whatever alphaMod scale or alphaMod set values. So if a vertex of your terrain mesh is within an alphaMod volume brush also marked with alphaMod scale 0.5, then the terrain surrounding that vertex point will be blended by 50%. You can also use alphaMod volume with alphamaps or dotproduct for any fine tuning.

You may also want to read this:
http://www.shaderlab.com/q3map2/shader_manual/ch3.html#alphamod


(dime1622) #9

aha! thanks, obsidian! so, if i want to blend a piece of something, i:

  • make sure textureA has BlendFunc in the shader file
  • make a brush with textureA on the face
  • put any number of vertices inside a brush textured with the “alpha0” texture

all non-enclosed vertices will be at 100% visibility, all vertices enclosed will be at 0% visibility

so in order to make the picture ydnar did above, he laid down a base texture that had no BlendFunc property. then he laid down brushes where he wanted the rock texture with a rock texture containing a BlendFunc property and then at their edge vertices put brushes with alpha0 around those vertices.

am i correct?

my only question is, do the blended parts then need “polygonoffset” to make them not have z-fighting with the original terrain?


(ydnar) #10

There’s only one terrain shader, with two stages. It looks like any other Q3Map2 lightmapped terrain blend shader, with the second stage using:

blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex

y


(Godmil) #11

that sample of the blocks sticking out of the water is fantastic!

I was trying to achive something similar a wee while ago, but nearly gave up in despair.
this technique will be just perfect :smiley:

<3


(dime1622) #12

sorry ydnar, im completely retarded. could i see an example of the shader?


(ydnar) #13

textures/shaderlab_vector_1/rock_1_z
{
	q3map_lightimage textures/shaderlab_vector_1/rock_1.tga
	
	q3map_nonplanar
	q3map_shadeAngle 179
	q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 )
	q3map_tcMod rotate 33
	q3map_lightmapAxis z
	
	{
		map textures/shaderlab_vector_1/rock_1.tga
		rgbGen identity
	}
	{
		map textures/slterra/sand_1.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbGen identity
		alphaGen vertex
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
		tcGen lightmap
	}
}


(dime1622) #14

cool, thanks!


(ratty redemption) #15

for anyone who`s interested:

Ive very nearly finished my first intended, terrain tutorial using ydnars alpha mod volume blending, and Ill be posting that in another topic in this forum over the weekend... if I dont MadJack and Shazmax can start laying down the rat traps as I`ve been promising to write up some tutorials for ages.

I`m not saying there will be anything particularly new or amazing in what I show you guys, but it might help some of you understand the process further, and apply it to your terrain maps or inspire other uses for it.

also Im looking forward to the guys here helping me perfect my construction methods, and I admit I didnt know that additive blending worked with the volume blending, so I`ve learnt something new today :slight_smile:


(dime1622) #16

like helping idiots like me. thanks ratty :wink:


(ratty redemption) #17

hee hee, well it wont be a very newbie friendly tutorial as its aimed more at mappers with a basic understanding of radiant and shaders.

but Im willing to help teach you guys this stuff until one of us writes a complete step by step guide, saying that, its reasonably quick and easy to use once weve learnt the basics, so most people in here shouldnt have a problem with it.