Add support for transparent materials and .dds normal maps.
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
parent
8caf2ef24d
commit
c383cda2c6
3 changed files with 187 additions and 75 deletions
|
@ -4,9 +4,9 @@
|
|||
PARAMETERS: There are two forms of cube map texture:- vertical cross and 6 images.
|
||||
Either can be used - alternative forms are shown in <parameters> and in <texture-unit>
|
||||
|
||||
The reflection is set proportional to the shininess of the material. Thus by
|
||||
varying the material shininess value over or between objects the amount of
|
||||
refection can be controlled. The overall amount of reflection may be
|
||||
The reflection is set proportional to the shininess of the material. Thus by
|
||||
varying the material shininess value over or between objects the amount of
|
||||
refection can be controlled. The overall amount of reflection may be
|
||||
adjusted by the use of <refl_correction> -1.0 (fully transparent)- 1.0 (fully opaque).
|
||||
|
||||
The overall values of the noisiness, coloured fringing or fresnel effect may be adjusted
|
||||
|
@ -16,33 +16,35 @@ If your result is too dark/too light the overall ambient light value can be adju
|
|||
by the use of <ambient_correction>. This correction also takes out some of the blueness
|
||||
added as default to compensate for the lack of reflection.
|
||||
|
||||
To use a reflection map set <reflect_map> to 1,and the path to the map texture in
|
||||
To use a reflection map set <reflect_map> to 1,and the path to the map texture in
|
||||
<texture n="8">
|
||||
|
||||
A default, null, bumpspec is specified as texture unit 4. To provide a custom bumpspec map,
|
||||
define <texture n="4"> in the derived effect file
|
||||
|
||||
USE: To use the default reflection effect (controlled by material shininess values) use
|
||||
|
||||
If you are using Direct Draw Surface (.dds) files for your bumpmap set <normalmap_dds> to 1.
|
||||
|
||||
USE: To use the default reflection effect (controlled by material shininess values) use
|
||||
|
||||
<effect>
|
||||
<inherits-from>Effects/reflect-bump-spec</inherits-from>
|
||||
<object-name>Fuselage</object-name>
|
||||
</effect>
|
||||
|
||||
|
||||
To use your own reflection effect, use
|
||||
|
||||
|
||||
<effect>
|
||||
<inherits-from>Aircraft/Lightning/Models/Effects/lightningreflect</inherits-from>
|
||||
<object-name>Fuselage</object-name>
|
||||
</effect>
|
||||
|
||||
|
||||
in your model file.
|
||||
|
||||
To use your own effect place your efffect file containing something like this:
|
||||
|
||||
<name>Effects/lightningreflect</name>
|
||||
<inherits-from>Effects/reflect-bump-spec</inherits-from>
|
||||
|
||||
|
||||
and the the modified tags in the path as above
|
||||
|
||||
EXAMPLES: You can find examples of both usages in the Hunter and Lightning models.
|
||||
|
@ -104,13 +106,14 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<refl_correction>0.0</refl_correction>
|
||||
<ambient_correction>0.05</ambient_correction>
|
||||
<reflect_map>0</reflect_map>
|
||||
<normalmap_dds>0</normalmap_dds>
|
||||
</parameters>
|
||||
|
||||
<generate>
|
||||
<tangent type="int">6</tangent>
|
||||
<binormal type="int">7</binormal>
|
||||
</generate>
|
||||
|
||||
|
||||
<technique n="9">
|
||||
<predicate>
|
||||
<and>
|
||||
|
@ -133,77 +136,157 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<pass>
|
||||
<lighting>true</lighting>
|
||||
<material>
|
||||
<active><use>material/active</use></active>
|
||||
<ambient><use>material/ambient</use></ambient>
|
||||
<diffuse><use>material/diffuse</use></diffuse>
|
||||
<specular><use>material/specular</use></specular>
|
||||
<emissive><use>material/emissive</use></emissive>
|
||||
<shininess><use>material/shininess</use></shininess>
|
||||
<color-mode><use>material/color-mode</use></color-mode>
|
||||
<active>
|
||||
<use>material/active</use>
|
||||
</active>
|
||||
<ambient>
|
||||
<use>material/ambient</use>
|
||||
</ambient>
|
||||
<diffuse>
|
||||
<use>material/diffuse</use>
|
||||
</diffuse>
|
||||
<specular>
|
||||
<use>material/specular</use>
|
||||
</specular>
|
||||
<emissive>
|
||||
<use>material/emissive</use>
|
||||
</emissive>
|
||||
<shininess>
|
||||
<use>material/shininess</use>
|
||||
</shininess>
|
||||
<color-mode>
|
||||
<use>material/color-mode</use>
|
||||
</color-mode>
|
||||
</material>
|
||||
<blend>
|
||||
<active><use>blend/active</use></active>
|
||||
<source><use>blend/source</use></source>
|
||||
<destination><use>blend/destination</use></destination>
|
||||
<active>
|
||||
<use>blend/active</use>
|
||||
</active>
|
||||
<source>
|
||||
<use>blend/source</use>
|
||||
</source>
|
||||
<destination>
|
||||
<use>blend/destination</use>
|
||||
</destination>
|
||||
</blend>
|
||||
<shade-model><use>shade-model</use></shade-model>
|
||||
<cull-face><use>cull-face</use></cull-face>
|
||||
<rendering-hint><use>rendering-hint</use></rendering-hint>
|
||||
<shade-model>
|
||||
<use>shade-model</use>
|
||||
</shade-model>
|
||||
<cull-face>
|
||||
<use>cull-face</use>
|
||||
</cull-face>
|
||||
<rendering-hint>
|
||||
<use>rendering-hint</use>
|
||||
</rendering-hint>
|
||||
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<image><use>texture[0]/image</use></image>
|
||||
<filter><use>texture[0]/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||
<internal-format><use>texture[0]/internal-format</use></internal-format>
|
||||
<image>
|
||||
<use>texture[0]/image</use>
|
||||
</image>
|
||||
<filter>
|
||||
<use>texture[0]/filter</use>
|
||||
</filter>
|
||||
<wrap-s>
|
||||
<use>texture[0]/wrap-s</use>
|
||||
</wrap-s>
|
||||
<wrap-t>
|
||||
<use>texture[0]/wrap-t</use>
|
||||
</wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[0]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
<unit>4</unit>
|
||||
<image><use>texture[4]/image</use></image>
|
||||
<filter><use>texture[4]/filter</use></filter>
|
||||
<wrap-s><use>texture[4]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[4]/wrap-t</use></wrap-t>
|
||||
<internal-format><use>texture[4]/internal-format</use></internal-format>
|
||||
<image>
|
||||
<use>texture[4]/image</use>
|
||||
</image>
|
||||
<filter>
|
||||
<use>texture[4]/filter</use>
|
||||
</filter>
|
||||
<wrap-s>
|
||||
<use>texture[4]/wrap-s</use>
|
||||
</wrap-s>
|
||||
<wrap-t>
|
||||
<use>texture[4]/wrap-t</use>
|
||||
</wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[4]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
|
||||
|
||||
<texture-unit>
|
||||
<unit>5</unit>
|
||||
<type><use>texture[5]/type</use></type>
|
||||
<type>
|
||||
<use>texture[5]/type</use>
|
||||
</type>
|
||||
|
||||
<!-- use this form for a cube cross -->
|
||||
<!--<image><use>texture[5]/image</use></image>-->
|
||||
|
||||
<!-- use this form for a 6 image cube map -->
|
||||
<images><use>texture[5]/images</use></images>
|
||||
<images>
|
||||
<use>texture[5]/images</use>
|
||||
</images>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
<unit>6</unit>
|
||||
<type><use>texture[6]/type</use></type>
|
||||
<image><use>texture[6]/image</use></image>
|
||||
<filter><use>texture[6]/filter</use></filter>
|
||||
<wrap-s><use>texture[6]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[6]/wrap-t</use></wrap-t>
|
||||
<type>
|
||||
<use>texture[6]/type</use>
|
||||
</type>
|
||||
<image>
|
||||
<use>texture[6]/image</use>
|
||||
</image>
|
||||
<filter>
|
||||
<use>texture[6]/filter</use>
|
||||
</filter>
|
||||
<wrap-s>
|
||||
<use>texture[6]/wrap-s</use>
|
||||
</wrap-s>
|
||||
<wrap-t>
|
||||
<use>texture[6]/wrap-t</use>
|
||||
</wrap-t>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
<unit>7</unit>
|
||||
<type><use>texture[7]/type</use></type>
|
||||
<image><use>texture[7]/image</use></image>
|
||||
<filter><use>texture[7]/filter</use></filter>
|
||||
<wrap-s><use>texture[7]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[7]/wrap-t</use></wrap-t>
|
||||
<type>
|
||||
<use>texture[7]/type</use>
|
||||
</type>
|
||||
<image>
|
||||
<use>texture[7]/image</use>
|
||||
</image>
|
||||
<filter>
|
||||
<use>texture[7]/filter</use>
|
||||
</filter>
|
||||
<wrap-s>
|
||||
<use>texture[7]/wrap-s</use>
|
||||
</wrap-s>
|
||||
<wrap-t>
|
||||
<use>texture[7]/wrap-t</use>
|
||||
</wrap-t>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
<unit>8</unit>
|
||||
<image><use>texture[8]/image</use></image>
|
||||
<filter><use>texture[8]/filter</use></filter>
|
||||
<wrap-s><use>texture[8]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[8]/wrap-t</use></wrap-t>
|
||||
<internal-format><use>texture[0]/internal-format</use></internal-format>
|
||||
<image>
|
||||
<use>texture[8]/image</use>
|
||||
</image>
|
||||
<filter>
|
||||
<use>texture[8]/filter</use>
|
||||
</filter>
|
||||
<wrap-s>
|
||||
<use>texture[8]/wrap-s</use>
|
||||
</wrap-s>
|
||||
<wrap-t>
|
||||
<use>texture[8]/wrap-t</use>
|
||||
</wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[0]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
|
@ -271,46 +354,67 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<uniform>
|
||||
<name>rainbowiness</name>
|
||||
<type>float</type>
|
||||
<value><use>rainbowiness</use></value>
|
||||
<value>
|
||||
<use>rainbowiness</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- set the amount of fresnel effect colour 0.0 - 1.0 -->
|
||||
<uniform>
|
||||
<name>fresneliness</name>
|
||||
<type>float</type>
|
||||
<value><use>fresneliness</use></value>
|
||||
<value>
|
||||
<use>fresneliness</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- set the amount of noisiness 0.0 - 1.0 -->
|
||||
<uniform>
|
||||
<name>noisiness</name>
|
||||
<type>float</type>
|
||||
<value><use>noisiness</use></value>
|
||||
<value>
|
||||
<use>noisiness</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- The reflection is set proportional to the shininess of the material.
|
||||
<!-- The reflection is set proportional to the shininess of the material.
|
||||
The amount of reflection may be adjusted by the use of this correction
|
||||
-1.0 (fully transparent)- 1.0 (fully opaque) -->
|
||||
<uniform>
|
||||
<name>refl_correction</name>
|
||||
<type>float</type>
|
||||
<value><use>refl_correction</use></value>
|
||||
<value>
|
||||
<use>refl_correction</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- set the amount of ambient light correction 0.0 - 1.0 -->
|
||||
<uniform>
|
||||
<name>ambient_correction</name>
|
||||
<type>float</type>
|
||||
<value><use>ambient_correction</use></value>
|
||||
<value>
|
||||
<use>ambient_correction</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- use a reflection map-->
|
||||
<uniform>
|
||||
<name>reflect_map</name>
|
||||
<type>float</type>
|
||||
<value><use>reflect_map</use></value>
|
||||
<value>
|
||||
<use>reflect_map</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- normalmap is .dds-->
|
||||
<uniform>
|
||||
<name>normalmap_dds</name>
|
||||
<type>float</type>
|
||||
<value>
|
||||
<use>normalmap_dds</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
||||
</PropertyList>
|
|
@ -1,6 +1,6 @@
|
|||
// -*- mode: C; -*-
|
||||
// Licence: GPL v2
|
||||
// Author: Vivian Meazza.
|
||||
// Author: Vivian Meazza.
|
||||
|
||||
#version 120
|
||||
|
||||
|
@ -30,6 +30,7 @@ uniform float fresneliness;
|
|||
uniform float noisiness;
|
||||
uniform float ambient_correction;
|
||||
uniform float reflect_map;
|
||||
uniform float normalmap_dds;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
|
@ -45,6 +46,12 @@ void main (void)
|
|||
vec4 ns = texture2D(NormalTex, gl_TexCoord[0].st);
|
||||
vec3 n = ns.rgb * 2.0 - 1.0;
|
||||
n = normalize(n.x * VTangent + n.y * VBinormal + n.z * VNormal);
|
||||
|
||||
//fix dds normal
|
||||
if (normalmap_dds > 0.0) {
|
||||
n = -n;
|
||||
}
|
||||
|
||||
NdotL = max(0.0, dot(n, lightDir));
|
||||
|
||||
// calculate the specular light
|
||||
|
@ -58,10 +65,11 @@ void main (void)
|
|||
* pow(NdotHV, gl_FrontMaterial.shininess));
|
||||
}
|
||||
|
||||
color.a = alpha;
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
//color.a = alpha;
|
||||
vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st);
|
||||
vec4 texelcolor = color * texel + specular;
|
||||
//vec4 texelcolor = color * texel + specular;
|
||||
color.a = texel.a * alpha;
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
// calculate the fog factor
|
||||
const float LOG2 = 1.442695;
|
||||
|
@ -89,12 +97,12 @@ void main (void)
|
|||
float reflFactor = 0.0;
|
||||
|
||||
if(reflect_map > 0.0){
|
||||
// map the shininess of the object with user input
|
||||
// map the shininess of the object with user input
|
||||
vec4 map = texture2D(Map, gl_TexCoord[0].st);
|
||||
//float pam = (map.a * -2) + 1; //reverse map
|
||||
reflFactor = map.a + transparency_offset;
|
||||
} else {
|
||||
// set the reflectivity proportional to shininess with user input
|
||||
// set the reflectivity proportional to shininess with user input
|
||||
reflFactor = (gl_FrontMaterial.shininess / 128.0) * ns.a + transparency_offset;
|
||||
}
|
||||
|
||||
|
@ -105,7 +113,7 @@ void main (void)
|
|||
vec4 ambient_Correction = vec4(gl_LightSource[0].ambient.rg, gl_LightSource[0].ambient.b * 0.6, 0.5) * ambient_offset ;
|
||||
ambient_Correction = clamp(ambient_Correction, -1.0, 1.0);
|
||||
|
||||
// map noise vectore
|
||||
// map noise vector
|
||||
vec4 noisevec = texture3D(Noise, rawpos.xyz);
|
||||
|
||||
// add fringing fresnel and rainbow effects and modulate by reflection
|
||||
|
@ -117,9 +125,9 @@ void main (void)
|
|||
vec4 mixedcolor = mix(texel, raincolor, reflFactor);
|
||||
|
||||
// the final reflection
|
||||
vec4 reflColor = vec4(color.rgb * mixedcolor.rgb + specular.rgb + ambient_Correction.rgb, alpha);
|
||||
vec4 reflColor = vec4(color.rgb * mixedcolor.rgb + specular.rgb + ambient_Correction.rgb, color.a);
|
||||
|
||||
reflColor = clamp(reflColor, 0.0, 1.0);
|
||||
|
||||
gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor);
|
||||
}
|
||||
}
|
|
@ -51,10 +51,10 @@ void main (void)
|
|||
* pow(NdotHV, gl_FrontMaterial.shininess));
|
||||
}
|
||||
|
||||
color.a = alpha;
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st);
|
||||
vec4 texelcolor = color * texel + specular;
|
||||
// vec4 texelcolor = color * texel + specular;
|
||||
color.a = texel.a * alpha;
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
// calculate the fog factor
|
||||
const float LOG2 = 1.442695;
|
||||
|
@ -77,7 +77,7 @@ void main (void)
|
|||
// map the refection of the environment
|
||||
vec4 reflection = textureCube(Environment, reflVec);
|
||||
|
||||
// set the user shininess offse
|
||||
// set the user shininess offset
|
||||
float transparency_offset = clamp(refl_correction, -1.0, 1.0);
|
||||
float reflFactor = 0.0;
|
||||
|
||||
|
@ -100,7 +100,7 @@ void main (void)
|
|||
// vec4 ambient_Correction = vec4(ambient_Correction.rgb, 0.5);
|
||||
ambient_Correction = clamp(ambient_Correction, -1.0, 1.0);
|
||||
|
||||
// map noise vectore
|
||||
// map noise vector
|
||||
vec4 noisevec = texture3D(Noise, rawpos.xyz);
|
||||
|
||||
// add fringing fresnel and rainbow effects and modulate by reflection
|
||||
|
@ -112,7 +112,7 @@ void main (void)
|
|||
vec4 mixedcolor = mix(texel, raincolor, reflFactor);
|
||||
|
||||
// the final reflection
|
||||
vec4 reflColor = vec4(color.rgb * mixedcolor.rgb + specular.rgb + ambient_Correction.rgb, alpha);
|
||||
vec4 reflColor = vec4(color.rgb * mixedcolor.rgb + specular.rgb + ambient_Correction.rgb, color.a);
|
||||
reflColor = clamp(reflColor, 0.0, 1.0);
|
||||
|
||||
gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor);
|
||||
|
|
Loading…
Add table
Reference in a new issue