alpha blend over the same plane


(carnage) #1

i have a dot2product shader with alpha blend to help control it. The brushwork is of cliffs and flat ground. The base texture is rock and then grass is belnded over the flat areas

What i want to achive is having the rock texture to always show from the side regardles of what direction the plane the image is on is facing

also i want the grass texture to always show from the xy plane regadless of the normal of the plane its on

if i uses the comand

	// q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )

i get the entire shader applied over the xy axis but i only want the grass to do this. iv tried using this just in the section of the shader concerning the grass but it then does not show in game

here is my shader. any help is greatly apreciated

textures/Carnagecliffs/phongcliff
{

qer_editorimage textures/carnagecliffs/phongcliff.tga

q3map_nonplanar
q3map_shadeangle 70
// q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )

{
map textures/terrain/cliff_m05dcon.tga // Primary texture
rgbGen identity

}

{
map textures/terrain/grass_dm01.tga // Secondary
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}

{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
rgbGen identity
}
}


(Shaderman) #2

I’ve read these two sentences about 20 times now and I’m still not sure if I understand what you try to achieve :moo:

This is what I think now (correct me if I’m wrong). If you have a simple cube brush with the same shader on the 4 sides and the top, you’d like to see the rock texture on the 4 (vertical) sides and the grass texture on the top (horizontal)? Did I get it?


(carnage) #3

I’ve read these two sentences about 20 times now and I’m still not sure if I understand what you try to achieve

nither do i sadly im crap at comunicating :drink:

k ill have another go. In the game there are three planes xyz

a level plane, ie. has not differance in the z cordinate or the vertices of the plane the texture will be applied from above

a vertical plane where there is no differnace in the x coordinate on the vertices in the plane the texture will apear as if its applied from the side

q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )

this makes the entire shader apply to the brushwork as if the entire texture is applied from above ragardless of the normals of the planes its applied on. The result is that there is now no seams where two planes meet that apply the image on a differnt axis. The downside is that since all texture are applied from above very steep slopes apear to have extreamly streached textures

for me this is ok since the grass is always on the xy plane and the and the rock is only on the xz and yz planes. so if the grass is always shown on the xy plane this wont look streached since the alpha gen vertices will stop it apearing on the walls where it would apear streched

feels like i am confusing ppl more maby the aid of some screenshots will help

EDIT//

as it is now… you can see where the grass texture has a seam since its applied on differnt axis

[img=http://img141.imageshack.us/img141/6433/seam13ti.jpg]

with the

q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )

command

[img=http://img400.imageshack.us/img400/8085/seam24qs.jpg]

as you can see the seam in the grass textures dissapear since the shader is always allpied from obove regardless of the planes normal

but you can see in the red that this also applies to the rock texture and creates that extream streach

what i want to do is have it only apply to the grass part of the shader so there are not ugly seams in the grass but the rock still lookg unstreached


(Twisted0n3) #4

You need to use tcGen vector or ivector in individual stages, rather than q3map_tcgen ivector in the beginning of the shader, to achieve what you want. And you may need 2 separate versions projecting the rock component N-S and E-W respectively, depending on whether the cliff sides face lots of different ways or are mostly aligned.


(Twisted0n3) #5

Oh, thank God. What’s up with quick reply? It just fails saying cryptically “the network is busy”. It fails really quickly – normally, if congestion is the problem something fails very slowly, spinning for ages and then timing out, so I think the real problem is something else entirely. But it seems like “slow” replying works (hit Quote button on someone’s post) for the duration…


(Detoeni) #6

I did something like this in me last map, I used an ASE to project a decal over the terrain, with alpha volumes to fade the edges. The ASE’s were re-textured in max to get them to look right.


(carnage) #7

thanx for the repiled guys

@ Detoeni i had considerd this but wanted to be able to do it using the shaders. If i have to overlap brushowkr and use decals then its going to majorly increase bsp size and cause extra calculations with the depth buffer to handel them. Not to mention how much mover complex the map file will be. still i gess not much choice

@ TwistedOn3 ill give these a go and see what results i can get hope they work

many thanx


(Shaderman) #8

I’ve tried to achieve the same some days ago and ended up with two separate shaders (mentioned by Twisted0n3 or ydnar in this thread).
It didn’t work very well with my bumpy rock brushwork. I still had streched textures depending on some angles and seams where both shaders meet :frowning:


(carnage) #9

ive tried both solutions

btw worth saying imtrying this in rtcw so and render stage shader keywords may not works too perfect

twisteds partialy worked but the green grass apeared just as a average green colour all over and had no texture detial to it but i think that may be cos of the values i was using

detonis solution actuaily worked brilliantly for the grass at least although even when i got the results i wanted it wasnt all that special but the editor was so over complex with overlaping brushes it was total unusable to edit terrain like that and im only looking after a small sample a full map would probably be imposible

even better to get the cliffs working without seams tripple overlapping brushowrk is needed. on for x axis one for y axis much in the same way that the grass works. then finaly apply the grass over again so thats three passes. but cant use more then one decal. not given up yet though


(obsidian) #10

q3map_* directives are global, so they affect the entire shader on all stages.

Remove q3map_tcGen iVector since you don’t want to project the rock texture from the Z-axis.

Try using the stage specific tcGen vector on the grass stage instead.
http://members.lycos.co.uk/quakeroats/q3map2/shader_manual/ch6.html#tcgen


(carnage) #11

i have it working now where the grass never seams
the rock on most of the cliffs doesnt seam
the only places that looks bad is where there is a very strong change in angle on the rock

to get around this i wrote a second shader that keeps the grass seamless wile changing the direction the rock texture is applied. but nasty seams in rock apear

if only it were posble to apply a second dot2product so i could blend both surfaces of rock