Phong Shading, what is it ?!?


(freekill) #1

wtf is that??


(kyleb) #2

http://images.google.com/images?svnum=10&hl=en&lr=&ie=UTF-8&oe=UTF-8&q=phong+shading&spell=1


(JIM_BOB7813) #3

Try here:http://tiger.towson.edu/~tzeger1/3dfx/information/help.html


(Doc) #4

Just a thought, he might be referring to those textures with “HONG PHONG” written on them several times. Why?


(system) #5

Head over to q3map2-forums. Or do a search in the q3map2 forum.
They will explain it to you.

Phong-shaded edges are looking smoother and rounder than other surfaces.

No Shading:

Shaded Model:

Both Models are low-poly


(sock) #6

The “Hong phong” texture is just a special placeholder EDITOR ONLY texture so that you can see where phong shading is being applied to. The name “Hong Phong” is my play on words to the cool cartoon “Hong Kong Phooey”! :smiley:

http://www.bcdb.com/pages/Hanna-Barbera_Studios/G-J/Hong_Kong_Phooey/
http://www.cartoonnetwork.com/watch/web_shows/hkp/

Sock
:moo:


(seven_dc) #7

So how do you use phong shading in Radiant? Is it done just by applying a texture? If so, how do you know wich are phong shaded?


latin girl Cam


(Doc) #8

I was wondering how they got terrain to look so smooth! :clap:


(freekill) #9

cool i really had no reson to ask i was just curious
now ima gonna cover my whole map in phong hehe


(seven_dc) #10

Mee too. After someone would tell me how to do it. I tried to search the q3map2-forums but had no luck. :bored:


Curvy Cam


(sock) #11

Phong shading is a compiler option ONLY and is done on a texture by texture basis. To enable phong shading you need to create a brand new shader for each extra texture you are going to apply it to.

This is very important, you need to know the basics of shaders and how to create them FIRST. I recommend you check the shader manual you get with SDRadiant or check this site : Maj’s Shader Manual - http://woekitten.org/misc/ Blindly creating shaders without any understanding of what they do and how they are structured will get you nowhere fast. Take time to learn them because shader technology is very important.

Open up a shader file (In the SCRIPTS directory) for example “egypt_walls_sd.shader”. The first shader in this file is a phong shader. To highlight a phong texture to the compiler you need to include 2 extra lines as follows:

q3map_nonplanar - This tells the compiler this is a phong lighting shader.
q3map_shadeangle 90 - The texture edge with an angle less than this value will have phong lighting applied.

Phong lighting is applied to the edges of the texture surface to give the illusion of “smoothness” or “curvyness”. Applying it to all your map is not realistic because not every corner/edge is curved. It also can produce some very wierd lighting effects sometimes so test this feature first.

Phong shading is a compiler option so it cannot be seen easily in the map editor. So I recommend you create all phong shaders as different to the original texture with a “_phong” extension to the name. Also create a special version of the existing texture with the words “PHONG” on it so that it can easily be recognised in the editor. At the top of the shader is the command “qer_editorimage” which tells the editor which texture to display. This does not effect the texture in game, only the editor.

Original you had to add a extra parameter to the compiler on the light stage. (-shade) This option would tell the compiler to check for phong lighting shaders and apply them. Ydnar recently told me that this option is no longer needed but I’m not sure which version of the compiler this applies to. If in doubt then add the (-shade) option to the light stage of your compiler process.

Sock
:moo:


(jah) #12

sock i searched for those 2 parameters in those doc’s you referenced and in the shader manual that comes with GTK and found nothing… :frowning:

after that i tried to stick it in a shader for a terrain created using easygen:


textures/123/terrain_0
{

	q3map_nonplanar
	q3map_shadeangle 90

	q3map_baseshader textures/123/terrain_base
	surfaceparm landmine
	surfaceparm gravelsteps
	{
		map textures/123/grass.tga
		tcMod scale 0.234 0.234
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
	}
}

and added that -shade command to my compile options and the compiler didn’t recognize the command…

compiled the map… went to ET and… wow… nothing changed :frowning:

what am i missing here?

please help

thx in advance

:jah:


(sock) #13

Well the link I gave you is about the basics of shaders and how they work. The link will give you an insight into how shaders are put together and what sections do what not a guide on the compiler. As I said earlier the two new commands are COMPILER OPTIONS ONLY. If you want info on the compiler you need to check out the following links.

http://www.shaderlab.com/q3map2/manual/
http://www.inficad.com/~mnichol/dummies/index

