phong shader +normal map?


(ACROBAT) #1

Is it possible to combine a phong shader with a normal map shader

// ------------------------------------------------------------------------------
// outer part for detail shader + Phong
// ------------------------------------------------------------------------------

textures/test/stucco_grime_shader
{
q3map_nonplanar
q3map_shadeangle 120
qer_editorimage textures/test/stucco_grime_image.tga
{
map $lightmap
rgbGen identity
}
{
map textures/test/stucco_grime
blendFunc filter
}
{
map textures/test/rockdetail
blendFunc GL_DST_COLOR GL_SRC_COLOR
detail
tcMod scale 9.1 9.2
}
}

// ------------------------------------------------------------------------------
//Normal map shader
// ------------------------------------------------------------------------------

    textures/test/cactusbump
{
qer_editorimage textures/test/cactusshader 
q3map_lightmapsamplesize 1x1
q3map_normalimage textures/test/cactus_local
{
map $lightmap
}
{
map textures/test/cactus
blendFunc GL_DST_COLOR GL_ZERO
}
}

The main problem I wonder about is that they both use different blend functions on the map actual base texture? Any ideas?


(carnage) #2

without testing im pretty sure that it will work since normal mapping in quake3 bakes the final lighting to the lightmap so you wouldn’t actually be doing anything different other than rendering a more detailed lightmap

you shouldn’t be worrying about the blend functions since they don’t directly impact the effects of bumpmaping or phong shading, they simply effect what is on the lightmap. how you apply the lightmap is then up to you but should not require any special blends etc


(obsidian) #3

Yes, entirely possible. The two shaders posted are more alike than you think.

First stage is a lightmap.
Second stage is a filtered texture.
Third stage in the first shader is an optional detail layer.

So other than the third stage and the q3map_* directives, these two shaders are more or less the same.