Mixture of blending and Phong shading


(Teuthis) #1

Maybe a stupid question but can blending and Phong shading be Mixed and Used for the Same Brush? I was actually about to Release my Map this week but i noticed that some Walls Look unrealistic with too many hard edges and shadows. Imortantly, the Walls Are using a blending texture so the question is whether I can apply more than One Shader for These Textures? I think this is a Common Situation as You might have Run into this Situation as well. So can we have a blended Texture that Uses a phong Shader as well. Also Even if I can do this and am using Standard Textures from the Pak.0 file I Need to copy and Rename them., right? Otherwise I apple the Phong Shader also to Other peoples work once the Shader Finds this Texture in Other Maps, right?

Thanks for Taking the Time


(stealth6) #2

You don’t need to copy the textures. Also you don’t apply 2 shaders. You combine the 2 effects into 1 shader. If you post what you have now it’s easier.


(Mateos) #3

Look at the vanilla maps sources, well even if they’re using the PCX method they have both smoothed lighting (Phong Shading) and blending.

You can use q3map_lightmapMergeable to have the whole terrain on a single lightmap and thus no cut on shadows; q3map_NonPlanar may help too if it isn’t enough.


(Teuthis) #4

Great. Will post my Shader tomorrow. Am currently enjoying the Spanisch Beach :slight_smile:


(Teuthis) #5

Mateos, I’m not sure what you mean with ‘Code balises @@’ so I Need unfortunately to copy/paste my Problem the old Fashion way:

so I have a shader for vertical blending of two Standard textures, located under /egypt_walls_sd/debri_m05.tga and /temperate_sd/rock_grayvar.tga. The Problem is now that I Need to somehow update the shader to use phong shading as well. I could get it to work on textures that are not blended, so my Problem is restricted to this one (and others) that are blended. your help is highly appreciated.

// ======================================================================
// shader for vertical blending-roofcave
// ======================================================================
textures/terrain_example/rock_roof
{
qer_editorimage textures/terrain_example/rock_roof.tga

q3map_nonplanar
q3map_shadeAngle 75

{
	// Primary
	map textures/egypt_walls_sd/debri_m05.tga
	rgbGen identity
}
{
	// Secondary
	map textures/temperate_sd/rock_grayvar.tga
	blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
	alphaGen vertex
	rgbGen identity
}
{
	map $lightmap
	blendFunc GL_DST_COLOR GL_ZERO
	rgbGen identity
}

}


(Mateos) #6

The “code” one.

[QUOTE=Teuthis;506212]so I have a shader for vertical blending of two Standard textures, located under /egypt_walls_sd/debri_m05.tga and /temperate_sd/rock_grayvar.tga. The Problem is now that I Need to somehow update the shader to use phong shading as well. I could get it to work on textures that are not blended, so my Problem is restricted to this one (and others) that are blended. your help is highly appreciated.

// ======================================================================
// shader for vertical blending-roofcave
// ======================================================================
textures/terrain_example/rock_roof
{
qer_editorimage textures/terrain_example/rock_roof.tga

q3map_nonplanar
q3map_shadeAngle 75

{
	// Primary
	map textures/egypt_walls_sd/debri_m05.tga
	rgbGen identity
}
{
	// Secondary
	map textures/temperate_sd/rock_grayvar.tga
	blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
	alphaGen vertex
	rgbGen identity
}
{
	map $lightmap
	blendFunc GL_DST_COLOR GL_ZERO
	rgbGen identity
}

}[/QUOTE]

Can you post a screen, maybe it’s the angle of shading which isn’t enough, or something else


(Teuthis) #7

thanks Mateos,

the shader I posted is the pure blending shader. I tried in incorporate also the phong shader but then the blending didn’t work anymore. I was hopeing someone could tell me what I have to add here in this shader to make both work, the blending and the phong.


(stealth6) #8

I’m confused. The shader you posted is Blending and Phong already. Does that shader blend or not? If it does play around with q3map_shadeAngle 75 to change the lighting. Here are some examples:
http://www.simonoc.com/pages/articles/phongshading3.htm

If it doesn’t I don’t think there’s something wrong with the shader. Are you using a PCX file? I’m not sure if it matters, but I was just interested since I don’t see q3map_tcGen ivector in your shader. I’m scratching my head wondering how you make nice terrain without using q3map_tcGen ivector actually :smiley: . Do you have any screenshots?


(Teuthis) #9

I’m equally confused now. I don’t use a PCX file, at least not that I know of one. Blending works fine (see Pictures attached). I have no idea what this q3map_tcGen ivector is. I modified that shader file from sockter to fit my Needs. I hope I didn’t miss some essential parts. If you have a Suggestion to modify my shader please let me know.