If the compiler did not recognise the command then it will obviously not work in the game! The (-shade) option is used only on the LIGHT stage of the compile as phong shading is a trick with light maps. The light stage is the 3 part of the compile process but for further information on the compiler check: http://www.shaderlab.com/q3map2/manual/

Unfortunately q3map2/sdmap has a massive amount of parameters, but luckly you dont need alot of them, but its extremely useful to have that link if you are unsure about what the compiler does. I really cannot stress enough that you take the time to understand the compile process and shader technology before rushing at phong shading and expecting it to work first time.

Sock
:moo:


(freekill) #14

thanks alot sock u made using phong much more difficult now…
im not gonna use it anymore :disgust:


(opus) #15

hate to bring up this thread again but:

Once we’ve created the new phong shader (w00t, never created a shader before, always started and got ticked off at the system :)), do we then use our normal compile options (say w/ q3map2) or do we add -shade to the -light stage?


(SCDS_reyalP) #16

use normal compile options.

and while you compile, listen to the classic cypress hill tune ‘hits from the phong’ :moo:


(sock) #17

Finally got round to creating an article on Phong Shading and how to use it. Its still a work in progress document and all feedback and suggestions are always welcome.

http://www.planetquake.com/simland/pages/articles/phongshading1.htm

Sock
:moo:


(nUllSkillZ) #18

Thanks for another very helpful tutorial.
Very well written. And easy to understand.

Haven’t tried this yet. Because I still call me a nOOb.
But if ever I get a map to work this will be a great help.

I haven’t found the link to the shader manual in the article.
So I’ve googled a little bit and have found two manuals:
Q3Map2 Shader Manual
Quake III Arena Shader Manual

Theres also a german version / translation of the second one:
Quake III Arena Shader Manual Deutsche Version


(sock) #19

I have re-arranged the article, corrected some more spelling/grammer mistakes and condensed down the shader explaination section.

Also updated the shader manual links, thks nUllSkillZ for the links. :smiley:

Sock
:moo:


(PSIonic) #20

Hi.

Sock, I totally agree that your tutorial is very well written!

I’ve been trying to implement Phong shading in my map as well. Read through your tutorial to make sure I had done it correctly. Everything matches except for the fact that the .shader file I created which contains the phong texture isn’t named after my .bsp file. That shouldn’t matter right? (Otherwise how would we use existing phong textures?). The compiler says “entering resistance.shader” (my shader) when it compiles, so it must be finding it.

I have tried placing a 12 sided ‘cylinder’ brush in my map with an official SD phong texture (a snow one). In-game the brush still appears with high shadow contrasts between the brush’s faces. This has led me to believe that I have probably set up my .shader correctly, but am lacking some compiler switch or something along those lines.

For completness, here are the file paths:

Textures used by the shader:
C:\Games\Wolfenstein - Enemy Territory\etmain extures\resistance\organ_metal_1.jpg
C:\Games\Wolfenstein - Enemy Territory\etmain extures\resistance\organ_metal_1_editor.jpg

The shader:
C:\Games\Wolfenstein - Enemy Territory\etmain\scripts\resistance.shader

The compile command I am using (from GTK Radiant’s BSP menu):
! “C:\Games\Wolfenstein - Enemy Territory\q3map_2.5.12_win32_x86\q3map2” -v # -game et -fs_basepath “C:/Games/Wolfenstein - Enemy Territory/” -meta -mv 1024 -mi 6144 $ && ! “C:\Games\Wolfenstein - Enemy Territory\q3map_2.5.12_win32_x86\q3map2” # -game et -fs_basepath “C:/Games/Wolfenstein - Enemy Territory/” -vis -saveprt $ && ! “C:\Games\Wolfenstein - Enemy Territory\q3map_2.5.12_win32_x86\q3map2” -v # -game et -fs_basepath “C:/Games/Wolfenstein - Enemy Territory/” -light -fast -shade -samples 2 -filter -bounce 8 -external -lightmapsize 256 $

I am using q3map2 version 2.5.12

The contents of the resistance.shader file:

textures/resistance/organ_metal_1_phong
{
	q3map_nonplanar
	q3map_shadeangle 60
	qer_editorimage textures/resistance/organ_metal_1_editor.tga
	{
		map $lightmap
		rgbGen identity
	}
	{
		map textures/resistance/organ_metal_1.tga
		blendFunc filter
	}
}

I have tried using a high shadeangle value like 179 as well. The result is the same. Some tutorials say that higher values include more faces and others say lower values do… so I thought I better try several angles! :cool:

Any idea why the compiler isn’t rendering my textures with phong shading? It would be great if anyone could help me with that! :drink: