Jump to content

horizon blending, shader clashing problem with dot2product


Recommended Posts

Posted

Hi all,

 

In light of shaders... here is a clashing one, and I kinda need your help.

I am working on a horizon blending, since my singleplayer map is part of an island group in the ocean, so i got most of it all set up. The blending into the horizon works like a charm, except I am having a shader clash problem.

 

w97fbp.jpg

 

2ypn6ad.jpg

 

So as you see, there is a very distinctive problem in colorization here, where my dot2product blending ends, and my shader for the horizon blending starts. They are both the very same texture, althought the blending in dot2product is making it more.... light, thus creating an obvious seem.

 

My shader is as following.

textures/sp_terrain/ter_sandsand
{
	q3map_shadeangle	120
	qer_editorimage	textures/sp_terrain/ter_sandsand
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_material	Sand
	q3map_nonplanar
	q3map_tcGen	ivector ( 256 0 0 ) ( 0 256 0 )
    {
        map textures/sp_terrain/ter_sand1
        rgbGen identity
    }
    {
        map textures/sp_terrain/ter_sand3
        alphaFunc GE128
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        rgbGen identity
        alphaGen vertex
    }
    {
        map $lightmap
        blendFunc GL_DST_COLOR GL_ZERO
        rgbGen identity
    }
}
textures/sp_terrain/ter_sandsky
{
	q3map_shadeangle 120
	qer_editorimage textures/sp_terrain/ter_sandsky
	q3map_material Sand
	q3map_nonplanar
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
    
    {
        map $lightmap
        rgbGen identity
    }
    {
		map textures/sp_terrain/ter_sand3
		blendFunc filter
		detail
		rgbGen identity
    }
    {
       map textures/sp_terrain/ter_horizon
       blendFunc blend
       rgbGen identityLighting
       alphaGen oneMinusVertex
    }
}

The sandsand is a mix of a light sand and a darker sand (under water the sand is more darker than above water). The sandsky texture blends the dark sand into the horizon, which works fine, but i am trying to match it up with my dot2product sand, which isn't going as planned as you can see.

 

This has to do with the dot2product shader, where, even at 100% visibility on the secondairy image, it still shines through some detail, this causes the sand3 to become brighter (since there is still shine through). So i am kind of in an impasse on how to fix this. Anybody has suggestions? cause this bugs the hell out of me. Else i may need to do some sloping with rocks to cover this up.

Posted

Okay, i was pulling my hair out (i dont have much left anyway), but .... what if i modify the q3map_alphamod dotproduct. It's now set to 0.75, which is the best blend possible, but what if i up to 1? Would that make it stronger? I am trying to read through the documentation but wouldn't that affect the blend?

 

q3map_alphaMod dotproduct ( X Y Z)

It is used to blend textures using alphaFunc or blendFunc in the shader's second pass, with the falloff depending on the surface's normal axis. This is achieved by doing a vector dot product of the specified normalized vector value ( X Y Z ) and the vertex normal which yields the amount of blending. The dot product operation multiplies each element of one vector against the corresponding elements of a second vector, then adds them. Examples:

( 0 0 1 ) dp ( 0 0 1 ) = 0 * 0 + 0 * 0 + 1 * 1 = 1
( 0 0 1 ) dp ( 0 0 0.5 ) = 0 * 0 + 0 * 0 + 1 * 0.5 = 0.5
( 0.5 0.5 1 ) dp ( 0 0.5 0.5 ) = 0.5 * 0 + 0.5 * 0.5 + 1 * 0.5 = 0.75

 

Posted

I never managed to make horizon blending work, but please, if you discover new information please share it since it's very useful for every mapper here.

Posted

Long story short, this has to do with the alpha channel in the texture. dot2product is set up as texture blending, so the secondary texture is put over the first texture. Even with 100% visibility on the secondary texture, the primary always shines through a bit, hence it becomes brighter, since the primary texture is pretty bright. If my chosen texture would be the primary texture, without any alpha applied to it, it would work fine. However, as you may guessed, this was my secundairy texture, so it becomes brighter. Switching it around is a solution, however, the problem lies than in blending it back to the brighter sand texture on the beach. 

 

The outcome in mind: I ll create an extra sand1 - dirt and sand3 - dirt shader and add those in between, so what will happen is bright sand ... line of dirt .... darker sand  .... and then fade away. This requires some terrain modifications, but I am okay with that for in the future.

 

For now, I used primary sand 1 and played with it. Result, seamsless blend,

2d0ce10.jpg

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...