Having problems with tcGen vector...


(obsidian) #1

I’m trying to create some terrain with q3map_alphaMod dotProduct, q3map_tcGen ivector and tcGen vector, but I can’t seem to get the textures aligned to the terrain mesh properly.

What I want to do is have one texture for all near-horizontal faces that blends into another texture for all near-vertical faces. The horizonal faces are projection mapped along the z-axis using q3map_tcGen ivector. The vertical faces are supposed to be projection mapped along the x-and-y-axes using tcGen vector (stage specific).

Problem is that no matter what I do, the vertical face textures seem to deform whenever I try to map it along two axes at the same time. You can see the result in this screenshot (I replaced the vertical face texture with a grid to illustrate my point).

Here’s my shader:


// rock-decay BASE shader
textures/obsidian_terrain/rock-decay-base
{
	q3map_forceMeta
	q3map_nonPlanar
	q3map_shadeAngle 120
	//q3map_tcMod rotate 22
	
	//q3map_lightmapAxis z			//use on normal non-x'ing terrain mesh only
	q3map_lightmapMergable
	//q3map_lightmapSample Offset 1.0
	q3map_lightmapSampleSize 8		//default 16
}


// rock-decay BLEND shader - blends between horizontal & vertical surfaces
textures/obsidian_terrain/rock-decay-blend
{
	q3map_baseShader textures/obsidian_terrain/rock-decay-base
	
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0 0 1 )

	qer_editorimage textures/obsidian_terrain/rock-decay03.tga
	{
		map textures/obsidian_terrain/alpha.tga
		//map textures/obsidian_terrain/rock-decay03.tga
		tcGen vector ( 0.00390625 0.00390625 0 ) ( 0 0 0.00390625 )	//1/256 = 0.00390625
		rgbGen identity
	}
	{
		map textures/obsidian_terrain/rock-decay01.tga
		blendFunc blend
		alphaGen vertex
		rgbGen identity
	}
	{
		map $lightmap
		blendFunc filter
		rgbGen identity
	}
}

I can see why I’m having the problem, but I can’t think of any solutions. Any ideas?

I also tried using two tcGen vector directives in that stage, but it didn’t work, it only uses the first one.


(obsidian) #2

As an afterthought, I have a couple of feature requests that might be useful…

Instead of using either q3map_alphaMod dotproduct or dotproduct2, it might be useful to have a user set value:
q3map_alphaMod dotproduct N.N ( x y z )

Since we have q3map_tcGen ivector, it would be useful to have a stage specific tcGen ivector version of it as well.
tcGen ivector ( sx sy sz ) ( tx ty tz )


(ydnar) #3

tcGen is a renderer keyword, not compiler relevant, hence I have no control over it.

The problem in the screenshot is that you’re mapping the other texture onto two axes rather than one. You’ll need two blend shaders, one for N/S facing walls, and one for E/W facing walls.

However, what does it look like with a natural/organic texture? It doesn’t look like the mapping is that bad…

y


(obsidian) #4

The main thing that I was experimenting with was to eliminate any streaking that occurs on vertical terrain faces by mapping it along a different axis. But it doesn’t look like it’s currently possible or at least easy to do.

With the texture that I’m using for the vertical faces, it does look quite odd the way it’s mapped.

Problem that I see with two blend shaders is that I’ll probably run into problems where the N/S walls blend into the E/W walls and blend into the horizontal surfaces, since I can’t blend 3 textures simultaneously.

Hmm… so there’s no way to ‘box map’ the texture the way Q3 does by default but disable the z-axis mapping?


(obsidian) #5

This is what it would look like with normal z-axis texture projection. The vertical face streaking is what I’m trying to avoid with the shader above.

Here’s another screenshot of the problem using the shader above. The mapping along the NESW walls look acceptable, but I have ugly streaking problems along 45-degree surfaces.

I can box map the texture, which looks fine on all near vertical faces, but then changes to z-axis mapping along faces beyond 45-degrees from the vertical, resulting in a solid break:

Any thoughts?