-
-
Notifications
You must be signed in to change notification settings - Fork 183
Description
I don't know if it's a bug on GL4ES, but in case it is, I better report it.
Out of curiosity I tried to run the Unvanquished game on GL4ES. The Dæmon engine support GL 2.1 (and even very old and low-end ones) so I was curious to see how GL4ES would manage to run the game.
I first tried on a device that only has GLES (some PowerVR), but after having experienced issues, I decided to test GL4ES on my main computer as it is more convenient for me to test on that main computer. Of course that main computer doesn't require GL4ES (Mesa radeonsi for AMD is featureful), but it's easier for me to build and run things on that main computer.
So I tried running GL4ES over Mesa radeonsi for AMD.
When doing that I get that error:
warning: extension `GL_EXT_shader_non_constant_global_initializers' unsupported in vertex shader
I don't know if that's because of an error in our code (the Dæmon engine code), or because of an error in GL4ES, or maybe a Mesa limitation.
For example I don't see that GL_EXT_shader_non_constant_global_initializers extension being supported at all in Mesa:
Would you know more about it?
Here is the Dæmon engine error log I got:
Using custom context - 24-bit OpenGL 2.1 compatibility
OpenGL vendor: ptitSeb
OpenGL renderer: GL4ES wrapper
OpenGL version: 2.1 gl4es wrapper 1.1.7
Available modes: 1280x720 1600x900 1920x1080 2560x1440 3840x2160 720x400 1280x800 1440x900 1680x1050 1920x1200 720x480 640x480 800x600 832x624 1024x768 1152x864 1600x1200 720x576 1280x1024
Detected graphics hardware class 'generic'
Initializing OpenGL extensions
...missing optional extension GL_ARB_debug_output.
...using required extension GL_ARB_fragment_program.
...using shading language version 120
...using up to 16384 texture size.
...using up to 8192 3D texture size.
...using up to 16384 cube map texture size.
...using up to 192 texture units.
...missing optional extension GL_ARB_half_float_pixel.
...using optional extension GL_ARB_texture_float.
...missing optional extension GL_EXT_gpu_shader4.
...missing optional extension GL_ARB_gpu_shader5.
...missing optional extension GL_EXT_texture_integer.
...using optional extension GL_ARB_texture_rg.
...missing optional extension GL_ARB_texture_gather.
...using required extension GL_EXT_texture_compression_s3tc.
...missing optional extension GL_ARB_texture_compression_rgtc.
...ignoring optional extension GL_EXT_texture_filter_anisotropic.
...using required extension GL_ARB_vertex_array_object.
...using required extension GL_ARB_vertex_buffer_object.
...missing optional extension GL_ARB_half_float_vertex.
...using optional extension GL_ARB_framebuffer_object.
...missing optional extension GL_ARB_get_program_binary.
...missing optional extension GL_ARB_buffer_storage.
...missing optional extension GL_ARB_uniform_buffer_object.
...using optional extension GL_ARB_map_buffer_range.
...missing optional extension GL_ARB_sync.
...missing optional extension GL_ARB_texture_barrier.
...missing optional extension GL_ARB_compute_shader.
...missing optional extension GL_ARB_bindless_texture.
...missing optional extension GL_ARB_shader_draw_parameters.
...missing optional extension GL_ARB_program_interface_query.
...missing optional extension GL_ARB_shader_storage_buffer_object.
...missing optional extension GL_ARB_multi_draw_indirect.
...missing optional extension GL_ARB_shading_language_420pack.
...missing optional extension GL_ARB_explicit_uniform_location.
...missing optional extension GL_ARB_shader_image_load_store.
...missing optional extension GL_ARB_shader_atomic_counters.
...missing optional extension GL_ARB_shader_atomic_counter_ops.
...missing optional extension GL_ARB_indirect_parameters.
...missing optional extension GL_ARB_direct_state_access.
...missing optional extension GL_ARB_vertex_attrib_binding.
...missing optional extension GL_KHR_shader_subgroup.
Warn: SSAO disabled because ARB_texture_gather is not available.
Warn: SSAO disabled because EXT_gpu_shader4 is not available.
Warn: Motion blur disabled because GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB is too small: 8
Trying SMP acceleration...
Warn: You enable r_smp at your own risk!
...succeeded.
Render thread starting
]LIBGL: Warning, unhandled Buffer type GL_PIXEL_PACK_BUFFER in bindBuffer
OpenGL hardware vendor: Unknown
OpenGL driver vendor: Unknown
GL_VENDOR: ptitSeb
GL_RENDERER: GL4ES wrapper
GL_VERSION: 2.1 gl4es wrapper 1.1.7
GL_MAX_TEXTURE_SIZE: 16384
GL_MAX_3D_TEXTURE_SIZE: 8192
GL_MAX_CUBE_MAP_TEXTURE_SIZE: 16384
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: 192
GL_SHADING_LANGUAGE_VERSION: 1.20 via gl4es
GL_MAX_VERTEX_UNIFORM_COMPONENTS 16384
GL_MAX_VERTEX_ATTRIBS 16
GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: 1024
GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: 8
GL_MAX_DRAW_BUFFERS: 8
GL_MAX_COLOR_ATTACHMENTS: 8
PIXELFORMAT: color(24-bits)
MODE: -1, 640 x 480 windowed
Using OpenGL version 2.1, requested: 2.1
OpenGL context is not forward compatible.
Using OpenGL extensions: GL_ARB_fragment_program GL_ARB_texture_float GL_ARB_texture_rg GL_EXT_texture_compression_s3tc GL_ARB_vertex_array_object GL_ARB_vertex_buffer_object GL_ARB_framebuffer_object GL_ARB_map_buffer_range
Missing OpenGL extensions: GL_ARB_debug_output GL_ARB_half_float_pixel GL_EXT_gpu_shader4 GL_ARB_gpu_shader5 GL_EXT_texture_integer GL_ARB_texture_gather GL_ARB_texture_compression_rgtc GL_ARB_half_float_vertex GL_ARB_get_program_binary GL_ARB_buffer_storage GL_ARB_uniform_buffer_object GL_ARB_sync GL_ARB_texture_barrier GL_ARB_compute_shader GL_ARB_bindless_texture GL_ARB_shader_draw_parameters GL_ARB_program_interface_query GL_ARB_shader_storage_buffer_object GL_ARB_multi_draw_indirect GL_ARB_shading_language_420pack GL_ARB_explicit_uniform_location GL_ARB_shader_image_load_store GL_ARB_shader_atomic_counters GL_ARB_shader_atomic_counter_ops GL_ARB_indirect_parameters GL_ARB_direct_state_access GL_ARB_vertex_attrib_binding GL_KHR_shader_subgroup
Missing half-float vertex format.
Using S3TC (DXTC) texture compression.
Missing GPU vertex skinning, models are not hardware-accelerated.
Using dual processor acceleration.
OpenAL System Info:
- Vendor: OpenAL Community
- Version: 1.1 ALSOFT 1.23.1
- Renderer: OpenAL Soft
- AL Extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_EXT_SOURCE_RADIUS AL_EXT_STATIC_BUFFER AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic AL_SOFT_bformat_ex AL_SOFTX_bformat_hoa AL_SOFT_block_alignment AL_SOFT_buffer_length_query AL_SOFT_callback_buffer AL_SOFTX_convolution_reverb AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_direct_channels_remix AL_SOFT_effect_target AL_SOFT_events AL_SOFT_gain_clamp_ex AL_SOFTX_hold_on_disconnect AL_SOFT_loop_points AL_SOFTX_map_buffer AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length AL_SOFT_source_resampler AL_SOFT_source_spatialize AL_SOFT_source_start_delay AL_SOFT_UHJ AL_SOFT_UHJ_ex
- ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_output_mode ALC_SOFT_pause_device ALC_SOFT_reopen_device
- Using Device: UAC1 DAC Stéréo analogique
- Available Devices:
- UAC1 DAC Stéréo analogique
- USB Audio Stéréo numérique (IEC958)
- Navi 31 HDMI/DP Audio Digital Stereo (HDMI 4)
- Default Device: OpenAL Soft
- Available Capture Devices:
- USB Audio Stéréo numérique (IEC958)
- Monitor of UAC1 DAC Stéréo analogique
- Monitor of USB Audio Stéréo numérique (IEC958)
- Monitor of Navi 31 HDMI/DP Audio Digital Stereo (HDMI 4)
- Default Capture Device: USB Audio Stéréo numérique (IEC958)
Loading VM module cgame-native-dll.so...
Loaded cgame VM module in 58 msec
cgame Linux amd64 (GCC_13.3.0:g++) Sep 26 2025
Loading Lua plugin using a new Lua state.
Loaded font face 'unifont' [regular] from 'fonts/unifont.ttf'.
Loaded font face 'Roboto' [bold] from 'fonts/Roboto-Bold.ttf'.
Loaded font face 'Roboto' [italic, bold] from 'fonts/Roboto-BoldItalic.ttf'.
Loaded font face 'Roboto' [italic] from 'fonts/Roboto-Italic.ttf'.
Loaded font face 'Roboto' [regular] from 'fonts/Roboto-Regular.ttf'.
Loaded font face 'FontAwesome' [regular] from 'fonts/fontawesome-webfont.ttf'.
Loaded font face 'DejaVu Sans' [regular] from 'fonts/DejaVuSansCondensed.ttf'.
Loaded font face 'Material Icons' [regular] from 'fonts/MaterialIcons-Regular.ttf'.
]LIBGL: Error while compiling shader 2. Original source is:
#version 120
#define HAVE_ARB_texture_float 1
#define HAVE_ARB_texture_rg 1
float smoothstep(float edge0, float edge1, float x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); }
#ifndef r_AmbientScale
#define r_AmbientScale 1.00000000e+00
#endif
#ifndef r_SpecularScale
#define r_SpecularScale 1.00000000e+00
#endif
#ifndef r_zNear
#define r_zNear 3.00000000e+00
#endif
#ifndef M_PI
#define M_PI 3.14159274e+00
#endif
#ifndef MAX_REF_LIGHTS
#define MAX_REF_LIGHTS 1024
#endif
#ifndef NUM_LIGHT_LAYERS
#define NUM_LIGHT_LAYERS 0
#endif
#ifndef TILE_SIZE
#define TILE_SIZE 16
#endif
#ifndef r_FBufSize
#define r_FBufSize vec2(6.40000000e+02, 4.80000000e+02)
#endif
#ifndef r_tileStep
#define r_tileStep vec2(2.50000004e-02, 3.33333351e-02)
#endif
const int MAX_GLSL_BONES = 4;
#ifndef r_halfLambertLighting
#define r_halfLambertLighting 1
#endif
#ifndef r_accurateSRGB
#define r_accurateSRGB 1
#endif
#ifndef r_glowMapping
#define r_glowMapping 1
#endif
#define IN attribute
#define OUT(mode) varying
/*
===========================================================================
Copyright (C) 2006-2011 Robert Beckebans <[email protected]>
This file is part of XreaL source code.
XreaL source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
XreaL source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with XreaL source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/* generic_vp.glsl */
#line 10000 // common.glsl
/*
===========================================================================
Daemon BSD Source Code
Copyright (c) 2024-2025 Daemon Developers
All rights reserved.
This file is part of the Daemon BSD Source Code (Daemon Source Code).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Daemon developers nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===========================================================================
*/
/* common.glsl */
/* Common defines */
/* Allows accessing each element of a uvec4 array with a singular ID
Useful to avoid wasting memory due to alignment requirements
array must be in the form of uvec4 array[] */
#define UINT_FROM_UVEC4_ARRAY( array, id ) ( ( array )[( id ) / 4][( id ) % 4] )
#define UVEC2_FROM_UVEC4_ARRAY( array, id ) ( ( id ) % 2 == 0 ? ( array )[( id ) / 2].xy : ( array )[( id ) / 2].zw )
// Common functions
#if defined(HAVE_EXT_gpu_shader4)
#define colorPack uint
#define colorModulatePack uint
#else
#define colorPack vec4
#define colorModulatePack vec4
#endif
vec4 UnpackColor( const in colorPack packedColor )
{
#if defined(HAVE_EXT_gpu_shader4)
return unpackUnorm4x8( packedColor );
#else
return packedColor;
#endif
}
/* colorMod uint format:
colorMod << 0: color * 1
colorMod << 1: color * ( -1 )
colorMod << 2: alpha * 1
colorMod << 3: alpha * ( -1 )
colorMod << 4: alpha = 1
colorMod << 5-26: available for future usage
colorMod << 27: color += lightFactor
colorMod << 28-31: lightFactor
colorMod float format:
colorMod[ 0 ]: color * f
colorMod[ 1 ] absolute value: lightFactor
colorMod[ 1 ] minus sign: color += lightFactor
colorMod[ 2 ]: alpha = 1
colorMod[ 3 ]: alpha * f */
vec4 ColorModulateToColor( const in colorModulatePack colorMod )
{
#if defined(HAVE_EXT_gpu_shader4)
vec3 colorModArray = vec3( 0.0f, 1.0f, -1.0f );
uint rgbIndex = colorMod & 3u;
uint alphaIndex = ( colorMod >> 2u ) & 3u;
float rgb = colorModArray[ rgbIndex ];
float alpha = colorModArray[ alphaIndex ];
#else
float rgb = colorMod.r;
float alpha = colorMod.a;
#endif
return vec4( rgb, rgb, rgb, alpha );
}
struct ModBits_t
{
bool alphaAddOne;
bool useVertexLightFactor;
};
ModBits_t ColorModulateToBits( const in colorModulatePack colorMod )
{
ModBits_t modBits;
#if defined(HAVE_EXT_gpu_shader4)
modBits.alphaAddOne = bool( ( colorMod >> 4u ) & 1u );
modBits.useVertexLightFactor = bool( ( colorMod >> 27u ) & 1u );
#else
modBits.alphaAddOne = colorMod.b != 0;
modBits.useVertexLightFactor = colorMod.g < 0;
#endif
return modBits;
}
float ColorModulateToLightFactor( const in colorModulatePack colorMod )
{
#if defined(HAVE_EXT_gpu_shader4)
return float( colorMod >> 28u );
#else
return abs( colorMod.g );
#endif
}
void ModulateColor(
const in vec4 colorModulation,
const in vec4 unpackedColor,
inout vec4 color )
{
color *= colorModulation;
color += unpackedColor;
}
void ColorModulateColor(
const in colorModulatePack colorMod,
const in colorPack packedColor,
inout vec4 color )
{
vec4 colorModulation = ColorModulateToColor( colorMod );
vec4 unpackedColor = UnpackColor( packedColor );
ModulateColor( colorModulation, unpackedColor, color );
}
void ColorModulateColor_lightFactor(
const in colorModulatePack colorMod,
const in colorPack packedColor,
inout vec4 color )
{
vec4 colorModulation = ColorModulateToColor( colorMod );
ModBits_t modBits = ColorModulateToBits( colorMod );
float lightFactor = ColorModulateToLightFactor( colorMod );
// This is used to skip vertex colours if the colorMod doesn't need them.
color.a = modBits.alphaAddOne ? 1.0 : color.a;
colorModulation.rgb += vec3( modBits.useVertexLightFactor ? lightFactor : 0 );
vec4 unpackedColor = UnpackColor( packedColor );
unpackedColor.rgb *= lightFactor;
ModulateColor( colorModulation, unpackedColor, color );
}
#line 69
#line 20000 // vertexSimple_vp.glsl
/*
===========================================================================
Copyright (C) 2010 Robert Beckebans <[email protected]>
This file is part of XreaL source code.
XreaL source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
XreaL source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with XreaL source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// vertexSimple_vp.glsl - simple vertex fetch
struct localBasis {
vec3 normal;
vec3 tangent, binormal;
};
vec3 QuatTransVec(in vec4 quat, in vec3 vec) {
vec3 tmp = 2.0 * cross( quat.xyz, vec );
return vec + quat.w * tmp + cross( quat.xyz, tmp );
}
void QTangentToLocalBasis( in vec4 qtangent, out localBasis LB ) {
LB.normal = QuatTransVec( qtangent, vec3( 0.0, 0.0, 1.0 ) );
LB.tangent = QuatTransVec( qtangent, vec3( 1.0, 0.0, 0.0 ) );
LB.tangent *= sign( qtangent.w );
LB.binormal = QuatTransVec( qtangent, vec3( 0.0, 1.0, 0.0 ) );
}
#if !defined(USE_VERTEX_ANIMATION) && !defined(USE_VERTEX_SKINNING)
IN vec3 attr_Position;
IN vec4 attr_Color;
IN vec4 attr_QTangent;
IN vec4 attr_TexCoord0;
void VertexFetch(out vec4 position,
out localBasis normalBasis,
out vec4 color,
out vec2 texCoord,
out vec2 lmCoord)
{
position = vec4( attr_Position, 1.0 );
QTangentToLocalBasis( attr_QTangent, normalBasis );
color = attr_Color;
texCoord = attr_TexCoord0.xy;
lmCoord = attr_TexCoord0.zw;
}
#endif
#line 70
#line 30000 // vertexSkinning_vp.glsl
/*
===========================================================================
Copyright (C) 2009-2011 Robert Beckebans <[email protected]>
This file is part of XreaL source code.
XreaL source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
XreaL source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with XreaL source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// vertexSkinning_vp.glsl - GPU vertex skinning for skeletal meshes
#if defined(USE_VERTEX_SKINNING)
IN vec3 attr_Position;
IN vec2 attr_TexCoord0;
IN vec4 attr_Color;
IN vec4 attr_QTangent;
IN vec4 attr_BoneFactors;
// even elements are rotation quat, odd elements are translation + scale (in .w)
uniform vec4 u_Bones[ 2 * MAX_GLSL_BONES ];
void VertexFetch(out vec4 position,
out localBasis LB,
out vec4 color,
out vec2 texCoord,
out vec2 lmCoord)
{
const float scale = 1.0 / 256.0;
const float weightScale = 1.0 / 255.0;
localBasis inLB;
// Unpack data from "bone factors". This used to have the index in the high byte and the weight
// in the low byte, which may seem a bit more logical, but it triggered issues with some
// Nvidia shader compilers (https://github.com/DaemonEngine/Daemon/issues/472).
vec4 ipart = floor( attr_BoneFactors * scale );
vec4 fpart = attr_BoneFactors * scale - ipart;
// idx = 2 times the original bone index (the index input to boneFactor)
ivec4 idx = ivec4( fpart * 512.0 );
vec4 weights = ipart * weightScale;
vec4 quat = u_Bones[ idx.x ];
vec4 trans = u_Bones[ idx.x + 1 ];
QTangentToLocalBasis( attr_QTangent, inLB );
position.xyz = weights.x * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
LB.normal = weights.x * (QuatTransVec( quat, inLB.normal ));
LB.tangent = weights.x * (QuatTransVec( quat, inLB.tangent ));
LB.binormal = weights.x * (QuatTransVec( quat, inLB.binormal ));
quat = u_Bones[ idx.y ];
trans = u_Bones[ idx.y + 1 ];
position.xyz += weights.y * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
LB.normal += weights.y * (QuatTransVec( quat, inLB.normal ));
LB.tangent += weights.y * (QuatTransVec( quat, inLB.tangent ));
LB.binormal += weights.y * (QuatTransVec( quat, inLB.binormal ));
quat = u_Bones[ idx.z ];
trans = u_Bones[ idx.z + 1 ];
position.xyz += weights.z * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
LB.normal += weights.z * (QuatTransVec( quat, inLB.normal ));
LB.tangent += weights.z * (QuatTransVec( quat, inLB.tangent ));
LB.binormal += weights.z * (QuatTransVec( quat, inLB.binormal ));
quat = u_Bones[ idx.w ];
trans = u_Bones[ idx.w + 1 ];
position.xyz += weights.w * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
LB.normal += weights.w * (QuatTransVec( quat, inLB.normal ));
LB.tangent += weights.w * (QuatTransVec( quat, inLB.tangent ));
LB.binormal += weights.w * (QuatTransVec( quat, inLB.binormal ));
position.w = 1.0;
LB.normal = normalize(LB.normal);
LB.tangent = normalize(LB.tangent);
LB.binormal = normalize(LB.binormal);
color = attr_Color;
texCoord = attr_TexCoord0;
lmCoord = attr_TexCoord0;
}
#endif
#line 71
#line 40000 // vertexAnimation_vp.glsl
/*
===========================================================================
Copyright (C) 2010 Robert Beckebans <[email protected]>
This file is part of XreaL source code.
XreaL source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
XreaL source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with XreaL source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// vertexAnimation_vp.glsl - interpolates .md3/.mdc vertex animations
#if defined(USE_VERTEX_ANIMATION)
IN vec3 attr_Position;
IN vec4 attr_Color;
IN vec4 attr_QTangent;
IN vec2 attr_TexCoord0;
IN vec3 attr_Position2;
IN vec4 attr_QTangent2;
uniform float u_VertexInterpolation;
void VertexAnimation_P_N( vec3 fromPosition, vec3 toPosition,
vec4 fromQTangent, vec4 toQTangent,
float frac,
inout vec4 position, inout vec3 normal)
{
vec3 fromNormal = QuatTransVec( fromQTangent, vec3( 0.0, 0.0, 1.0 ) );
vec3 toNormal = QuatTransVec( toQTangent, vec3( 0.0, 0.0, 1.0 ) );
position.xyz = 512.0 * mix(fromPosition, toPosition, frac);
position.w = 1;
normal = normalize(mix(fromNormal, toNormal, frac));
}
void VertexFetch(out vec4 position,
out localBasis LB,
out vec4 color,
out vec2 texCoord,
out vec2 lmCoord)
{
localBasis fromLB, toLB;
QTangentToLocalBasis( attr_QTangent, fromLB );
QTangentToLocalBasis( attr_QTangent2, toLB );
position.xyz = 512.0 * mix(attr_Position, attr_Position2, u_VertexInterpolation);
position.w = 1;
LB.normal = normalize(mix(fromLB.normal, toLB.normal, u_VertexInterpolation));
LB.tangent = normalize(mix(fromLB.tangent, toLB.tangent, u_VertexInterpolation));
LB.binormal = normalize(mix(fromLB.binormal, toLB.binormal, u_VertexInterpolation));
color = attr_Color;
texCoord = attr_TexCoord0;
lmCoord = attr_TexCoord0;
}
#endif
#line 72
#line 50000 // shaderProfiler_vp.glsl
/*
===========================================================================
Daemon BSD Source Code
Copyright (c) 2024 Daemon Developers
All rights reserved.
This file is part of the Daemon BSD Source Code (Daemon Source Code).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Daemon developers nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===========================================================================
*/
/* shaderProfiler_vp.glsl */
#if defined(r_profilerRenderSubGroups) && defined(HAVE_KHR_shader_subgroup_basic) && defined(HAVE_KHR_shader_subgroup_arithmetic)
uniform uint u_ProfilerRenderSubGroups;
OUT(flat) float var_SubGroupCount;
#define SHADER_PROFILER_SET \
if( u_ProfilerRenderSubGroups == 1 ) {\
var_SubGroupCount = subgroupAdd( 1.0 ) / float( gl_SubgroupSize );\
}
#else
#define SHADER_PROFILER_OUT
#define SHADER_PROFILER_SET
#endif
#line 73
#if !defined(USE_MATERIAL_SYSTEM)
uniform mat3x2 u_TextureMatrix;
#endif
uniform vec3 u_ViewOrigin;
uniform float u_Time;
uniform colorModulatePack u_ColorModulateColorGen;
uniform colorPack u_Color;
#if defined(USE_TCGEN_ENVIRONMENT)
uniform mat4 u_ModelMatrix;
#endif
uniform mat4 u_ModelViewProjectionMatrix;
#if defined(USE_DEPTH_FADE)
uniform float u_DepthScale;
OUT(smooth) float var_FadeDepth;
#endif
OUT(smooth) vec2 var_TexCoords;
OUT(smooth) vec4 var_Color;
void DeformVertex( inout vec4 pos, inout vec3 normal, inout vec2 st, inout vec4 color, in float time );
void main() {
#line 60000 // material_vp.glsl
/*
===========================================================================
Daemon BSD Source Code
Copyright (c) 2024 Daemon Developers
All rights reserved.
This file is part of the Daemon BSD Source Code (Daemon Source Code).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Daemon developers nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===========================================================================
*/
/* material_vp.glsl */
#if defined(USE_MATERIAL_SYSTEM)
#ifdef HAVE_ARB_shader_draw_parameters
in_drawID = drawID;
in_baseInstance = baseInstance;
#endif // !HAVE_ARB_shader_draw_parameters
#endif // !USE_MATERIAL_SYSTEM
#line 103
vec4 position;
localBasis LB;
vec4 color;
vec2 texCoord, lmCoord;
VertexFetch( position, LB, color, texCoord, lmCoord );
ColorModulateColor_lightFactor( u_ColorModulateColorGen, u_Color, color );
DeformVertex( position, LB.normal, texCoord, color, u_Time );
// transform vertex position into homogenous clip-space
gl_Position = u_ModelViewProjectionMatrix * position;
// transform texcoords
#if defined(USE_TCGEN_ENVIRONMENT)
// TODO: Explain why only the rotational part of u_ModelMatrix is relevant
position.xyz = mat3( u_ModelMatrix ) * position.xyz;
vec3 viewer = normalize( u_ViewOrigin - position.xyz );
float d = dot( LB.normal, viewer );
vec3 reflected = LB.normal * 2.0 * d - viewer;
var_TexCoords = 0.5 + vec2( 0.5, -0.5 ) * reflected.yz;
#elif defined(USE_TCGEN_LIGHTMAP)
var_TexCoords = ( u_TextureMatrix * vec3( lmCoord, 1.0 ) ).xy;
#else
var_TexCoords = ( u_TextureMatrix * vec3( texCoord, 1.0 ) ).xy;
#endif
#if defined(USE_DEPTH_FADE)
// compute z of end of fading effect
vec4 fadeDepth = u_ModelViewProjectionMatrix * ( position - u_DepthScale * vec4(LB.normal, 0.0) );
var_FadeDepth = fadeDepth.z / fadeDepth.w;
#endif
SHADER_PROFILER_SET
var_Color = color;
}
=======
ShaderConv Source is:
#version 100
#extension GL_EXT_shader_non_constant_global_initializers : enable
precision highp float;
#define GL4ES
float clamp(float f, int a, int b) {
return clamp(f, float(a), float(b));
}
float clamp(float f, float a, int b) {
return clamp(f, a, float(b));
}
float clamp(float f, int a, float b) {
return clamp(f, float(a), b);
}
vec2 clamp(vec2 f, int a, int b) {
return clamp(f, float(a), float(b));
}
vec2 clamp(vec2 f, float a, int b) {
return clamp(f, a, float(b));
}
vec2 clamp(vec2 f, int a, float b) {
return clamp(f, float(a), b);
}
vec3 clamp(vec3 f, int a, int b) {
return clamp(f, float(a), float(b));
}
vec3 clamp(vec3 f, float a, int b) {
return clamp(f, a, float(b));
}
vec3 clamp(vec3 f, int a, float b) {
return clamp(f, float(a), b);
}
vec4 clamp(vec4 f, int a, int b) {
return clamp(f, float(a), float(b));
}
vec4 clamp(vec4 f, float a, int b) {
return clamp(f, a, float(b));
}
vec4 clamp(vec4 f, int a, float b) {
return clamp(f, float(a), b);
}
precision highp int;
#define HAVE_ARB_texture_float 1
#define HAVE_ARB_texture_rg 1
float smoothstep(float edge0, float edge1, float x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.00000, 1.00000); return t * t * (3.00000 - 2.00000 * t); }
#ifndef r_AmbientScale
#define r_AmbientScale 1.00000000e+00
#endif
#ifndef r_SpecularScale
#define r_SpecularScale 1.00000000e+00
#endif
#ifndef r_zNear
#define r_zNear 3.00000000e+00
#endif
#ifndef M_PI
#define M_PI 3.14159274e+00
#endif
#ifndef MAX_REF_LIGHTS
#define MAX_REF_LIGHTS 1024
#endif
#ifndef NUM_LIGHT_LAYERS
#define NUM_LIGHT_LAYERS 0
#endif
#ifndef TILE_SIZE
#define TILE_SIZE 16
#endif
#ifndef r_FBufSize
#define r_FBufSize vec2(640.000, 480.000)
#endif
#ifndef r_tileStep
#define r_tileStep vec2(0.0250000, 0.0333333)
#endif
const int MAX_GLSL_BONES = 4;
#ifndef r_halfLambertLighting
#define r_halfLambertLighting 1
#endif
#ifndef r_accurateSRGB
#define r_accurateSRGB 1
#endif
#ifndef r_glowMapping
#define r_glowMapping 1
#endif
#define IN attribute
#define OUT(mode) varying
#line 10000
#define UINT_FROM_UVEC4_ARRAY( array, id ) ( ( array )[( id ) / 4][( id ) % 4] )
#define UVEC2_FROM_UVEC4_ARRAY( array, id ) ( ( id ) % 2 == 0 ? ( array )[( id ) / 2].xy : ( array )[( id ) / 2].zw )
#if defined(HAVE_EXT_gpu_shader4)
#define colorPack uint
#define colorModulatePack uint
#else
#define colorPack vec4
#define colorModulatePack vec4
#endif
vec4 UnpackColor( const in colorPack packedColor )
{
#if defined(HAVE_EXT_gpu_shader4)
return unpackUnorm4x8( packedColor );
#else
return packedColor;
#endif
}
vec4 ColorModulateToColor( const in colorModulatePack colorMod )
{
#if defined(HAVE_EXT_gpu_shader4)
vec3 colorModArray = vec3( 0.00000, 1.00000, -1.00000 );
uint rgbIndex = colorMod & 3u;
uint alphaIndex = ( colorMod >> 2u ) & 3u;
float rgb = colorModArray[ rgbIndex ];
float alpha = colorModArray[ alphaIndex ];
#else
float rgb = colorMod.r;
float alpha = colorMod.a;
#endif
return vec4( rgb, rgb, rgb, alpha );
}
struct ModBits_t
{
bool alphaAddOne;
bool useVertexLightFactor;
};
ModBits_t ColorModulateToBits( const in colorModulatePack colorMod )
{
ModBits_t modBits;
#if defined(HAVE_EXT_gpu_shader4)
modBits.alphaAddOne = bool( ( colorMod >> 4u ) & 1u );
modBits.useVertexLightFactor = bool( ( colorMod >> 27u ) & 1u );
#else
modBits.alphaAddOne = colorMod.b != 0;
modBits.useVertexLightFactor = colorMod.g < 0;
#endif
return modBits;
}
float ColorModulateToLightFactor( const in colorModulatePack colorMod )
{
#if defined(HAVE_EXT_gpu_shader4)
return float( colorMod >> 28u );
#else
return abs( colorMod.g );
#endif
}
void ModulateColor(
const in vec4 colorModulation,
const in vec4 unpackedColor,
inout vec4 color )
{
color *= colorModulation;
color += unpackedColor;
}
void ColorModulateColor(
const in colorModulatePack colorMod,
const in colorPack packedColor,
inout vec4 color )
{
vec4 colorModulation = ColorModulateToColor( colorMod );
vec4 unpackedColor = UnpackColor( packedColor );
ModulateColor( colorModulation, unpackedColor, color );
}
void ColorModulateColor_lightFactor(
const in colorModulatePack colorMod,
const in colorPack packedColor,
inout vec4 color )
{
vec4 colorModulation = ColorModulateToColor( colorMod );
ModBits_t modBits = ColorModulateToBits( colorMod );
float lightFactor = ColorModulateToLightFactor( colorMod );
color.a = modBits.alphaAddOne ? 1.00000 : color.a;
colorModulation.rgb += vec3( modBits.useVertexLightFactor ? lightFactor : 0 );
vec4 unpackedColor = UnpackColor( packedColor );
unpackedColor.rgb *= lightFactor;
ModulateColor( colorModulation, unpackedColor, color );
}
#line 69
#line 20000
struct localBasis {
vec3 normal;
vec3 tangent, binormal;
};
vec3 QuatTransVec(in vec4 quat, in vec3 vec) {
vec3 tmp = 2.00000 * cross( quat.xyz, vec );
return vec + quat.w * tmp + cross( quat.xyz, tmp );
}
void QTangentToLocalBasis( in vec4 qtangent, out localBasis LB ) {
LB.normal = QuatTransVec( qtangent, vec3( 0.00000, 0.00000, 1.00000 ) );
LB.tangent = QuatTransVec( qtangent, vec3( 1.00000, 0.00000, 0.00000 ) );
LB.tangent *= sign( qtangent.w );
LB.binormal = QuatTransVec( qtangent, vec3( 0.00000, 1.00000, 0.00000 ) );
}
#if !defined(USE_VERTEX_ANIMATION) && !defined(USE_VERTEX_SKINNING)
IN vec3 attr_Position;
IN vec4 attr_Color;
IN vec4 attr_QTangentWarn: Unable to parse shader info log errors: unknown format
Warn: Source for shader program generic:
0: #version 120
1:
2: #define HAVE_ARB_texture_float 1
3: #define HAVE_ARB_texture_rg 1
4: float smoothstep(float edge0, float edge1, float x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); }
5: #ifndef r_AmbientScale
6: #define r_AmbientScale 1.00000000e+00
7: #endif
8: #ifndef r_SpecularScale
9: #define r_SpecularScale 1.00000000e+00
10: #endif
11: #ifndef r_zNear
12: #define r_zNear 3.00000000e+00
13: #endif
14: #ifndef M_PI
15: #define M_PI 3.14159274e+00
16: #endif
17: #ifndef MAX_REF_LIGHTS
18: #define MAX_REF_LIGHTS 1024
19: #endif
20: #ifndef NUM_LIGHT_LAYERS
21: #define NUM_LIGHT_LAYERS 0
22: #endif
23: #ifndef TILE_SIZE
24: #define TILE_SIZE 16
25: #endif
26: #ifndef r_FBufSize
27: #define r_FBufSize vec2(6.40000000e+02, 4.80000000e+02)
28: #endif
29: #ifndef r_tileStep
30: #define r_tileStep vec2(2.50000004e-02, 3.33333351e-02)
31: #endif
32: const int MAX_GLSL_BONES = 4;
33: #ifndef r_halfLambertLighting
34: #define r_halfLambertLighting 1
35: #endif
36: #ifndef r_accurateSRGB
37: #define r_accurateSRGB 1
38: #endif
39: #ifndef r_glowMapping
40: #define r_glowMapping 1
41: #endif
42: #define IN attribute
43: #define OUT(mode) varying
44: /*
45: ===========================================================================
46: Copyright (C) 2006-2011 Robert Beckebans <[email protected]>
47:
48: This file is part of XreaL source code.
49:
50: XreaL source code is free software; you can redistribute it
51: and/or modify it under the terms of the GNU General Public License as
52: published by the Free Software Foundation; either version 2 of the License,
53: or (at your option) any later version.
54:
55: XreaL source code is distributed in the hope that it will be
56: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
57: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58: GNU General Public License for more details.
59:
60: You should have received a copy of the GNU General Public License
61: along with XreaL source code; if not, write to the Free Software
62: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
63: ===========================================================================
64: */
65:
66: /* generic_vp.glsl */
67:
10000: #line 10000 // common.glsl
10001: /*
10002: ===========================================================================
10003:
10004: Daemon BSD Source Code
10005: Copyright (c) 2024-2025 Daemon Developers
10006: All rights reserved.
10007:
10008: This file is part of the Daemon BSD Source Code (Daemon Source Code).
10009:
10010: Redistribution and use in source and binary forms, with or without
10011: modification, are permitted provided that the following conditions are met:
10012: * Redistributions of source code must retain the above copyright
10013: notice, this list of conditions and the following disclaimer.
10014: * Redistributions in binary form must reproduce the above copyright
10015: notice, this list of conditions and the following disclaimer in the
10016: documentation and/or other materials provided with the distribution.
10017: * Neither the name of the Daemon developers nor the
10018: names of its contributors may be used to endorse or promote products
10019: derived from this software without specific prior written permission.
10020:
10021: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
10022: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10023: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10024: DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
10025: DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
10026: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
10027: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
10028: ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10029: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
10030: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10031:
10032: ===========================================================================
10033: */
10034:
10035: /* common.glsl */
10036:
10037: /* Common defines */
10038:
10039: /* Allows accessing each element of a uvec4 array with a singular ID
10040: Useful to avoid wasting memory due to alignment requirements
10041: array must be in the form of uvec4 array[] */
10042:
10043: #define UINT_FROM_UVEC4_ARRAY( array, id ) ( ( array )[( id ) / 4][( id ) % 4] )
10044: #define UVEC2_FROM_UVEC4_ARRAY( array, id ) ( ( id ) % 2 == 0 ? ( array )[( id ) / 2].xy : ( array )[( id ) / 2].zw )
10045:
10046: // Common functions
10047:
10048: #if defined(HAVE_EXT_gpu_shader4)
10049: #define colorPack uint
10050: #define colorModulatePack uint
10051: #else
10052: #define colorPack vec4
10053: #define colorModulatePack vec4
10054: #endif
10055:
10056: vec4 UnpackColor( const in colorPack packedColor )
10057: {
10058: #if defined(HAVE_EXT_gpu_shader4)
10059: return unpackUnorm4x8( packedColor );
10060: #else
10061: return packedColor;
10062: #endif
10063: }
10064:
10065: /* colorMod uint format:
10066:
10067: colorMod << 0: color * 1
10068: colorMod << 1: color * ( -1 )
10069: colorMod << 2: alpha * 1
10070: colorMod << 3: alpha * ( -1 )
10071: colorMod << 4: alpha = 1
10072: colorMod << 5-26: available for future usage
10073: colorMod << 27: color += lightFactor
10074: colorMod << 28-31: lightFactor
10075:
10076: colorMod float format:
10077:
10078: colorMod[ 0 ]: color * f
10079: colorMod[ 1 ] absolute value: lightFactor
10080: colorMod[ 1 ] minus sign: color += lightFactor
10081: colorMod[ 2 ]: alpha = 1
10082: colorMod[ 3 ]: alpha * f */
10083:
10084: vec4 ColorModulateToColor( const in colorModulatePack colorMod )
10085: {
10086: #if defined(HAVE_EXT_gpu_shader4)
10087: vec3 colorModArray = vec3( 0.0f, 1.0f, -1.0f );
10088:
10089: uint rgbIndex = colorMod & 3u;
10090: uint alphaIndex = ( colorMod >> 2u ) & 3u;
10091:
10092: float rgb = colorModArray[ rgbIndex ];
10093: float alpha = colorModArray[ alphaIndex ];
10094: #else
10095: float rgb = colorMod.r;
10096: float alpha = colorMod.a;
10097: #endif
10098:
10099: return vec4( rgb, rgb, rgb, alpha );
10100: }
10101:
10102: struct ModBits_t
10103: {
10104: bool alphaAddOne;
10105: bool useVertexLightFactor;
10106: };
10107:
10108: ModBits_t ColorModulateToBits( const in colorModulatePack colorMod )
10109: {
10110: ModBits_t modBits;
10111:
10112: #if defined(HAVE_EXT_gpu_shader4)
10113: modBits.alphaAddOne = bool( ( colorMod >> 4u ) & 1u );
10114: modBits.useVertexLightFactor = bool( ( colorMod >> 27u ) & 1u );
10115: #else
10116: modBits.alphaAddOne = colorMod.b != 0;
10117: modBits.useVertexLightFactor = colorMod.g < 0;
10118: #endif
10119:
10120: return modBits;
10121: }
10122:
10123: float ColorModulateToLightFactor( const in colorModulatePack colorMod )
10124: {
10125: #if defined(HAVE_EXT_gpu_shader4)
10126: return float( colorMod >> 28u );
10127: #else
10128: return abs( colorMod.g );
10129: #endif
10130: }
10131:
10132: void ModulateColor(
10133: const in vec4 colorModulation,
10134: const in vec4 unpackedColor,
10135: inout vec4 color )
10136: {
10137: color *= colorModulation;
10138: color += unpackedColor;
10139: }
10140:
10141: void ColorModulateColor(
10142: const in colorModulatePack colorMod,
10143: const in colorPack packedColor,
10144: inout vec4 color )
10145: {
10146: vec4 colorModulation = ColorModulateToColor( colorMod );
10147:
10148: vec4 unpackedColor = UnpackColor( packedColor );
10149:
10150: ModulateColor( colorModulation, unpackedColor, color );
10151: }
10152:
10153: void ColorModulateColor_lightFactor(
10154: const in colorModulatePack colorMod,
10155: const in colorPack packedColor,
10156: inout vec4 color )
10157: {
10158: vec4 colorModulation = ColorModulateToColor( colorMod );
10159: ModBits_t modBits = ColorModulateToBits( colorMod );
10160: float lightFactor = ColorModulateToLightFactor( colorMod );
10161:
10162: // This is used to skip vertex colours if the colorMod doesn't need them.
10163: color.a = modBits.alphaAddOne ? 1.0 : color.a;
10164:
10165: colorModulation.rgb += vec3( modBits.useVertexLightFactor ? lightFactor : 0 );
10166:
10167: vec4 unpackedColor = UnpackColor( packedColor );
10168:
10169: unpackedColor.rgb *= lightFactor;
10170:
10171: ModulateColor( colorModulation, unpackedColor, color );
10172: }
69: #line 69
20000: #line 20000 // vertexSimple_vp.glsl
20001: /*
20002: ===========================================================================
20003: Copyright (C) 2010 Robert Beckebans <[email protected]>
20004:
20005: This file is part of XreaL source code.
20006:
20007: XreaL source code is free software; you can redistribute it
20008: and/or modify it under the terms of the GNU General Public License as
20009: published by the Free Software Foundation; either version 2 of the License,
20010: or (at your option) any later version.
20011:
20012: XreaL source code is distributed in the hope that it will be
20013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
20014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20015: GNU General Public License for more details.
20016:
20017: You should have received a copy of the GNU General Public License
20018: along with XreaL source code; if not, write to the Free Software
20019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20020: ===========================================================================
20021: */
20022: // vertexSimple_vp.glsl - simple vertex fetch
20023:
20024: struct localBasis {
20025: vec3 normal;
20026: vec3 tangent, binormal;
20027: };
20028:
20029: vec3 QuatTransVec(in vec4 quat, in vec3 vec) {
20030: vec3 tmp = 2.0 * cross( quat.xyz, vec );
20031: return vec + quat.w * tmp + cross( quat.xyz, tmp );
20032: }
20033:
20034: void QTangentToLocalBasis( in vec4 qtangent, out localBasis LB ) {
20035: LB.normal = QuatTransVec( qtangent, vec3( 0.0, 0.0, 1.0 ) );
20036: LB.tangent = QuatTransVec( qtangent, vec3( 1.0, 0.0, 0.0 ) );
20037: LB.tangent *= sign( qtangent.w );
20038: LB.binormal = QuatTransVec( qtangent, vec3( 0.0, 1.0, 0.0 ) );
20039: }
20040:
20041: #if !defined(USE_VERTEX_ANIMATION) && !defined(USE_VERTEX_SKINNING)
20042:
20043: IN vec3 attr_Position;
20044: IN vec4 attr_Color;
20045: IN vec4 attr_QTangent;
20046: IN vec4 attr_TexCoord0;
20047:
20048: void VertexFetch(out vec4 position,
20049: out localBasis normalBasis,
20050: out vec4 color,
20051: out vec2 texCoord,
20052: out vec2 lmCoord)
20053: {
20054: position = vec4( attr_Position, 1.0 );
20055: QTangentToLocalBasis( attr_QTangent, normalBasis );
20056: color = attr_Color;
20057: texCoord = attr_TexCoord0.xy;
20058: lmCoord = attr_TexCoord0.zw;
20059: }
20060: #endif
70: #line 70
30000: #line 30000 // vertexSkinning_vp.glsl
30001: /*
30002: ===========================================================================
30003: Copyright (C) 2009-2011 Robert Beckebans <[email protected]>
30004:
30005: This file is part of XreaL source code.
30006:
30007: XreaL source code is free software; you can redistribute it
30008: and/or modify it under the terms of the GNU General Public License as
30009: published by the Free Software Foundation; either version 2 of the License,
30010: or (at your option) any later version.
30011:
30012: XreaL source code is distributed in the hope that it will be
30013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
30014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30015: GNU General Public License for more details.
30016:
30017: You should have received a copy of the GNU General Public License
30018: along with XreaL source code; if not, write to the Free Software
30019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30020: ===========================================================================
30021: */
30022: // vertexSkinning_vp.glsl - GPU vertex skinning for skeletal meshes
30023:
30024: #if defined(USE_VERTEX_SKINNING)
30025:
30026: IN vec3 attr_Position;
30027: IN vec2 attr_TexCoord0;
30028: IN vec4 attr_Color;
30029: IN vec4 attr_QTangent;
30030: IN vec4 attr_BoneFactors;
30031:
30032: // even elements are rotation quat, odd elements are translation + scale (in .w)
30033: uniform vec4 u_Bones[ 2 * MAX_GLSL_BONES ];
30034:
30035: void VertexFetch(out vec4 position,
30036: out localBasis LB,
30037: out vec4 color,
30038: out vec2 texCoord,
30039: out vec2 lmCoord)
30040: {
30041: const float scale = 1.0 / 256.0;
30042: const float weightScale = 1.0 / 255.0;
30043: localBasis inLB;
30044:
30045: // Unpack data from "bone factors". This used to have the index in the high byte and the weight
30046: // in the low byte, which may seem a bit more logical, but it triggered issues with some
30047: // Nvidia shader compilers (https://github.com/DaemonEngine/Daemon/issues/472).
30048: vec4 ipart = floor( attr_BoneFactors * scale );
30049: vec4 fpart = attr_BoneFactors * scale - ipart;
30050: // idx = 2 times the original bone index (the index input to boneFactor)
30051: ivec4 idx = ivec4( fpart * 512.0 );
30052: vec4 weights = ipart * weightScale;
30053:
30054: vec4 quat = u_Bones[ idx.x ];
30055: vec4 trans = u_Bones[ idx.x + 1 ];
30056:
30057: QTangentToLocalBasis( attr_QTangent, inLB );
30058:
30059: position.xyz = weights.x * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
30060: LB.normal = weights.x * (QuatTransVec( quat, inLB.normal ));
30061: LB.tangent = weights.x * (QuatTransVec( quat, inLB.tangent ));
30062: LB.binormal = weights.x * (QuatTransVec( quat, inLB.binormal ));
30063:
30064: quat = u_Bones[ idx.y ];
30065: trans = u_Bones[ idx.y + 1 ];
30066:
30067: position.xyz += weights.y * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
30068: LB.normal += weights.y * (QuatTransVec( quat, inLB.normal ));
30069: LB.tangent += weights.y * (QuatTransVec( quat, inLB.tangent ));
30070: LB.binormal += weights.y * (QuatTransVec( quat, inLB.binormal ));
30071:
30072: quat = u_Bones[ idx.z ];
30073: trans = u_Bones[ idx.z + 1 ];
30074:
30075: position.xyz += weights.z * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
30076: LB.normal += weights.z * (QuatTransVec( quat, inLB.normal ));
30077: LB.tangent += weights.z * (QuatTransVec( quat, inLB.tangent ));
30078: LB.binormal += weights.z * (QuatTransVec( quat, inLB.binormal ));
30079:
30080: quat = u_Bones[ idx.w ];
30081: trans = u_Bones[ idx.w + 1 ];
30082:
30083: position.xyz += weights.w * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
30084: LB.normal += weights.w * (QuatTransVec( quat, inLB.normal ));
30085: LB.tangent += weights.w * (QuatTransVec( quat, inLB.tangent ));
30086: LB.binormal += weights.w * (QuatTransVec( quat, inLB.binormal ));
30087:
30088: position.w = 1.0;
30089: LB.normal = normalize(LB.normal);
30090: LB.tangent = normalize(LB.tangent);
30091: LB.binormal = normalize(LB.binormal);
30092:
30093: color = attr_Color;
30094: texCoord = attr_TexCoord0;
30095: lmCoord = attr_TexCoord0;
30096: }
30097: #endif
71: #line 71
40000: #line 40000 // vertexAnimation_vp.glsl
40001: /*
40002: ===========================================================================
40003: Copyright (C) 2010 Robert Beckebans <[email protected]>
40004:
40005: This file is part of XreaL source code.
40006:
40007: XreaL source code is free software; you can redistribute it
40008: and/or modify it under the terms of the GNU General Public License as
40009: published by the Free Software Foundation; either version 2 of the License,
40010: or (at your option) any later version.
40011:
40012: XreaL source code is distributed in the hope that it will be
40013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
40014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40015: GNU General Public License for more details.
40016:
40017: You should have received a copy of the GNU General Public License
40018: along with XreaL source code; if not, write to the Free Software
40019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40020: ===========================================================================
40021: */
40022: // vertexAnimation_vp.glsl - interpolates .md3/.mdc vertex animations
40023:
40024: #if defined(USE_VERTEX_ANIMATION)
40025:
40026: IN vec3 attr_Position;
40027: IN vec4 attr_Color;
40028: IN vec4 attr_QTangent;
40029: IN vec2 attr_TexCoord0;
40030: IN vec3 attr_Position2;
40031: IN vec4 attr_QTangent2;
40032:
40033: uniform float u_VertexInterpolation;
40034:
40035: void VertexAnimation_P_N( vec3 fromPosition, vec3 toPosition,
40036: vec4 fromQTangent, vec4 toQTangent,
40037: float frac,
40038: inout vec4 position, inout vec3 normal)
40039: {
40040: vec3 fromNormal = QuatTransVec( fromQTangent, vec3( 0.0, 0.0, 1.0 ) );
40041: vec3 toNormal = QuatTransVec( toQTangent, vec3( 0.0, 0.0, 1.0 ) );
40042:
40043: position.xyz = 512.0 * mix(fromPosition, toPosition, frac);
40044: position.w = 1;
40045:
40046: normal = normalize(mix(fromNormal, toNormal, frac));
40047: }
40048:
40049: void VertexFetch(out vec4 position,
40050: out localBasis LB,
40051: out vec4 color,
40052: out vec2 texCoord,
40053: out vec2 lmCoord)
40054: {
40055: localBasis fromLB, toLB;
40056:
40057: QTangentToLocalBasis( attr_QTangent, fromLB );
40058: QTangentToLocalBasis( attr_QTangent2, toLB );
40059:
40060: position.xyz = 512.0 * mix(attr_Position, attr_Position2, u_VertexInterpolation);
40061: position.w = 1;
40062:
40063: LB.normal = normalize(mix(fromLB.normal, toLB.normal, u_VertexInterpolation));
40064: LB.tangent = normalize(mix(fromLB.tangent, toLB.tangent, u_VertexInterpolation));
40065: LB.binormal = normalize(mix(fromLB.binormal, toLB.binormal, u_VertexInterpolation));
40066:
40067: color = attr_Color;
40068: texCoord = attr_TexCoord0;
40069: lmCoord = attr_TexCoord0;
40070: }
40071: #endif
72: #line 72
50000: #line 50000 // shaderProfiler_vp.glsl
50001: /*
50002: ===========================================================================
50003:
50004: Daemon BSD Source Code
50005: Copyright (c) 2024 Daemon Developers
50006: All rights reserved.
50007:
50008: This file is part of the Daemon BSD Source Code (Daemon Source Code).
50009:
50010: Redistribution and use in source and binary forms, with or without
50011: modification, are permitted provided that the following conditions are met:
50012: * Redistributions of source code must retain the above copyright
50013: notice, this list of conditions and the following disclaimer.
50014: * Redistributions in binary form must reproduce the above copyright
50015: notice, this list of conditions and the following disclaimer in the
50016: documentation and/or other materials provided with the distribution.
50017: * Neither the name of the Daemon developers nor the
50018: names of its contributors may be used to endorse or promote products
50019: derived from this software without specific prior written permission.
50020:
50021: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
50022: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50023: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50024: DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
50025: DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50026: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50027: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50028: ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50029: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50030: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50031:
50032: ===========================================================================
50033: */
50034:
50035: /* shaderProfiler_vp.glsl */
50036:
50037: #if defined(r_profilerRenderSubGroups) && defined(HAVE_KHR_shader_subgroup_basic) && defined(HAVE_KHR_shader_subgroup_arithmetic)
50038: uniform uint u_ProfilerRenderSubGroups;
50039: OUT(flat) float var_SubGroupCount;
50040:
50041: #define SHADER_PROFILER_SET \
50042: if( u_ProfilerRenderSubGroups == 1 ) {\
50043: var_SubGroupCount = subgroupAdd( 1.0 ) / float( gl_SubgroupSize );\
50044: }
50045: #else
50046: #define SHADER_PROFILER_OUT
50047: #define SHADER_PROFILER_SET
50048: #endif
73: #line 73
74:
75: #if !defined(USE_MATERIAL_SYSTEM)
76: uniform mat3x2 u_TextureMatrix;
77: #endif
78:
79: uniform vec3 u_ViewOrigin;
80:
81: uniform float u_Time;
82:
83: uniform colorModulatePack u_ColorModulateColorGen;
84: uniform colorPack u_Color;
85:
86:
87: #if defined(USE_TCGEN_ENVIRONMENT)
88: uniform mat4 u_ModelMatrix;
89: #endif
90: uniform mat4 u_ModelViewProjectionMatrix;
91:
92: #if defined(USE_DEPTH_FADE)
93: uniform float u_DepthScale;
94: OUT(smooth) float var_FadeDepth;
95: #endif
96:
97: OUT(smooth) vec2 var_TexCoords;
98: OUT(smooth) vec4 var_Color;
99:
100: void DeformVertex( inout vec4 pos, inout vec3 normal, inout vec2 st, inout vec4 color, in float time );
101:
102: void main() {
60000: #line 60000 // material_vp.glsl
60001: /*
60002: ===========================================================================
60003:
60004: Daemon BSD Source Code
60005: Copyright (c) 2024 Daemon Developers
60006: All rights reserved.
60007:
60008: This file is part of the Daemon BSD Source Code (Daemon Source Code).
60009:
60010: Redistribution and use in source and binary forms, with or without
60011: modification, are permitted provided that the following conditions are met:
60012: * Redistributions of source code must retain the above copyright
60013: notice, this list of conditions and the following disclaimer.
60014: * Redistributions in binary form must reproduce the above copyright
60015: notice, this list of conditions and the following disclaimer in the
60016: documentation and/or other materials provided with the distribution.
60017: * Neither the name of the Daemon developers nor the
60018: names of its contributors may be used to endorse or promote products
60019: derived from this software without specific prior written permission.
60020:
60021: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
60022: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60023: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60024: DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
60025: DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60026: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60027: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60028: ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60029: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60030: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60031:
60032: ===========================================================================
60033: */
60034:
60035: /* material_vp.glsl */
60036:
60037: #if defined(USE_MATERIAL_SYSTEM)
60038:
60039: #ifdef HAVE_ARB_shader_draw_parameters
60040: in_drawID = drawID;
60041: in_baseInstance = baseInstance;
60042: #endif // !HAVE_ARB_shader_draw_parameters
60043:
60044: #endif // !USE_MATERIAL_SYSTEM
103: #line 103
104:
105: vec4 position;
106: localBasis LB;
107: vec4 color;
108: vec2 texCoord, lmCoord;
109:
110: VertexFetch( position, LB, color, texCoord, lmCoord );
111: ColorModulateColor_lightFactor( u_ColorModulateColorGen, u_Color, color );
112:
113: DeformVertex( position, LB.normal, texCoord, color, u_Time );
114:
115: // transform vertex position into homogenous clip-space
116: gl_Position = u_ModelViewProjectionMatrix * position;
117:
118: // transform texcoords
119: #if defined(USE_TCGEN_ENVIRONMENT)
120: // TODO: Explain why only the rotational part of u_ModelMatrix is relevant
121: position.xyz = mat3( u_ModelMatrix ) * position.xyz;
122:
123: vec3 viewer = normalize( u_ViewOrigin - position.xyz );
124:
125: float d = dot( LB.normal, viewer );
126:
127: vec3 reflected = LB.normal * 2.0 * d - viewer;
128:
129: var_TexCoords = 0.5 + vec2( 0.5, -0.5 ) * reflected.yz;
130: #elif defined(USE_TCGEN_LIGHTMAP)
131: var_TexCoords = ( u_TextureMatrix * vec3( lmCoord, 1.0 ) ).xy;
132: #else
133: var_TexCoords = ( u_TextureMatrix * vec3( texCoord, 1.0 ) ).xy;
134: #endif
135:
136: #if defined(USE_DEPTH_FADE)
137: // compute z of end of fading effect
138: vec4 fadeDepth = u_ModelViewProjectionMatrix * ( position - u_DepthScale * vec4(LB.normal, 0.0) );
139: var_FadeDepth = fadeDepth.z / fadeDepth.w;
140: #endif
141:
142: SHADER_PROFILER_SET
143:
144: var_Color = color;
145: }
Warn: Compile log:
0:2(12): warning: extension `GL_EXT_shader_non_constant_global_initializers' unsupported in vertex shader
0:75(17): error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'
]terminate called after throwing an instance of 'ShaderException'
what(): Couldn't compile vertex shader: generic