Page 1 of 1

Terrain blending problems

Posted: Tue Dec 29, 2009 3:47 pm
by Bliccer
I've already posted that problem in my other thread, but it seems like nobody goes there.
First the pic: terrain
Now the question: How can I solve that shadow problem + that different light using thing (between that normal brush on the left side (where the shadow is) and the ones with the terrainblending texture)?
I'm using this shader for the blending.

Code: Select all

textures/suriel/dirt2grass
{
   	qer_editorimage textures/suriel/ter_dirtgrass.jpg
   	q3map_nonplanar
   	q3map_shadeAngle 120
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )

   	{
      map textures/suriel/grass_01_alpha.tga	// Primary texture
      rgbGen identity
   	}
  	{
      map textures/suriel/dirt_grass.tga	// Secondary
	blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
      alphaFunc GE128
      rgbGen identity
      alphaGen vertex
  	}

	{
      map $lightmap
      blendFunc GL_DST_COLOR GL_ZERO
      rgbGen identity
   }
}
I guess it is also necessary to know that I am using a normal texture on the "normal" brush. Just that rocky one.

Thanks for help =)

Re: Terrain blending problems

Posted: Tue Dec 29, 2009 4:03 pm
by obsidian
Do you also have an editor screenshot of the same area, also perhaps a screenshot in game with r_showtris 1? Another one with r_lightmap 1? It's still hard to tell exactly what's going on.

First off, it looks like there is a mismatch between the two textures and how they are tiling. You may want to select both surfaces and make sure they are axial as well on the same texture scale (your iVector settings in the shader makes the texture tile once every 256x256 units along the z-axis).

I also recommend you create a shader for your base texture with the following:

q3map_nonplanar
q3map_shadeAngle 120
q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )

Re: Terrain blending problems

Posted: Tue Dec 29, 2009 4:07 pm
by Bliccer
For the ivector I thought I have to use half of the image resolution it actually has...
Screens in a sec

Re: Terrain blending problems

Posted: Tue Dec 29, 2009 4:56 pm
by sock
Bliccer wrote:How can I solve that shadow problem + that different light using thing (between that normal brush on the left side (where the shadow is) and the ones with the terrainblending texture)?
Do what obs said, you cannot easily match a 'normal' texture projection and an ivector projection unless you use special editor textures. It is possible, but honestly it is not worth the trouble across large floor areas. Convert the texture on the left of the image to ivector (using the obs shader) and it will texture match. Also func_group all the floor brushes together to make sure the lighting is consistent.

Code: Select all

alphaFunc GE128
You are aware that the above statement in your grass blend shader makes hard edges? If you want a soft alpha blend then remove it so the dotproduct can use the full alpha range.

I did write a tutorial on all of the above and talked about alpha blending terrain to normal brushwork on page 6. Please take the time to read it, all of the source files are available to go with the tutorial so it should be easy to follow.

Re: Terrain blending problems

Posted: Tue Dec 29, 2009 5:42 pm
by Bliccer
So I have written a shader for my base texture now like obsidian suggested:

Code: Select all

textures/suriel/dirt_grass_ivector
{
	qer_editorimage textures/suriel/dirt_grass.tga
	q3map_nonplanar
	q3map_shadeAngle 120
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	{
		map textures/suriel/dirt_grass.tga
		rgbGen identity
	}
}
Without lightcompile the terrain looks good:
00_ingamewolight

But when it comes to light it looks like this:
06_ingamelightmap3

So here are the tris and the lightmap screenshots:
03_ingametris
04_ingamelightmap

Now the shadow somehow splits up into 3 parts:
05_ingamelightmap2

Editorshot: 01_editor

This is the shader for the green grasstexture:

Code: Select all

textures/suriel/grasswplants
{
        qer_editorimage textures/suriel/grass_01.tga
	q3map_nonplanar
	q3map_shadeangle 120
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_surfacemodel models/mapobjects/suriel/nggrass.ase 100 0.15 0.6 1.2 0 360 1
	{
		map textures/suriel/grass_01.tga
		rgbGen identity
	}
}

And this is the modified one for the blending texture:

Code: Select all

textures/suriel/dirt2grass
{
   	qer_editorimage textures/suriel/ter_dirtgrass.jpg
   	q3map_nonplanar
   	q3map_shadeAngle 120
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )

   	{
      map textures/suriel/grass_01_alpha.tga	// Primary texture
      rgbGen identity
   	}
  	{
      map textures/suriel/dirt_grass.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
   }
}

Re: Terrain blending problems

Posted: Tue Dec 29, 2009 6:05 pm
by obsidian
Your grass shader needs a lightmap stage.

Make sure all terrain textures have a lightmap stage.

Make sure all terrain textures have the same light affecting q3map_ directives as I wrote above.

That includes the dirt, grass and dirt-to-grass blend shaders.

Re: Terrain blending problems

Posted: Tue Dec 29, 2009 7:04 pm
by jal_
I don't know if someone said it already, but the terrain in that screenshot is in desperate need of q3map_lightmapaxis z (in all shaders)

Re: Terrain blending problems

Posted: Wed Dec 30, 2009 12:49 pm
by Bliccer
Light works nicely now. Only the shadow and all explosions are getting split up. It seems like the terrain blending texture doesn't cast any shadow or prohibit the explosions being displayed.

screen

I've also already goruped the whole terrain, but no effect.

Re: Terrain blending problems

Posted: Wed Dec 30, 2009 1:10 pm
by TTI
Bliccer: There's nothing you can do about it. I'd personally use surfaceparm nomarks for the terrain shaders.

Re: Terrain blending problems

Posted: Wed Dec 30, 2009 1:27 pm
by Bliccer
Hm... but looks totally idiotic. :/