1
0
Fork 0

Fix wingflex shader to use current effect code. A better way would probably be to just keep the wing flexing part there and then include model-combined, but I couldnt get that to work unfortunately

This commit is contained in:
Benedikt Wolf 2023-02-10 10:37:52 +01:00
parent 13b24e5290
commit 1be001a18c
2 changed files with 1308 additions and 1150 deletions

View file

@ -3,11 +3,29 @@
<name>Effects/model-wingflex</name>
<inherits-from>Effects/model-default</inherits-from>
<!-- the file is directly copied from model-combined.eff except the (three) WINGFLEX to END WINGLFEX parts -->
<!-- I didnt find how to do a more beautiful way (including model-combined and only adding the wingflexer part) -->
<!-- if you know how to do this, please do :) -->
<parameters>
<!-- Diffuse Texture -->
<!-- <texture n ="0">
<type>white</type>
</texture>-->
<!-- Wingflex -->
<wingflex-type type="int">0</wingflex-type>
<body-width type="float">0.7</body-width>
<wing-span type="float">15.0</wing-span>
<wingflex-alpha>0.0</wingflex-alpha>
<wingflex-trailing-alpha>0.0</wingflex-trailing-alpha>
<wingsweep-factor>0.0</wingsweep-factor>
<wingflex-z>0.0</wingflex-z>
<!-- Sub: rotation -->
<rotation-rad type="float">0.0</rotation-rad>
<rotation-x1 type="float">0.0</rotation-x1>
<rotation-y1 type="float">0.0</rotation-y1>
<rotation-z1 type="float">0.0</rotation-z1>
<rotation-x2 type="float">0.0</rotation-x2>
<rotation-y2 type="float">0.0</rotation-y2>
<rotation-z2 type="float">0.0</rotation-z2>
<!-- END Wingflex -->
<!-- Normal Map -->
<normalmap-enabled type="int">0</normalmap-enabled>
<normalmap-dds type="int">0</normalmap-dds>
@ -45,6 +63,8 @@
<reflection-enabled type="int">0</reflection-enabled>
<reflection-correction type="float">0.0</reflection-correction>
<reflect-map-enabled type="int">0</reflect-map-enabled>
<reflection-fresnel-factor type="float">0.0</reflection-fresnel-factor>
<reflection-type type="int">1</reflection-type>
<reflection-dynamic type="int">0</reflection-dynamic>
<texture n="4">
<image>Aircraft/Generic/Effects/ReflectMaps/reflectmap.png</image>
@ -99,6 +119,7 @@
<!-- END Grain texture -->
<!-- simulate rain effects -->
<rain-enabled type="int">0</rain-enabled>
<snow-enabled type="int">0</snow-enabled>
<!-- Dirt -->
<dirt-enabled type="int">0</dirt-enabled>
<dirt-multi type="int">0</dirt-multi>
@ -108,6 +129,8 @@
<dirt-factor type="float" n="1">0.0</dirt-factor>
<dirt-color type="vec3d" n="2">0.0 0.0 0.0</dirt-color>
<dirt-factor type="float" n="2">0.0</dirt-factor>
<dirt-modulates-reflection type="int">0</dirt-modulates-reflection>
<dirt-reflection-factor type="double">1.0</dirt-reflection-factor>
<!-- ambient correction -->
<ambient-correction type="float">0.05</ambient-correction>
<rendering-hint>opaque</rendering-hint>
@ -142,23 +165,8 @@
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
<wetness><use>/environment/surface/wetness</use></wetness>
<rnorm><use>/environment/rain-norm</use></rnorm>
<!-- Wingflex -->
<wingflex-type type="int">0</wingflex-type>
<body-width type="float">0.7</body-width>
<wingflex-alpha>0.0</wingflex-alpha>
<wingflex-trailing-alpha>0.0</wingflex-trailing-alpha>
<wingsweep-factor>0.0</wingsweep-factor>
<wingflex-z>0.0</wingflex-z>
<wing-span>15.0</wing-span>
<!-- Sub: rotation -->
<rotation-rad type="float">0.0</rotation-rad>
<rotation-x1 type="float">0.0</rotation-x1>
<rotation-y1 type="float">0.0</rotation-y1>
<rotation-z1 type="float">0.0</rotation-z1>
<rotation-x2 type="float">0.0</rotation-x2>
<rotation-y2 type="float">0.0</rotation-y2>
<rotation-z2 type="float">0.0</rotation-z2>
<!-- END Wingflex -->
<snow_level><use>/environment/snow-level-m</use></snow_level>
<snow_thickness_factor><use>/environment/surface/snow-thickness-factor</use></snow_thickness_factor>
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
<cloudpos2_x><use>/local-weather/cloud-shadows/cloudpos-x[1]</use></cloudpos2_x>
@ -201,13 +209,11 @@
<cloudpos20_y><use>/local-weather/cloud-shadows/cloudpos-y[19]</use></cloudpos20_y>
<cloud_shadow_flag><use>/local-weather/cloud-shadows/cloud-shadow-flag</use></cloud_shadow_flag>
<building-flag type="int">0</building-flag>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
<!-- END fog include -->
</parameters>
<!--<generate>
<tangent type="int">6</tangent>
<binormal type="int">7</binormal>
</generate>-->
<technique n="4">
<predicate>
@ -447,16 +453,18 @@
</vertex-program-two-side>
<program>
<!-- WINGFLEX -->
<vertex-shader n="0">Shaders/model-ALS-wingflex.vert</vertex-shader>
<!-- END WINGFLEX -->
<vertex-shader n="1">Shaders/shadows-include.vert</vertex-shader>
<fragment-shader n="1">Shaders/model-ALS-ultra.frag</fragment-shader>
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader n="3">Shaders/hazes.frag</fragment-shader>
<fragment-shader n="4">Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader n="5">Shaders/noise.frag</fragment-shader>
<fragment-shader n="6">Shaders/filters-ALS.frag</fragment-shader>
<fragment-shader n="7">Shaders/shadows-include.frag</fragment-shader>
<fragment-shader n="8">Shaders/clustered-include.frag</fragment-shader>
<fragment-shader n="0">Shaders/model-ALS-ultra.frag</fragment-shader>
<fragment-shader n="1">Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader n="2">Shaders/hazes.frag</fragment-shader>
<fragment-shader n="3">Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader n="4">Shaders/noise.frag</fragment-shader>
<fragment-shader n="5">Shaders/filters-ALS.frag</fragment-shader>
<fragment-shader n="6">Shaders/shadows-include.frag</fragment-shader>
<fragment-shader n="7">Shaders/clustered-include.frag</fragment-shader>
</program>
<uniform>
@ -507,90 +515,6 @@
<value type="int">7</value>
</uniform>
<uniform>
<name>wingflex_type</name>
<type>int</type>
<value><use>wingflex-type</use></value>
</uniform>
<uniform>
<name>wingflex_alpha</name>
<type>float</type>
<value><use>wingflex-alpha</use></value>
</uniform>
<uniform>
<name>wingflex_trailing_alpha</name>
<type>float</type>
<value><use>wingflex-trailing-alpha</use></value>
</uniform>
<uniform>
<name>wingsweep_factor</name>
<type>float</type>
<value><use>wingsweep-factor</use></value>
</uniform>
<uniform>
<name>wingflex_z</name>
<type>float</type>
<value><use>wingflex-z</use></value>
</uniform>
<uniform>
<name>body_width</name>
<type>float</type>
<value><use>body-width</use></value>
</uniform>
<uniform>
<name>wing_span</name>
<type>float</type>
<value><use>wing-span</use></value>
</uniform>
<uniform>
<name>rotation_rad</name>
<type>float</type>
<value><use>rotation-rad</use></value>
</uniform>
<uniform>
<name>rotation_x1</name>
<type>float</type>
<value><use>rotation-x1</use></value>
</uniform>
<uniform>
<name>rotation_y1</name>
<type>float</type>
<value><use>rotation-y1</use></value>
</uniform>
<uniform>
<name>rotation_z1</name>
<type>float</type>
<value><use>rotation-z1</use></value>
</uniform>
<uniform>
<name>rotation_x2</name>
<type>float</type>
<value><use>rotation-x2</use></value>
</uniform>
<uniform>
<name>rotation_y2</name>
<type>float</type>
<value><use>rotation-y2</use></value>
</uniform>
<uniform>
<name>rotation_z2</name>
<type>float</type>
<value><use>rotation-z2</use></value>
</uniform>
<!-- NORMAL MAP -->
<!-- normalmap is used-->
<uniform>
@ -725,6 +649,15 @@
</value>
</uniform>
<!-- Fresnel reflectivity -->
<uniform>
<name>refl_fresnel_factor</name>
<type>float</type>
<value>
<use>reflection-fresnel-factor</use>
</value>
</uniform>
<!-- use a reflection map-->
<uniform>
<name>refl_map</name>
@ -733,6 +666,17 @@
<use>reflect-map-enabled</use>
</value>
</uniform>
<!-- how are colors merged in a reflection-->
<uniform>
<name>refl_type</name>
<type>int</type>
<value>
<use>reflection-type</use>
</value>
</uniform>
<!-- reflection is dynamic -->
<uniform>
<name>refl_dynamic</name>
@ -834,6 +778,22 @@
</value>
</uniform>
<uniform>
<name>dirt_modulates_reflection</name>
<type>int</type>
<value>
<use>dirt-modulates-reflection</use>
</value>
</uniform>
<uniform>
<name>dirt_reflection_factor</name>
<type>float</type>
<value>
<use>dirt-reflection-factor</use>
</value>
</uniform>
<!-- use a grain texture map-->
<uniform>
@ -852,7 +812,7 @@
</value>
</uniform>
<!-- simulate wetness and rain-->
<!-- simulate wetness, rain and snow -->
<uniform>
<name>rain_enabled</name>
<type>int</type>
@ -861,6 +821,26 @@
</value>
</uniform>
<uniform>
<name>snow_enabled</name>
<type>int</type>
<value>
<use>snow-enabled</use>
</value>
</uniform>
<uniform>
<name>snowlevel</name>
<type>float</type>
<value><use>snow_level</use></value>
</uniform>
<uniform>
<name>snow_thickness_factor</name>
<type>float</type>
<value><use>snow_thickness_factor</use></value>
</uniform>
<!-- set the amount of ambient light correction 0.0 - 1.0 -->
<uniform>
<name>amb_correction</name>
@ -1020,7 +1000,6 @@
<type>float</type>
<value><use>landing_light3_offset</use></value>
</uniform>
<!-- filtering -->
<uniform>
<name>gamma</name>
<type>float</type>
@ -1061,6 +1040,18 @@
<type>float</type>
<value><use>fact_black</use></value>
</uniform>
<uniform>
<name>quality_level</name>
<type>int</type>
<value><use>quality_level</use></value>
</uniform>
<uniform>
<name>tquality_level</name>
<type>int</type>
<value><use>tquality_level</use></value>
</uniform>
<!-- cloud shadows -->
<uniform>
<name>cloudpos1_x</name>
@ -1325,6 +1316,161 @@
</value>
</uniform>
<!-- END shadows include -->
<!-- WINGFLEX -->
<uniform>
<name>wingflex_type</name>
<type>int</type>
<value><use>wingflex-type</use></value>
</uniform>
<uniform>
<name>wingflex_alpha</name>
<type>float</type>
<value><use>wingflex-alpha</use></value>
</uniform>
<uniform>
<name>wingflex_trailing_alpha</name>
<type>float</type>
<value><use>wingflex-trailing-alpha</use></value>
</uniform>
<uniform>
<name>wingsweep_factor</name>
<type>float</type>
<value><use>wingsweep-factor</use></value>
</uniform>
<uniform>
<name>wingflex_z</name>
<type>float</type>
<value><use>wingflex-z</use></value>
</uniform>
<uniform>
<name>body_width</name>
<type>float</type>
<value><use>body-width</use></value>
</uniform>
<uniform>
<name>wing_span</name>
<type>float</type>
<value><use>wing-span</use></value>
</uniform>
<uniform>
<name>rotation_rad</name>
<type>float</type>
<value><use>rotation-rad</use></value>
</uniform>
<uniform>
<name>rotation_x1</name>
<type>float</type>
<value><use>rotation-x1</use></value>
</uniform>
<uniform>
<name>rotation_y1</name>
<type>float</type>
<value><use>rotation-y1</use></value>
</uniform>
<uniform>
<name>rotation_z1</name>
<type>float</type>
<value><use>rotation-z1</use></value>
</uniform>
<uniform>
<name>rotation_x2</name>
<type>float</type>
<value><use>rotation-x2</use></value>
</uniform>
<uniform>
<name>rotation_y2</name>
<type>float</type>
<value><use>rotation-y2</use></value>
</uniform>
<uniform>
<name>rotation_z2</name>
<type>float</type>
<value><use>rotation-z2</use></value>
</uniform>
<!-- END WINGFLEX -->
</pass>
</technique>
<technique n="7">
<scheme>hdr-geometry</scheme>
<pass>
<!-- Reverse floating point depth buffer -->
<depth>
<function>gequal</function>
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>8</value>
<pass>replace</pass>
</stencil>
<texture-unit>
<unit>0</unit>
<type><use>texture[0]/type</use></type>
<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>
</texture-unit>
<texture-unit>
<unit>1</unit>
<type><use>texture[2]/type</use></type>
<image><use>texture[2]/image</use></image>
<filter><use>texture[2]/filter</use></filter>
<wrap-s><use>texture[2]/wrap-s</use></wrap-s>
<wrap-t><use>texture[2]/wrap-t</use></wrap-t>
</texture-unit>
<cull-face>back</cull-face>
<program>
<vertex-shader>Shaders/HDR/geometry-combined.vert</vertex-shader>
<fragment-shader>Shaders/HDR/geometry-combined.frag</fragment-shader>
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
</program>
<uniform>
<name>color_tex</name>
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>normal_tex</name>
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>normalmap_enabled</name>
<type>int</type>
<value><use>normalmap-enabled</use></value>
</uniform>
<uniform>
<name>normalmap_dds</name>
<type>int</type>
<value><use>normalmap-dds</use></value>
</uniform>
<uniform>
<name>normalmap_tiling</name>
<type>float</type>
<value><use>normalmap-tiling</use></value>
</uniform>
</pass>
</technique>
<technique n="9">
<predicate><value type="bool">false</value></predicate>
</technique>
</PropertyList>

View file

@ -1,11 +1,15 @@
// -*- mode: C; -*-
// Licence: GPL v2
// based on
// © Emilian Huminiuc and Vivian Meazza 2011
// addition for wingflex mesh distortion by Thorsten Renk 2015
#version 120
// the file is directly copied from model-combined.eff except the (three) WINGFLEX to END WINGLFEX parts
// and the subsequent gl_Vertex integrations
// I didnt find how to do a more beautiful way (including model-combined and only adding the wingflexer part)
// if you know how to do this, please do :)
varying vec3 rawpos;
varying vec3 VNormal;
varying vec3 VTangent;
@ -22,6 +26,11 @@ attribute vec3 binormal;
uniform float pitch;
uniform float roll;
uniform float hdg;
uniform int refl_dynamic;
uniform int nmap_enabled;
uniform int shader_qual;
// WINGFLEX
uniform int wingflex_type;
uniform float body_width;
uniform float wingflex_alpha;
@ -36,33 +45,14 @@ uniform float rotation_x2;
uniform float rotation_y2;
uniform float rotation_z2;
uniform float rotation_rad;
uniform int refl_dynamic;
uniform int nmap_enabled;
uniform int shader_qual;
// END WINGFLEX
//////Fog Include///////////
// uniform int fogType;
// void fog_Func(int type);
////////////////////////////
void setupShadows(vec4 eyeSpacePos);
void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat)
{
rotmat = mat4( cosRy , sinRx * sinRy , cosRx * sinRy, 0.0,
0.0 , cosRx , -sinRx * cosRx, 0.0,
-sinRy, sinRx * cosRy, cosRx * cosRy , 0.0,
0.0 , 0.0 , 0.0 , 1.0 );
}
void rotationMatrixH(in float sinRz, in float cosRz, out mat4 rotmat)
{
rotmat = mat4( cosRz, -sinRz, 0.0, 0.0,
sinRz, cosRz, 0.0, 0.0,
0.0 , 0.0 , 1.0, 0.0,
0.0 , 0.0 , 0.0, 1.0 );
}
// WINGFLEX
vec2 calc_deflection(float y){
float distance;
float bwh = body_width/2;
@ -85,16 +75,33 @@ vec2 calc_deflection(float y){
vec2 returned = vec2 ( deflection, delta_y );
return returned;
}
// END WINGFLEX
void setupShadows(vec4 eyeSpacePos);
void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat)
{
rotmat = mat4( cosRy , sinRx * sinRy , cosRx * sinRy, 0.0,
0.0 , cosRx , -sinRx * cosRx, 0.0,
-sinRy, sinRx * cosRy, cosRx * cosRy , 0.0,
0.0 , 0.0 , 0.0 , 1.0 );
}
void rotationMatrixH(in float sinRz, in float cosRz, out mat4 rotmat)
{
rotmat = mat4( cosRz, -sinRz, 0.0, 0.0,
sinRz, cosRz, 0.0, 0.0,
0.0 , 0.0 , 1.0, 0.0,
0.0 , 0.0 , 0.0, 1.0 );
}
void main(void)
{
// WINGFLEX
vec4 vertex = gl_Vertex;
if ( wingflex_type == 0 ) {
float x_factor = max((abs(vertex.x) - body_width),0);
float y_factor = max(vertex.y,0.0);
vec2 deflection=calc_deflection(vertex.y);
vec2 deflection = calc_deflection(vertex.y);
vertex.z += deflection[0];
vertex.y += deflection[1];
@ -179,10 +186,13 @@ void main(void)
}
// END WINGFLEX
rawpos = vertex.xyz;
vec4 ecPosition = gl_ModelViewMatrix * vertex;
//rawpos = gl_Vertex.xyz;
//vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
//fog_Func(fogType);
VNormal = normalize(gl_NormalMatrix * gl_Normal);
@ -240,6 +250,7 @@ void main(void)
reflVec = reflVec_stat;
}
gl_FrontColor = gl_FrontMaterial.emission + gl_Color
* (gl_LightModel.ambient + gl_LightSource[0].ambient);
@ -247,5 +258,6 @@ void main(void)
//gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
setupShadows(ecPosition);
}