as you see on the Pictures, I have some sharp edges in the blending textures and I was hoping that that a phong would fix this. If I already have a phong effect in my shader I guess there is not much I can do here, right?

do I Need to add this q3map_tcGen ivector in my shader and if so what will this command do with the texture? thanks for your help btw







(Teuthis) #10

actually I just double checked my shader file and I have this q3map_tcGen ivector in the shaders for horizontal blending but the shader I posted is for vertical blending and does not has this q3map_tcGen ivector in it. Hope that’s right, if not please let me know.

thanks


(Mateos) #11

I know this issue, and the solution: use custom 32x32 q3map_editorimage, different from the original shader or texture name, and the compiler will apply the texture during the compilation like if everything was flat… I least I got this working on 2 maps ^^’


(Teuthis) #12

omg, Mateos, anything you don’t know about the GTK Radiant? if this works that would be awesome. You already earned a sentence in the readme file anyway.

However, as a recreational mapper I Need this info on a tea spoon. how do I use this 32x32 q3map_editorimage? you mean I have to Change the shader file to say 32x32 q3map_editorimage instead of qer_editorimage textures/terrain_example/rock_roof.tga as it is?


(Mateos) #13

I made myself several files which are the same as common/terrain.tga: a square two-colored texture with text over it.

Then in your shader, you add at the top q3map_editorimage textures/theutis/myterrain1.tga (you don’t need to include it in the PK3 btw).

Depending on the angle, it will be better or fail; When I see you tunnel which is like Supply one, well, here on Supply WE it failed :confused: But several rocky parts of the maps have been smoothed using this method, and so for 1944 Huertgen Forest. Played a lot with shaders but not enough to find out if it’s impossible ^^’


(stealth6) #14

q3map_tcGen ivector projects your texture onto your brushes at compile time. So you don’t have to align all the grass brushes and fit the texture, the compiler will do it for you.

Here’s an example:


textures/stealth6/ter_moss1_3
{
   qer_editorimage textures/stealth6/ter_moss1_3.tga
   q3map_nonplanar
   q3map_shadeangle 60
   q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 )
   {
      map textures/stealth6/ter_moss1_3.tga
      rgbGen identity
   }
   {
      map $lightmap
      blendFunc GL_DST_COLOR GL_ZERO
      rgbGen identity
   }
}

That’s for on the floor and it has phong shading. The numbers behind q3map_tcGen ivector are how the texture will be projected.
(x y z) (x y z)

So in my example it’s X and Y and the texture is stretched to 512 units. So every 512 units the texture wil repeat along the X & Y axis.

Doing walls is slightly trickier since it can be along the Z X axis or the Z Y (or maybe even something in between is possible? I never experimented with that)


textures/stealth6/rock_wall_northsouth
{
   qer_editorimage textures/temperate_sd/rock_ugly_brown.tga
   q3map_nonplanar
   q3map_shadeangle 60
   q3map_tcGen ivector ( 512 0 0 ) ( 0 0 512 )
   {
      map textures/temperate_sd/rock_ugly_brown.tga
      rgbGen identity
   }
   {
      map $lightmap
      blendFunc GL_DST_COLOR GL_ZERO
      rgbGen identity
   }
}

That’s for walls that run north to south.


textures/dinitext/rock_wall_eastwest
{
   qer_editorimage textures/temperate_sd/rock_ugly_brown.tga
   q3map_nonplanar
   q3map_shadeangle 60
   q3map_tcGen ivector ( 0 512 0 ) ( 0 0 512 )
   {
      map textures/temperate_sd/rock_ugly_brown.tga
      rgbGen identity
   }
   {
      map $lightmap
      blendFunc GL_DST_COLOR GL_ZERO
      rgbGen identity
   }
}

Wall from east to west.

I don’t think using q3map_tcGen ivector will effect the blending, but it makes doing terrain way way easier. Phong shading is just these 2 lines:


q3map_nonplanar
q3map_shadeangle 60

You can change the angle to get different effects as I said before:
http://www.simonoc.com/pages/articles/phongshading3.htm

I think what Mateos was saying is that maybe you’ve applied the wrong texture in radiant, but you can’t see it because they all have the same appearance in radiant? By changing:


q3map_editorimage textures/theutis/myterrain1.tga

You change the image used in radiant as to make it clearer which texture is dirt, rock wall and which one is inbetween.


(Mateos) #15

Nice information. Gotta try that in a tunnel :slight_smile: