Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
4d085a134c
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,5 @@
|
||||
bld*/
|
||||
build/
|
||||
build-32/
|
||||
build-64/
|
||||
build-win/
|
||||
build*/
|
||||
cmake_build/
|
||||
dependencies/
|
||||
CMakeFiles/
|
||||
|
@ -131,40 +131,21 @@
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="ubo"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Uniform buffer objects" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="texture_compression"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Texture compression" I18N="Video settings"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="hd-textures"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Use high definition textures" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
<!--
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="anim_gfx"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Animated Scenery" I18N="Video settings"/>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
|
||||
<spacer height="20" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
|
@ -1,18 +1,16 @@
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec3 Position;
|
||||
uniform vec2 Size;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec2 Corner;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec2 Corner;
|
||||
in vec2 Texcoord;
|
||||
out vec2 uv;
|
||||
#else
|
||||
attribute vec2 Corner;
|
||||
attribute vec2 Texcoord;
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
@ -2,16 +2,6 @@ uniform sampler2D tex_128;
|
||||
uniform sampler2D tex_256;
|
||||
uniform sampler2D tex_512;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
|
@ -3,15 +3,6 @@ uniform float greenLmn[9];
|
||||
uniform float redLmn[9];
|
||||
uniform sampler2D ntex;
|
||||
uniform mat4 TransposeViewMatrix;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
out vec4 Diff;
|
||||
|
||||
|
@ -5,16 +5,6 @@ uniform sampler2D tex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
|
@ -1,20 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
|
@ -1,16 +1,6 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
float focalDepth = 10.;
|
||||
|
@ -1,13 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 quadcorner;
|
||||
in vec2 texcoord;
|
||||
in vec3 position;
|
||||
|
@ -7,24 +7,6 @@ uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
|
@ -1,13 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
uniform int idx;
|
||||
|
||||
in vec3 Position;
|
||||
|
@ -14,16 +14,6 @@ uniform vec3 extents;
|
||||
uniform mat4 RHMatrix;
|
||||
uniform mat4 InvRHMatrix;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
vec4 SHBasis (const in vec3 dir)
|
||||
{
|
||||
float L00 = 0.282095;
|
||||
|
@ -1,20 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform vec3 windDir;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
@ -1,21 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform sampler2D Albedo;
|
||||
uniform vec3 SunDir;
|
||||
uniform sampler2D dtex;
|
||||
|
17
data/shaders/header.txt
Normal file
17
data/shaders/header.txt
Normal file
@ -0,0 +1,17 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
@ -1,13 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
uniform vec3 windDir;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
|
@ -1,20 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
|
@ -1,11 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
uniform vec3 windDir;
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec3 Position;
|
||||
|
@ -1,12 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
@ -2,16 +2,6 @@ uniform sampler2D tex;
|
||||
uniform float zn;
|
||||
uniform float zf;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
out float Depth;
|
||||
|
||||
void main()
|
||||
|
@ -1,16 +1,6 @@
|
||||
uniform sampler2D edgesMap;
|
||||
uniform sampler2D areaMap;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#define MAX_SEARCH_STEPS 8.0
|
||||
#define MAX_DISTANCE 33.0
|
||||
|
||||
|
@ -1,13 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
|
@ -37,16 +37,6 @@ uniform float mask_radius;
|
||||
|
||||
uniform mat4 previous_viewproj;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Number of samples used for blurring
|
||||
|
@ -1,12 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
|
@ -1,20 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
|
@ -1,17 +1,13 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture(tex, uv);
|
||||
if (color.a < 0.5) discard;
|
||||
FragColor = vec4(color.xyz, 1.);
|
||||
vec4 col = texture(tex, uv);
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
if (col.a < 0.5) discard;
|
||||
FragColor = vec4(col.xyz, 1.);
|
||||
}
|
||||
|
@ -1,23 +1,5 @@
|
||||
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
|
@ -1,19 +1,16 @@
|
||||
uniform sampler2D Albedo;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture(Albedo, uv);
|
||||
if (color.a < 0.5) discard;
|
||||
vec4 col = texture(Albedo, uv);
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
if (col.a * color.a < 0.5) discard;
|
||||
vec3 LightFactor = getLightFactor(1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
FragColor = vec4(col.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
@ -2,16 +2,6 @@ uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform mat4 invproj;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in float lf;
|
||||
in vec2 tc;
|
||||
in vec3 pc;
|
||||
|
@ -1,12 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
uniform vec3 color_from;
|
||||
uniform vec3 color_to;
|
||||
|
||||
|
@ -2,24 +2,6 @@ uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform float spec;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
flat in vec3 center;
|
||||
flat in float energy;
|
||||
flat in vec3 col;
|
||||
|
@ -1,20 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
in vec3 Position;
|
||||
in float Energy;
|
||||
in vec3 Color;
|
||||
|
@ -60,7 +60,7 @@ void main(void)
|
||||
vec2 uv = RHuv + offset * 0.01;
|
||||
|
||||
// Get world position and normal from the RSM sample
|
||||
float depth = texture(dtex, uv).z;
|
||||
float depth = texture(dtex, uv).x;
|
||||
vec4 RSMPos = inverse(RSMMatrix) * (2. * vec4(uv, depth, 1.) - 1.);
|
||||
RSMPos /= RSMPos.w;
|
||||
vec3 RSMAlbedo = texture(ctex, uv).xyz;
|
||||
@ -74,7 +74,7 @@ void main(void)
|
||||
float dist = distance(SamplePos, RSMPos.xyz) / R_wcs;
|
||||
// Determine the incident direction.
|
||||
// Avoid very close samples (and numerical instability problems)
|
||||
vec3 RSM_to_RH_dir = (dist <= 0.00) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
|
||||
vec3 RSM_to_RH_dir = (dist <= 0.1) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
|
||||
float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.);
|
||||
float factor = dotprod / (0.1 + dist * dist);
|
||||
|
||||
|
@ -10,5 +10,5 @@ void main()
|
||||
float r = texture(SHR, uvw).w;
|
||||
float g = texture(SHG, uvw).w;
|
||||
float b = texture(SHB, uvw).w;
|
||||
FragColor = max(vec4(r, g, b, 1.0), vec4(0.));
|
||||
FragColor = max(10. * vec4(r, g, b, 1.0), vec4(0.));
|
||||
}
|
||||
|
@ -1,15 +1,5 @@
|
||||
uniform vec3 extents;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
uniform mat4 RHMatrix;
|
||||
|
||||
ivec3 resolution = ivec3(32, 16, 32);
|
||||
@ -25,6 +15,6 @@ void main(void)
|
||||
uvw = vec3(gx, gy, gz) / vec3(resolution);
|
||||
vec3 WorldPos = (2. * uvw - 1.) * extents;
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * RHMatrix * vec4(WorldPos, 1.);
|
||||
gl_PointSize = 100. / gl_Position.w;
|
||||
gl_PointSize = 500. / gl_Position.w;
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (texture(tex, uv).a < .5) discard;
|
||||
RSMColor = texture(tex, uv).xyz * color.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
uniform mat4 RSMMatrix;
|
||||
|
||||
uniform mat4 TextureMatrix =
|
||||
@ -13,24 +12,28 @@ layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelViewProjectionMatrix = RSMMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModel = transpose(InverseModelMatrix);
|
||||
mat4 TransposeInverseModel = transpose(inverse(ModelMatrix));
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (vec4(Normal, 0.)).xyz;
|
||||
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
uv_bis = SecondTexcoord;
|
||||
color = Color.zyxw;
|
||||
}
|
||||
|
@ -1,12 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
|
@ -1,12 +1,3 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform vec3 windDir;
|
||||
|
||||
|
@ -1,21 +1,3 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform samplerCube tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
|
@ -8,16 +8,6 @@ uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec3 ambient;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
|
27
data/shaders/splatting_rsm.frag
Normal file
27
data/shaders/splatting_rsm.frag
Normal file
@ -0,0 +1,27 @@
|
||||
uniform sampler2D tex_layout;
|
||||
uniform sampler2D tex_detail0;
|
||||
uniform sampler2D tex_detail1;
|
||||
uniform sampler2D tex_detail2;
|
||||
uniform sampler2D tex_detail3;
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
in vec3 nor;
|
||||
layout (location = 0) out vec3 RSMColor;
|
||||
layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
RSMColor = splatted.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
@ -3,25 +3,6 @@
|
||||
|
||||
uniform sampler2D dtex;
|
||||
uniform vec4 samplePoints[16];
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
out float AO;
|
||||
|
||||
const float sigma = 1.;
|
||||
|
@ -8,24 +8,6 @@ uniform mat4 invproj;
|
||||
//uniform int hasclouds;
|
||||
//uniform vec2 wind;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
|
||||
|
@ -10,25 +10,6 @@ uniform vec3 col;
|
||||
//uniform vec2 wind;
|
||||
//uniform float shadowoffset;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform mat4 ShadowViewProjMatrixes[4];
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
|
@ -1,76 +0,0 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2DArrayShadow shadowtex;
|
||||
|
||||
uniform vec3 direction;
|
||||
uniform vec3 col;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform mat4 ShadowViewProjMatrixes[4];
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
|
||||
vec3 DecodeNormal(vec2 n);
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
|
||||
vec3 getShadowFactor(vec3 pos)
|
||||
{
|
||||
vec3 cascadeColor[] = vec3[](
|
||||
vec3(1., 0., 0.),
|
||||
vec3(0., 1., 0.),
|
||||
vec3(0., 0., 1.),
|
||||
vec3(1., 1., 1.)
|
||||
);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
vec4 shadowcoord = (ShadowViewProjMatrixes[i] * vec4(pos, 1.0));
|
||||
shadowcoord /= shadowcoord.w;
|
||||
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
|
||||
if (shadowtexcoord.x < 0. || shadowtexcoord.x > 1. || shadowtexcoord.y < 0. || shadowtexcoord.y > 1.)
|
||||
continue;
|
||||
return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * shadowcoord.z + 0.5));
|
||||
}
|
||||
return vec3(1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
float z = texture(dtex, uv).x;
|
||||
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
|
||||
xpos = InverseViewMatrix * InverseProjectionMatrix * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
float roughness =texture(ntex, uv).z;
|
||||
vec3 eyedir = -normalize(xpos.xyz);
|
||||
|
||||
// Normalized on the cpu
|
||||
vec3 L = direction;
|
||||
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
vec3 outcol = NdotL * col;
|
||||
|
||||
// Shadows
|
||||
vec3 factor = getShadowFactor(xpos.xyz);
|
||||
Diff = vec4(factor * NdotL * col, 1.);
|
||||
Spec = vec4(factor * Specular, 1.);
|
||||
return;
|
||||
}
|
@ -6,16 +6,6 @@ uniform float exposure = .09;
|
||||
uniform float Lwhite = 1.;
|
||||
uniform float vignette_weight = 0.;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getCIEYxy(vec3 rgbColor);
|
||||
|
@ -7,17 +7,6 @@ uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
@ -2,24 +2,6 @@ uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
uniform vec2 screen;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(float specMapValue)
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
|
@ -49,6 +49,9 @@
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
|
||||
#define XRANDR_ROTATION_LEFT (1 << 1)
|
||||
#define XRANDR_ROTATION_RIGHT (1 << 3)
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
@ -342,12 +345,31 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
|
||||
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
||||
float refresh_rate, refresh_rate_new;
|
||||
unsigned int mode0_width = -1, mode0_height = -1;
|
||||
|
||||
for (int i = 0; i < res->nmode; i++)
|
||||
{
|
||||
const XRRModeInfo* mode = &res->modes[i];
|
||||
unsigned int w, h;
|
||||
|
||||
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
|
||||
{
|
||||
w = mode->height;
|
||||
h = mode->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = mode->width;
|
||||
h = mode->height;
|
||||
}
|
||||
|
||||
if (bestMode == -1 && mode->id == output->modes[0])
|
||||
{
|
||||
mode0_width = w;
|
||||
mode0_height = h;
|
||||
}
|
||||
|
||||
if (bestMode == -1 && mode->width == Width && mode->height == Height)
|
||||
if (bestMode == -1 && w == Width && h == Height)
|
||||
{
|
||||
for (int j = 0; j < output->nmode; j++)
|
||||
{
|
||||
@ -359,7 +381,7 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bestMode != -1 && mode->width == Width && mode->height == Height)
|
||||
else if (bestMode != -1 && w == Width && h == Height)
|
||||
{
|
||||
refresh_rate_new = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
|
||||
|
||||
@ -382,6 +404,8 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
if (bestMode == -1)
|
||||
{
|
||||
bestMode = 0;
|
||||
Width = mode0_width;
|
||||
Height = mode0_height;
|
||||
}
|
||||
|
||||
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
|
||||
@ -1628,13 +1652,25 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
||||
for (int i = 0; i < res->nmode; i++)
|
||||
{
|
||||
const XRRModeInfo* mode = &res->modes[i];
|
||||
unsigned int w, h;
|
||||
|
||||
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
|
||||
{
|
||||
w = mode->height;
|
||||
h = mode->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = mode->width;
|
||||
h = mode->height;
|
||||
}
|
||||
|
||||
for (int j = 0; j < output->nmode; j++)
|
||||
{
|
||||
{
|
||||
if (mode->id == output->modes[j])
|
||||
{
|
||||
VideoModeList.addMode(core::dimension2d<u32>(
|
||||
mode->width, mode->height), defaultDepth);
|
||||
w, h), defaultDepth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1643,7 +1679,7 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
||||
{
|
||||
old_mode = crtc->mode;
|
||||
VideoModeList.setDesktop(defaultDepth,
|
||||
core::dimension2d<u32>(mode->width, mode->height));
|
||||
core::dimension2d<u32>(w, h));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,9 +446,6 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX BoolUserConfigParam m_high_definition_textures
|
||||
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_high_definition_textures",
|
||||
&m_video_group, "Enable high definition textures"));
|
||||
PARAM_PREFIX BoolUserConfigParam m_ubo_disabled
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false, "disable_ubo_support",
|
||||
&m_video_group, "Disable UBO support"));
|
||||
PARAM_PREFIX BoolUserConfigParam m_glow
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_glow",
|
||||
&m_video_group, "Enable Glow"));
|
||||
|
@ -96,6 +96,10 @@ CALLBACK
|
||||
debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
||||
const GLchar* msg, const void *userparam)
|
||||
{
|
||||
// ignore minor notifications sent by some drivers (notably the nvidia one)
|
||||
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
|
||||
return;
|
||||
|
||||
switch(source)
|
||||
{
|
||||
case GL_DEBUG_SOURCE_API_ARB:
|
||||
@ -245,6 +249,22 @@ void initGL()
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::string LoadHeader()
|
||||
{
|
||||
std::string result;
|
||||
std::ifstream Stream(file_manager->getAsset("shaders/header.txt").c_str(), std::ios::in);
|
||||
|
||||
if (Stream.is_open())
|
||||
{
|
||||
std::string Line = "";
|
||||
while (getline(Stream, Line))
|
||||
result += "\n" + Line;
|
||||
Stream.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Mostly from shader tutorial
|
||||
GLuint LoadShader(const char * file, unsigned type)
|
||||
{
|
||||
@ -254,10 +274,11 @@ GLuint LoadShader(const char * file, unsigned type)
|
||||
std::string Code = versionString;
|
||||
std::ifstream Stream(file, std::ios::in);
|
||||
Code += "//" + std::string(file) + "\n";
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
Code += "#define UBO_DISABLED\n";
|
||||
if (irr_driver->hasVSLayerExtension())
|
||||
Code += "#define VSLayer\n";
|
||||
Code += LoadHeader();
|
||||
if (Stream.is_open())
|
||||
{
|
||||
std::string Line = "";
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <ICameraSceneNode.h>
|
||||
#include <IParticleSystemSceneNode.h>
|
||||
#include "guiengine/engine.hpp"
|
||||
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#define COMPONENTCOUNT 8
|
||||
|
||||
scene::IParticleSystemSceneNode *ParticleSystemProxy::addParticleNode(
|
||||
@ -185,7 +185,10 @@ void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmi
|
||||
|
||||
const core::vector3df& extent = emitter->getBox().getExtent();
|
||||
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
bool randomize_initial_y = ((ParticleEmitter*)emitter)->randomizeInitialY();
|
||||
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
particles[i].PositionX = emitter->getBox().MinEdge.X + os::Randomizer::frand() * extent.X;
|
||||
particles[i].PositionY = emitter->getBox().MinEdge.Y + os::Randomizer::frand() * extent.Y;
|
||||
particles[i].PositionZ = emitter->getBox().MinEdge.Z + os::Randomizer::frand() * extent.Z;
|
||||
@ -196,6 +199,9 @@ void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmi
|
||||
generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size,
|
||||
initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ);
|
||||
memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float));
|
||||
|
||||
if (randomize_initial_y)
|
||||
particles[i].PositionY = os::Randomizer::frand()*50.0f; // -100.0f;
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW);
|
||||
|
@ -335,8 +335,24 @@ void IrrDriver::initDevice()
|
||||
{
|
||||
Log::warn("irr_driver", "The window size specified in "
|
||||
"user config is larger than your screen!");
|
||||
UserConfigParams::m_width = 800;
|
||||
UserConfigParams::m_height = 600;
|
||||
UserConfigParams::m_width = (int)ssize.Width;
|
||||
UserConfigParams::m_height = (int)ssize.Height;
|
||||
}
|
||||
|
||||
core::dimension2d<u32> res = core::dimension2du(UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
res = m_device->getVideoModeList()->getVideoModeResolution(res, res);
|
||||
|
||||
if (res.Width > 0 && res.Height > 0)
|
||||
{
|
||||
UserConfigParams::m_width = res.Width;
|
||||
UserConfigParams::m_height = res.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::verbose("irr_driver", "Cannot get information about "
|
||||
"resolutions. Try to use the default one.");
|
||||
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
|
||||
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
|
||||
}
|
||||
|
||||
m_device->closeDevice();
|
||||
@ -398,17 +414,18 @@ void IrrDriver::initDevice()
|
||||
}
|
||||
*/
|
||||
m_device = createDeviceEx(params);
|
||||
|
||||
if(m_device)
|
||||
break;
|
||||
} // for bits=32, 24, 16
|
||||
|
||||
|
||||
// if still no device, try with a standard 800x600 window size, maybe
|
||||
// if still no device, try with a default screen size, maybe
|
||||
// size is the problem
|
||||
if(!m_device)
|
||||
{
|
||||
UserConfigParams::m_width = 800;
|
||||
UserConfigParams::m_height = 600;
|
||||
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
|
||||
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
|
||||
|
||||
m_device = createDevice(video::EDT_OPENGL,
|
||||
core::dimension2du(UserConfigParams::m_width,
|
||||
@ -447,6 +464,13 @@ void IrrDriver::initDevice()
|
||||
Log::info("IrrDriver", "OpenGL vendor: %s", glGetString(GL_VENDOR));
|
||||
Log::info("IrrDriver", "OpenGL renderer: %s", glGetString(GL_RENDERER));
|
||||
Log::info("IrrDriver", "OpenGL version string: %s", glGetString(GL_VERSION));
|
||||
|
||||
m_need_ubo_workaround = false;
|
||||
#ifdef WIN32
|
||||
// Fix for Intel Sandy Bridge on Windows which supports GL up to 3.1 only
|
||||
if (strstr((const char *)glGetString(GL_VENDOR), "Intel") != nullptr && (GLMajorVersion == 3 && GLMinorVersion == 1))
|
||||
m_need_ubo_workaround = true;
|
||||
#endif
|
||||
}
|
||||
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1));
|
||||
|
||||
@ -865,12 +889,20 @@ void IrrDriver::setAllMaterialFlags(scene::IMesh *mesh) const
|
||||
{
|
||||
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
||||
video::SMaterial &irr_material=mb->getMaterial();
|
||||
for(unsigned int j=0; j<video::MATERIAL_MAX_TEXTURES; j++)
|
||||
{
|
||||
video::ITexture* t=irr_material.getTexture(j);
|
||||
if(t) material_manager->setAllMaterialFlags(t, mb);
|
||||
video::ITexture* t=irr_material.getTexture(0);
|
||||
if(t) material_manager->setAllMaterialFlags(t, mb);
|
||||
|
||||
// special case : for splatting, the main material is on layer 1.
|
||||
// it was done this way to provide a fallback for computers
|
||||
// where shaders are not supported
|
||||
t = irr_material.getTexture(1);
|
||||
if (t)
|
||||
{
|
||||
Material* mat = material_manager->getMaterialFor(t, mb);
|
||||
if (mat != NULL && mat->getShaderType() == Material::SHADERTYPE_SPLATTING)
|
||||
material_manager->setAllMaterialFlags(t, mb);
|
||||
}
|
||||
|
||||
} // for j<MATERIAL_MAX_TEXTURES
|
||||
material_manager->setAllUntexturedMaterialFlags(mb);
|
||||
} // for i<getMeshBufferCount()
|
||||
} // setAllMaterialFlags
|
||||
@ -1201,6 +1233,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &tex
|
||||
SkyboxTextures = texture;
|
||||
SphericalHarmonicsTextures = sphericalHarmonics;
|
||||
SkyboxCubeMap = 0;
|
||||
m_SH_dirty = true;
|
||||
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
|
||||
texture[2], texture[3],
|
||||
texture[4], texture[5]);
|
||||
@ -1210,6 +1243,7 @@ void IrrDriver::suppressSkyBox()
|
||||
{
|
||||
SkyboxTextures.clear();
|
||||
SphericalHarmonicsTextures.clear();
|
||||
m_SH_dirty = true;
|
||||
if ((SkyboxCubeMap) && (!ProfileWorld::isNoGraphics()))
|
||||
glDeleteTextures(1, &SkyboxCubeMap);
|
||||
SkyboxCubeMap = 0;
|
||||
@ -1679,7 +1713,7 @@ void IrrDriver::displayFPS()
|
||||
core::stringw fpsString = buffer;
|
||||
|
||||
static video::SColor fpsColor = video::SColor(255, 0, 0, 0);
|
||||
|
||||
|
||||
font->draw( fpsString.c_str(), core::rect< s32 >(100,0,400,50), fpsColor, false );
|
||||
} // updateFPS
|
||||
|
||||
@ -2307,7 +2341,7 @@ void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimli
|
||||
// viamb = (dynamic_cast<scene::IMeshSceneNode*>(node))->isReadOnlyMaterials();
|
||||
// mesh = (dynamic_cast<scene::IMeshSceneNode*>(node))->getMesh();
|
||||
//}
|
||||
|
||||
|
||||
for (i = 0; i < mcount; i++)
|
||||
{
|
||||
video::SMaterial &nodemat = node->getMaterial(i);
|
||||
|
@ -196,6 +196,7 @@ class IrrDriver : public IEventReceiver, public NoCopy
|
||||
private:
|
||||
int GLMajorVersion, GLMinorVersion;
|
||||
bool hasVSLayer;
|
||||
bool m_need_ubo_workaround;
|
||||
/** The irrlicht device. */
|
||||
IrrlichtDevice *m_device;
|
||||
/** Irrlicht scene manager. */
|
||||
@ -220,6 +221,7 @@ private:
|
||||
core::vector3df rh_extend;
|
||||
core::matrix4 rh_matrix;
|
||||
core::matrix4 rsm_matrix;
|
||||
core::vector2df m_current_screen_size;
|
||||
|
||||
/** Additional details to be shown in case that a texture is not found.
|
||||
* This is used to specify details like: "while loading kart '...'" */
|
||||
@ -233,6 +235,7 @@ private:
|
||||
|
||||
std::vector<video::ITexture *> SkyboxTextures;
|
||||
std::vector<video::ITexture *> SphericalHarmonicsTextures;
|
||||
bool m_SH_dirty;
|
||||
|
||||
float blueSHCoeff[9];
|
||||
float greenSHCoeff[9];
|
||||
@ -278,6 +281,11 @@ public:
|
||||
return 120;
|
||||
}
|
||||
|
||||
bool needUBOWorkaround() const
|
||||
{
|
||||
return m_need_ubo_workaround;
|
||||
}
|
||||
|
||||
bool hasVSLayerExtension() const
|
||||
{
|
||||
return hasVSLayer;
|
||||
@ -385,6 +393,7 @@ public:
|
||||
void initDevice();
|
||||
void reset();
|
||||
void generateSkyboxCubemap();
|
||||
void generateDiffuseCoefficients();
|
||||
void renderSkybox(const scene::ICameraSceneNode *camera);
|
||||
void setPhase(STKRenderingPass);
|
||||
STKRenderingPass getPhase() const;
|
||||
@ -688,6 +697,7 @@ public:
|
||||
const core::matrix4 & getPreviousPVMatrix() { return m_previousProjViewMatrix; }
|
||||
const core::matrix4 &getProjViewMatrix() const { return m_ProjViewMatrix; }
|
||||
const core::matrix4 &getInvProjViewMatrix() const { return m_InvProjViewMatrix; }
|
||||
const core::vector2df &getCurrentScreenSize() const { return m_current_screen_size; }
|
||||
#ifdef DEBUG
|
||||
/** Removes debug meshes. */
|
||||
void clearDebugMesh() { m_debug_meshes.clear(); }
|
||||
|
@ -287,7 +287,8 @@ public:
|
||||
|
||||
ParticleEmitter::ParticleEmitter(const ParticleKind* type,
|
||||
const Vec3 &position,
|
||||
scene::ISceneNode* parent)
|
||||
scene::ISceneNode* parent,
|
||||
bool randomize_initial_y)
|
||||
: m_position(position)
|
||||
{
|
||||
assert(type != NULL);
|
||||
@ -298,6 +299,7 @@ ParticleEmitter::ParticleEmitter(const ParticleKind* type,
|
||||
m_parent = parent;
|
||||
m_emission_decay_rate = 0;
|
||||
m_is_glsl = irr_driver->isGLSL();
|
||||
m_randomize_initial_y = randomize_initial_y;
|
||||
|
||||
|
||||
setParticleType(type);
|
||||
|
@ -74,6 +74,7 @@ private:
|
||||
/** The irrlicht emitter contains this info, but as an int. We want it as a float */
|
||||
float m_min_rate, m_max_rate;
|
||||
|
||||
bool m_randomize_initial_y;
|
||||
|
||||
public:
|
||||
|
||||
@ -81,7 +82,8 @@ public:
|
||||
|
||||
ParticleEmitter (const ParticleKind* type,
|
||||
const Vec3 &position,
|
||||
scene::ISceneNode* parent = NULL);
|
||||
scene::ISceneNode* parent = NULL,
|
||||
bool randomize_initial_y = false);
|
||||
virtual ~ParticleEmitter();
|
||||
virtual void update (float dt);
|
||||
void setCreationRateAbsolute(float fraction);
|
||||
@ -104,6 +106,8 @@ public:
|
||||
void unsetNode() { m_node = NULL; }
|
||||
|
||||
void addHeightMapAffector(Track* t);
|
||||
|
||||
bool randomizeInitialY() const { return m_randomize_initial_y; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -278,11 +278,11 @@ void PostProcessing::renderSunlight()
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glUseProgram(FullScreenShader::SunLightShader::Program);
|
||||
glBindVertexArray(FullScreenShader::SunLightShader::vao);
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::SunLightShader::setUniforms(cb->getPosition(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1);
|
||||
glUseProgram(FullScreenShader::SunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SunLightShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::SunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
@ -296,9 +296,9 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
setTexture(FullScreenShader::ShadowedSunLightShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::ShadowedSunLightShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::ShadowedSunLightShader::getInstance()->TU_shadowtex);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, depthtex);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@ -307,19 +307,10 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
|
||||
if (irr_driver->getShadowViz())
|
||||
{
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightDebugShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightDebugShader::vao);
|
||||
FullScreenShader::ShadowedSunLightDebugShader::setUniforms(cb->getPosition(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2);
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::getInstance()->vao);
|
||||
FullScreenShader::ShadowedSunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::vao);
|
||||
FullScreenShader::ShadowedSunLightShader::setUniforms(cb->getPosition(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
@ -645,11 +636,10 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::ToneMapShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::vao);
|
||||
setTexture(0, rtt, GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_LOG_LUMINANCE), GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST);
|
||||
FullScreenShader::ToneMapShader::setUniforms(irr_driver->getExposure(), irr_driver->getLwhite(), 0, 1);
|
||||
glUseProgram(FullScreenShader::ToneMapShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::ToneMapShader::getInstance()->TU_tex, rtt, GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::ToneMapShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
@ -144,6 +144,9 @@ void IrrDriver::renderGLSL(float dt)
|
||||
if (World::getWorld() && World::getWorld()->getTrack()->hasShadows() && !SphericalHarmonicsTextures.empty())
|
||||
irr_driver->getSceneManager()->setAmbientLight(SColor(0, 0, 0, 0));
|
||||
|
||||
// TODO: put this outside of the rendering loop
|
||||
generateDiffuseCoefficients();
|
||||
|
||||
unsigned plc = UpdateLightsInfo(camnode, dt);
|
||||
computeCameraMatrix(camnode, viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
|
||||
renderScene(camnode, plc, glows, dt, track->hasShadows(), false);
|
||||
@ -276,7 +279,7 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
// To avoid wrong culling, use the largest view possible
|
||||
m_scene_manager->setActiveCamera(m_suncam);
|
||||
if (!m_mipviz && !m_wireframe && UserConfigParams::m_dynamic_lights &&
|
||||
UserConfigParams::m_shadows && hasShadow)
|
||||
UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround() && hasShadow)
|
||||
renderShadows();
|
||||
m_scene_manager->setActiveCamera(camnode);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
@ -380,6 +383,8 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
if (!UserConfigParams::m_dynamic_lights && !forceRTT)
|
||||
{
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -558,6 +563,8 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
|
||||
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
||||
irr_driver->genProjViewMatrix();
|
||||
|
||||
m_current_screen_size = core::vector2df(float(width), float(height));
|
||||
|
||||
const float oldfar = camnode->getFarValue();
|
||||
const float oldnear = camnode->getNearValue();
|
||||
float FarValues[] =
|
||||
|
@ -212,9 +212,9 @@ void IrrDriver::renderSolidFirstPass()
|
||||
std::vector<TexUnit> object_pass1_texunits = TexUnits(TexUnit(MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true) );
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatDefault::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatSphereMap::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatDetails::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatSplatting::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(object_pass1_texunits, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true)), ListMatAlphaRef::Arguments);
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::GrassPass1Shader::getInstance()->TU_tex, true)), ListMatGrass::Arguments);
|
||||
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS, 2, 1>(TexUnits(
|
||||
@ -416,8 +416,8 @@ void IrrDriver::renderTransparent()
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
glUseProgram(MeshShader::DisplaceMaskShaderInstance->Program);
|
||||
MeshShader::DisplaceMaskShaderInstance->setUniforms(AbsoluteTransformation);
|
||||
glUseProgram(MeshShader::DisplaceMaskShader::getInstance()->Program);
|
||||
MeshShader::DisplaceMaskShader::getInstance()->setUniforms(AbsoluteTransformation);
|
||||
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
|
||||
}
|
||||
|
||||
@ -435,12 +435,12 @@ void IrrDriver::renderTransparent()
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
// Render the effect
|
||||
setTexture(MeshShader::DisplaceShaderInstance->TU_displacement_tex, getTextureGLuint(displaceTex), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(MeshShader::DisplaceShaderInstance->TU_mask_tex, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(MeshShader::DisplaceShaderInstance->TU_color_tex, irr_driver->getRenderTargetTexture(RTT_COLOR), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(MeshShader::DisplaceShaderInstance->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR, true);
|
||||
glUseProgram(MeshShader::DisplaceShaderInstance->Program);
|
||||
MeshShader::DisplaceShaderInstance->setUniforms(AbsoluteTransformation,
|
||||
setTexture(MeshShader::DisplaceShader::getInstance()->TU_displacement_tex, getTextureGLuint(displaceTex), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(MeshShader::DisplaceShader::getInstance()->TU_mask_tex, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(MeshShader::DisplaceShader::getInstance()->TU_color_tex, irr_driver->getRenderTargetTexture(RTT_COLOR), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(MeshShader::DisplaceShader::getInstance()->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR, true);
|
||||
glUseProgram(MeshShader::DisplaceShader::getInstance()->Program);
|
||||
MeshShader::DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation,
|
||||
core::vector2df(cb->getDirX(), cb->getDirY()),
|
||||
core::vector2df(cb->getDir2X(), cb->getDir2Y()));
|
||||
|
||||
@ -490,9 +490,9 @@ struct shadow_custom_unroll_args<N, List...>
|
||||
};
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int...List, typename... Args>
|
||||
void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(Shader->Program);
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
@ -503,14 +503,41 @@ void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t[i]);
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(T::getInstance(), t[i]);
|
||||
}
|
||||
}
|
||||
|
||||
template<enum E_VERTEX_TYPE VertexType, typename... Args>
|
||||
|
||||
template<int...List>
|
||||
struct rsm_custom_unroll_args;
|
||||
|
||||
template<>
|
||||
struct rsm_custom_unroll_args<>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const core::matrix4 &rsm_matrix, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(T::getInstance(), STK::tuple_get<0>(t), rsm_matrix, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N, int...List>
|
||||
struct rsm_custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const core::matrix4 &rsm_matrix, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
rsm_custom_unroll_args<List...>::template exec<T>(rsm_matrix, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int... Selector, typename... Args>
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(MeshShader::RSMShader::Program);
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
@ -522,7 +549,7 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> Texture
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
draw<MeshShader::RSMShader>(mesh, rsm_matrix, STK::tuple_get<1>(t[i]));
|
||||
rsm_custom_unroll_args<Selector...>::template exec<T>(rsm_matrix, t[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,14 +578,14 @@ void IrrDriver::renderShadows()
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
std::vector<GLuint> noTexUnits;
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatDefault::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatSphereMap::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatUnlit::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatDetails::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatSplatting::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatNormalMap::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(MeshShader::RefShadowShaderInstance, std::vector<GLuint>{ MeshShader::RefShadowShaderInstance->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(MeshShader::GrassShadowShaderInstance, std::vector<GLuint>{ MeshShader::GrassShadowShaderInstance->TU_tex }, ListMatGrass::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(noTexUnits, ListMatDefault::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(noTexUnits, ListMatSphereMap::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(noTexUnits, ListMatDetails::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(noTexUnits, ListMatSplatting::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(noTexUnits, ListMatNormalMap::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatUnlit::Arguments);
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(std::vector<GLuint>{ MeshShader::GrassShadowShader::getInstance()->TU_tex }, ListMatGrass::Arguments);
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
@ -568,9 +595,18 @@ void IrrDriver::renderShadows()
|
||||
m_rtts->getRSM().Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSplatting::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
// drawRSM<EVT_STANDARD, 2, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_2TCOORDS, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<MeshShader::SplattingRSMShader, EVT_2TCOORDS, 1>(rsm_matrix,
|
||||
std::vector<GLuint>{
|
||||
8,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_layout,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail0,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail1,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail2,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail3},
|
||||
ListMatSplatting::Arguments);
|
||||
}
|
||||
|
@ -161,18 +161,17 @@ void IrrDriver::renderLights(unsigned pointlightcount)
|
||||
m_post_processing->renderGI(rh_matrix, rh_extend, m_rtts->getRH().getRTT()[0], m_rtts->getRH().getRTT()[1], m_rtts->getRH().getRTT()[2]);
|
||||
}
|
||||
|
||||
if (SkyboxCubeMap)
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
|
||||
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
}
|
||||
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
|
||||
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
|
||||
m_rtts->getFBO(FBO_COMBINED_TMP1_TMP2).Bind();
|
||||
|
||||
// Render sunlight if and only if track supports shadow
|
||||
if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows())
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_SUN));
|
||||
if (World::getWorld() && UserConfigParams::m_shadows)
|
||||
if (World::getWorld() && UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround())
|
||||
m_post_processing->renderShadowedSunlight(sun_ortho_matrix, m_rtts->getShadowDepthTex());
|
||||
else
|
||||
m_post_processing->renderSunlight();
|
||||
|
@ -370,6 +370,11 @@ static void testSH(unsigned char *color[6], size_t width, size_t height,
|
||||
delete[] Y1minus1[face];
|
||||
delete[] Y10[face];
|
||||
delete[] Y11[face];
|
||||
delete[] Y2minus2[face];
|
||||
delete[] Y2minus1[face];
|
||||
delete[] Y20[face];
|
||||
delete[] Y21[face];
|
||||
delete[] Y22[face];
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,6 +438,13 @@ void IrrDriver::generateSkyboxCubemap()
|
||||
|
||||
assert(SkyboxTextures.size() == 6);
|
||||
SkyboxCubeMap = generateCubeMapFromTextures(SkyboxTextures);
|
||||
}
|
||||
|
||||
void IrrDriver::generateDiffuseCoefficients()
|
||||
{
|
||||
if (!m_SH_dirty)
|
||||
return;
|
||||
m_SH_dirty = false;
|
||||
const unsigned texture_permutation[] = { 2, 3, 0, 1, 5, 4 };
|
||||
|
||||
if (SphericalHarmonicsTextures.size() == 6)
|
||||
@ -460,7 +472,7 @@ void IrrDriver::generateSkyboxCubemap()
|
||||
SphericalHarmonicsTextures[idx]->unlock();
|
||||
|
||||
image->copyToScaling(sh_rgba[i], sh_w, sh_h);
|
||||
image->drop();
|
||||
delete image;
|
||||
}
|
||||
|
||||
testSH(sh_rgba, sh_w, sh_h, blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
@ -492,6 +504,14 @@ void IrrDriver::generateSkyboxCubemap()
|
||||
|
||||
testSH(sh_rgba, sh_w, sh_h, blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
|
||||
// Diffuse env map is x 0.25, compensate
|
||||
for (unsigned i = 0; i < 9; i++)
|
||||
{
|
||||
blueSHCoeff[i] *= 4;
|
||||
greenSHCoeff[i] *= 4;
|
||||
redSHCoeff[i] *= 4;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 6; i++)
|
||||
delete[] sh_rgba[i];
|
||||
}
|
||||
@ -503,6 +523,7 @@ void IrrDriver::generateSkyboxCubemap()
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);*/
|
||||
|
||||
}
|
||||
|
||||
void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
|
||||
|
@ -226,7 +226,7 @@ RTT::RTT(size_t width, size_t height)
|
||||
somevector.push_back(RenderTargetTextures[RTT_TMP_128]);
|
||||
FrameBuffers.push_back(new FrameBuffer(somevector, 128, 128));
|
||||
|
||||
if (UserConfigParams::m_shadows)
|
||||
if (UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround())
|
||||
{
|
||||
shadowColorTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_R8, GL_RED, GL_UNSIGNED_BYTE);
|
||||
shadowDepthTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||
@ -265,7 +265,7 @@ RTT::~RTT()
|
||||
{
|
||||
glDeleteTextures(RTT_COUNT, RenderTargetTextures);
|
||||
glDeleteTextures(1, &DepthStencilTexture);
|
||||
if (UserConfigParams::m_shadows)
|
||||
if (UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround())
|
||||
{
|
||||
delete m_shadow_FBO;
|
||||
glDeleteTextures(1, &shadowColorTex);
|
||||
@ -291,6 +291,8 @@ FrameBuffer* RTT::render(scene::ICameraSceneNode* camera, float dt)
|
||||
irr_driver->getSceneManager()->setActiveCamera(camera);
|
||||
|
||||
std::vector<IrrDriver::GlowData> glows;
|
||||
// TODO: put this outside of the rendering loop
|
||||
irr_driver->generateDiffuseCoefficients();
|
||||
irr_driver->computeCameraMatrix(camera, m_width, m_height);
|
||||
unsigned plc = irr_driver->UpdateLightsInfo(camera, dt);
|
||||
irr_driver->renderScene(camera, plc, glows, dt, false, true);
|
||||
|
@ -390,33 +390,18 @@ void Shaders::loadShaders()
|
||||
FullScreenShader::LayerPassThroughShader::init();
|
||||
FullScreenShader::LinearizeDepthShader::init();
|
||||
FullScreenShader::SSAOShader::init();
|
||||
FullScreenShader::SunLightShader::init();
|
||||
FullScreenShader::DiffuseEnvMapShader::init();
|
||||
FullScreenShader::ShadowedSunLightShader::init();
|
||||
FullScreenShader::ShadowedSunLightDebugShader::init();
|
||||
FullScreenShader::RadianceHintsConstructionShader::init();
|
||||
FullScreenShader::RHDebug::init();
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::init();
|
||||
FullScreenShader::MotionBlurShader::init();
|
||||
FullScreenShader::GodFadeShader::init();
|
||||
FullScreenShader::GodRayShader::init();
|
||||
FullScreenShader::ToneMapShader::init();
|
||||
FullScreenShader::MLAAColorEdgeDetectionSHader::init();
|
||||
FullScreenShader::MLAABlendWeightSHader::init();
|
||||
FullScreenShader::MLAAGatherSHader::init();
|
||||
MeshShader::ColorizeShader::init();
|
||||
MeshShader::BubbleShader::init();
|
||||
MeshShader::BillboardShader::init();
|
||||
LightShader::PointLightShader::init();
|
||||
MeshShader::DisplaceShaderInstance = new MeshShader::DisplaceShader();
|
||||
MeshShader::DisplaceMaskShaderInstance = new MeshShader::DisplaceMaskShader();
|
||||
MeshShader::ShadowShaderInstance = new MeshShader::ShadowShader();
|
||||
MeshShader::RSMShader::init();
|
||||
MeshShader::InstancedShadowShaderInstance = new MeshShader::InstancedShadowShader();
|
||||
MeshShader::RefShadowShaderInstance = new MeshShader::RefShadowShader();
|
||||
MeshShader::InstancedRefShadowShaderInstance = new MeshShader::InstancedRefShadowShader();
|
||||
MeshShader::GrassShadowShaderInstance = new MeshShader::GrassShadowShader();
|
||||
MeshShader::InstancedGrassShadowShaderInstance = new MeshShader::InstancedGrassShadowShader();
|
||||
MeshShader::SkyboxShader::init();
|
||||
MeshShader::ViewFrustrumShader::init();
|
||||
ParticleShader::FlipParticleRender::init();
|
||||
@ -466,6 +451,8 @@ void bypassUBO(GLuint Program)
|
||||
glUniformMatrix4fv(IVM, 1, GL_FALSE, irr_driver->getInvViewMatrix().pointer());
|
||||
GLint IPM = glGetUniformLocation(Program, "InverseProjectionMatrix");
|
||||
glUniformMatrix4fv(IPM, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||
GLint Screen = glGetUniformLocation(Program, "screen");
|
||||
glUniform2f(Screen, irr_driver->getCurrentScreenSize().X, irr_driver->getCurrentScreenSize().Y);
|
||||
}
|
||||
|
||||
namespace UtilShader
|
||||
@ -489,16 +476,15 @@ namespace UtilShader
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
|
||||
uniform_color = glGetUniformLocation(Program, "color");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
}
|
||||
|
||||
void ColoredLine::setUniforms(const irr::video::SColor &col)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniform4i(uniform_color, col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
glUniformMatrix4fv(glGetUniformLocation(Program, "ModelMatrix"), 1, GL_FALSE, core::IdentityMatrix.pointer());
|
||||
@ -597,6 +583,11 @@ void glUniform1fWrapper(GLuint a, float b)
|
||||
glUniform1f(a, b);
|
||||
}
|
||||
|
||||
bool needsUBO()
|
||||
{
|
||||
return irr_driver->needUBOWorkaround();
|
||||
}
|
||||
|
||||
namespace MeshShader
|
||||
{
|
||||
// Solid Normal and depth pass shaders
|
||||
@ -607,11 +598,10 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
@ -623,11 +613,10 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
@ -650,11 +639,10 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_normalmap = 1;
|
||||
TU_glossy = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_normalmap, "normalMap"), TexUnit(TU_glossy, "DiffuseForAlpha"));
|
||||
@ -669,11 +657,9 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedObjectRefPass1Shader::InstancedObjectRefPass1Shader()
|
||||
@ -685,11 +671,9 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedGrassPass1Shader::InstancedGrassPass1Shader()
|
||||
@ -702,11 +686,9 @@ namespace MeshShader
|
||||
AssignUniforms("windDir");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
// Solid Lit pass shaders
|
||||
@ -716,12 +698,11 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix");
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program,
|
||||
@ -739,7 +720,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
AssignUniforms("ambient");
|
||||
AssignUniforms();
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program,
|
||||
@ -749,11 +730,9 @@ namespace MeshShader
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
}
|
||||
|
||||
InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader()
|
||||
@ -763,11 +742,11 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
AssignUniforms("ambient");
|
||||
AssignUniforms();
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
@ -783,7 +762,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "ambient");
|
||||
AssignUniforms("ModelMatrix");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_Albedo = 3;
|
||||
@ -804,11 +783,10 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
AssignUniforms("ModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_tex = 3;
|
||||
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
@ -820,12 +798,11 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix");
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program,
|
||||
@ -842,7 +819,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "windDir", "ambient");
|
||||
AssignUniforms("ModelMatrix", "windDir");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program,
|
||||
@ -860,7 +837,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
|
||||
AssignUniforms("windDir", "SunDir", "ambient");
|
||||
AssignUniforms("windDir", "SunDir");
|
||||
TU_Albedo = 3;
|
||||
TU_dtex = 4;
|
||||
|
||||
@ -883,12 +860,11 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_tex = 3;
|
||||
|
||||
AssignTextureUnit(Program,
|
||||
@ -904,7 +880,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "ambient");
|
||||
AssignUniforms("ModelMatrix");
|
||||
TU_tex_layout = 3;
|
||||
TU_tex_detail0 = 4;
|
||||
TU_tex_detail1 = 5;
|
||||
@ -953,11 +929,10 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
@ -969,76 +944,39 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GLuint BillboardShader::Program;
|
||||
GLuint BillboardShader::attrib_corner;
|
||||
GLuint BillboardShader::attrib_texcoord;
|
||||
GLuint BillboardShader::uniform_MV;
|
||||
GLuint BillboardShader::uniform_P;
|
||||
GLuint BillboardShader::uniform_tex;
|
||||
GLuint BillboardShader::uniform_Position;
|
||||
GLuint BillboardShader::uniform_Size;
|
||||
|
||||
void BillboardShader::init()
|
||||
BillboardShader::BillboardShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/billboard.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/billboard.frag").c_str());
|
||||
attrib_corner = glGetAttribLocation(Program, "Corner");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix");
|
||||
uniform_P = glGetUniformLocation(Program, "ProjectionMatrix");
|
||||
uniform_Position = glGetUniformLocation(Program, "Position");
|
||||
uniform_Size = glGetUniformLocation(Program, "Size");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
AssignUniforms("ModelViewMatrix", "ProjectionMatrix", "Position", "Size");
|
||||
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix,
|
||||
const core::matrix4 &ProjectionMatrix,
|
||||
const core::vector3df &Position,
|
||||
const core::dimension2d<float> &size,
|
||||
unsigned TU_tex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_P, 1, GL_FALSE, ProjectionMatrix.pointer());
|
||||
glUniform3f(uniform_Position, Position.X, Position.Y, Position.Z);
|
||||
glUniform2f(uniform_Size, size.Width, size.Height);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
GLuint ColorizeShader::Program;
|
||||
GLuint ColorizeShader::uniform_MM;
|
||||
GLuint ColorizeShader::uniform_col;
|
||||
|
||||
void ColorizeShader::init()
|
||||
ColorizeShader::ColorizeShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colorize.frag").c_str());
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
}
|
||||
AssignUniforms("ModelMatrix", "col");
|
||||
|
||||
void ColorizeShader::setUniforms(const core::matrix4 &ModelMatrix, float r, float g, float b)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform3f(uniform_col, r, g, b);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
ShadowShader::ShadowShader()
|
||||
@ -1064,29 +1002,34 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
ShadowShader *ShadowShaderInstance;
|
||||
|
||||
GLuint RSMShader::Program;
|
||||
GLuint RSMShader::uniform_MM;
|
||||
GLuint RSMShader::uniform_RSMMatrix;
|
||||
GLuint RSMShader::TU_tex;
|
||||
|
||||
void RSMShader::init()
|
||||
RSMShader::RSMShader()
|
||||
{
|
||||
if (irr_driver->getGLSLVersion() < 150)
|
||||
return;
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str());
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_RSMMatrix = glGetUniformLocation(Program, "RSMMatrix");
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
TU_tex = 0;
|
||||
AssignUniforms("RSMMatrix", "ModelMatrix", "TextureMatrix");
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void RSMShader::setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &ModelMatrix)
|
||||
SplattingRSMShader::SplattingRSMShader()
|
||||
{
|
||||
glUniformMatrix4fv(uniform_RSMMatrix, 1, GL_FALSE, RSMMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting_rsm.frag").c_str());
|
||||
TU_layout = 0;
|
||||
TU_detail0 = 1;
|
||||
TU_detail1 = 2;
|
||||
TU_detail2 = 3;
|
||||
TU_detail3 = 4;
|
||||
AssignUniforms("RSMMatrix", "ModelMatrix");
|
||||
AssignTextureUnit(Program, TexUnit(TU_layout, "tex_layout"), TexUnit(TU_detail0, "tex_detail0"), TexUnit(TU_detail1, "tex_detail1"), TexUnit(TU_detail2, "tex_detail2"), TexUnit(TU_detail3, "tex_detail3"));
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedShadowShader::InstancedShadowShader()
|
||||
@ -1113,8 +1056,6 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedShadowShader *InstancedShadowShaderInstance;
|
||||
|
||||
RefShadowShader::RefShadowShader()
|
||||
{
|
||||
// Geometry shader needed
|
||||
@ -1141,8 +1082,6 @@ namespace MeshShader
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
RefShadowShader *RefShadowShaderInstance;
|
||||
|
||||
InstancedRefShadowShader::InstancedRefShadowShader()
|
||||
{
|
||||
// Geometry shader needed
|
||||
@ -1169,8 +1108,6 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedRefShadowShader *InstancedRefShadowShaderInstance;
|
||||
|
||||
GrassShadowShader::GrassShadowShader()
|
||||
{
|
||||
// Geometry shader needed
|
||||
@ -1197,8 +1134,6 @@ namespace MeshShader
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
GrassShadowShader *GrassShadowShaderInstance;
|
||||
|
||||
InstancedGrassShadowShader::InstancedGrassShadowShader()
|
||||
{
|
||||
// Geometry shader needed
|
||||
@ -1227,22 +1162,16 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedGrassShadowShader *InstancedGrassShadowShaderInstance;
|
||||
|
||||
DisplaceMaskShader::DisplaceMaskShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
|
||||
AssignUniforms("ModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DisplaceMaskShader *DisplaceMaskShaderInstance;
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
|
||||
DisplaceShader::DisplaceShader()
|
||||
@ -1265,8 +1194,6 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
DisplaceShader *DisplaceShaderInstance;
|
||||
|
||||
GLuint SkyboxShader::Program;
|
||||
GLuint SkyboxShader::attrib_position;
|
||||
GLuint SkyboxShader::uniform_MM;
|
||||
@ -1281,11 +1208,9 @@ namespace MeshShader
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
glGenVertexArrays(1, &cubevao);
|
||||
glBindVertexArray(cubevao);
|
||||
@ -1298,7 +1223,7 @@ namespace MeshShader
|
||||
|
||||
void SkyboxShader::setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &screen, unsigned TU_tex)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
@ -1316,11 +1241,10 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/frustrum.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
uniform_color = glGetUniformLocation(Program, "color");
|
||||
uniform_idx = glGetUniformLocation(Program, "idx");
|
||||
|
||||
@ -1394,7 +1318,7 @@ namespace LightShader
|
||||
|
||||
void PointLightShader::setUniforms(const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniform1f(uniform_spec, 200);
|
||||
|
||||
@ -1666,35 +1590,19 @@ namespace FullScreenShader
|
||||
glUniform1i(uniform_tex_512, TU_tex_512);
|
||||
}
|
||||
|
||||
GLuint ToneMapShader::Program;
|
||||
GLuint ToneMapShader::uniform_tex;
|
||||
GLuint ToneMapShader::uniform_logluminancetex;
|
||||
GLuint ToneMapShader::uniform_exposure;
|
||||
GLuint ToneMapShader::uniform_lwhite;
|
||||
GLuint ToneMapShader::vao;
|
||||
|
||||
void ToneMapShader::init()
|
||||
ToneMapShader::ToneMapShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getRGBfromCIEXxy.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getCIEXYZ.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/tonemap.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_logluminancetex = glGetUniformLocation(Program, "logluminancetex");
|
||||
uniform_exposure = glGetUniformLocation(Program, "exposure");
|
||||
uniform_lwhite = glGetUniformLocation(Program, "Lwhite");
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "text"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
void ToneMapShader::setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_loglum)
|
||||
{
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_logluminancetex, TU_loglum);
|
||||
glUniform1f(uniform_exposure, exposure);
|
||||
glUniform1f(uniform_lwhite, Lwhite);
|
||||
}
|
||||
|
||||
GLuint DepthOfFieldShader::Program;
|
||||
GLuint DepthOfFieldShader::uniform_tex;
|
||||
GLuint DepthOfFieldShader::uniform_depth;
|
||||
@ -1718,14 +1626,7 @@ namespace FullScreenShader
|
||||
glUniform1i(uniform_depth, TU_dtex);
|
||||
}
|
||||
|
||||
GLuint SunLightShader::Program;
|
||||
GLuint SunLightShader::uniform_ntex;
|
||||
GLuint SunLightShader::uniform_dtex;
|
||||
GLuint SunLightShader::uniform_direction;
|
||||
GLuint SunLightShader::uniform_col;
|
||||
GLuint SunLightShader::vao;
|
||||
|
||||
void SunLightShader::init()
|
||||
SunLightShader::SunLightShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
@ -1733,26 +1634,14 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getSpecular.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlight.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_direction = glGetUniformLocation(Program, "direction");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
TU_ntex = 0;
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void SunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z);
|
||||
glUniform3f(uniform_col, r, g, b);
|
||||
glUniform1i(uniform_ntex, TU_ntex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint DiffuseEnvMapShader::Program;
|
||||
@ -1786,15 +1675,7 @@ namespace FullScreenShader
|
||||
glUniform1fv(uniform_redLmn, 9, redSHCoeff);
|
||||
}
|
||||
|
||||
GLuint ShadowedSunLightShader::Program;
|
||||
GLuint ShadowedSunLightShader::uniform_ntex;
|
||||
GLuint ShadowedSunLightShader::uniform_dtex;
|
||||
GLuint ShadowedSunLightShader::uniform_shadowtex;
|
||||
GLuint ShadowedSunLightShader::uniform_direction;
|
||||
GLuint ShadowedSunLightShader::uniform_col;
|
||||
GLuint ShadowedSunLightShader::vao;
|
||||
|
||||
void ShadowedSunLightShader::init()
|
||||
ShadowedSunLightShader::ShadowedSunLightShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
@ -1802,67 +1683,15 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getSpecular.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlightshadow.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_shadowtex = glGetUniformLocation(Program, "shadowtex");
|
||||
uniform_direction = glGetUniformLocation(Program, "direction");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
TU_ntex = 0;
|
||||
TU_dtex = 1;
|
||||
TU_shadowtex = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"), TexUnit(TU_shadowtex, "shadowtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowedSunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z);
|
||||
glUniform3f(uniform_col, r, g, b);
|
||||
glUniform1i(uniform_ntex, TU_ntex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
glUniform1i(uniform_shadowtex, TU_shadowtex);
|
||||
}
|
||||
|
||||
GLuint ShadowedSunLightDebugShader::Program;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_ntex;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_dtex;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_shadowtex;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_direction;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_col;
|
||||
GLuint ShadowedSunLightDebugShader::vao;
|
||||
|
||||
void ShadowedSunLightDebugShader::init()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/decodeNormal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getSpecular.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlightshadowdebug.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_shadowtex = glGetUniformLocation(Program, "shadowtex");
|
||||
uniform_direction = glGetUniformLocation(Program, "direction");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
vao = createVAO(Program);
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowedSunLightDebugShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z);
|
||||
glUniform3f(uniform_col, r, g, b);
|
||||
glUniform1i(uniform_ntex, TU_ntex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
glUniform1i(uniform_shadowtex, TU_shadowtex);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint RadianceHintsConstructionShader::Program;
|
||||
@ -2187,11 +2016,9 @@ namespace FullScreenShader
|
||||
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
|
||||
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
|
||||
vao = createFullScreenVAO(Program);
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
// SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative
|
||||
|
||||
@ -2309,7 +2136,7 @@ namespace FullScreenShader
|
||||
|
||||
void SSAOShader::setUniforms(const core::vector2df &screen, unsigned TU_dtex, unsigned TU_noise)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniform4fv(uniform_samplePoints, 16, SSAOSamples);
|
||||
|
||||
@ -2341,16 +2168,14 @@ namespace FullScreenShader
|
||||
uniform_end = glGetUniformLocation(Program, "end");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void FogShader::setUniforms(float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniform1f(uniform_fogmax, fogmax);
|
||||
glUniform1f(uniform_startH, startH);
|
||||
|
@ -53,6 +53,7 @@ void glUniformMatrix4fvWraper(GLuint, size_t, unsigned, const float *mat);
|
||||
void glUniform3fWraper(GLuint, float, float, float);
|
||||
void glUniform2fWraper(GLuint a, float b, float c);
|
||||
void glUniform1fWrapper(GLuint, float);
|
||||
bool needsUBO();
|
||||
|
||||
struct UniformHelper
|
||||
{
|
||||
@ -93,6 +94,13 @@ struct UniformHelper
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const core::dimension2df &v, Args... arg)
|
||||
{
|
||||
glUniform2fWraper(uniforms[N], v.Width, v.Height);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, float f, Args... arg)
|
||||
{
|
||||
@ -105,51 +113,28 @@ struct UniformHelper
|
||||
void bypassUBO(GLuint Program);
|
||||
GLuint getUniformLocation(GLuint program, const char* name);
|
||||
|
||||
template<typename... Args>
|
||||
class ShaderHelper
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> uniforms;
|
||||
|
||||
void AssignUniforms(const char* name)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
void AssignUniforms(const char* name, T... rest)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
AssignUniforms(rest...);
|
||||
}
|
||||
|
||||
public:
|
||||
GLuint Program;
|
||||
|
||||
void setUniforms(const Args & ... args) const
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
UniformHelper::setUniformsHelper(uniforms, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename... Args>
|
||||
class ShaderHelperSingleton : public Singleton<T>
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> uniforms;
|
||||
|
||||
void AssignUniforms(const char* name)
|
||||
void AssignUniforms_impl()
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
}
|
||||
|
||||
template<typename... U>
|
||||
void AssignUniforms(const char* name, U... rest)
|
||||
void AssignUniforms_impl(const char* name, U... rest)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
AssignUniforms(rest...);
|
||||
AssignUniforms_impl(rest...);
|
||||
}
|
||||
|
||||
template<typename... U>
|
||||
void AssignUniforms(U... rest)
|
||||
{
|
||||
static_assert(sizeof...(rest) == sizeof...(Args), "Count of Uniform's name mismatch");
|
||||
AssignUniforms_impl(rest...);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -158,7 +143,7 @@ public:
|
||||
|
||||
void setUniforms(const Args & ... args) const
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
if (needsUBO())
|
||||
bypassUBO(Program);
|
||||
UniformHelper::setUniformsHelper(uniforms, args...);
|
||||
}
|
||||
@ -325,102 +310,84 @@ public:
|
||||
TransparentFogShader();
|
||||
};
|
||||
|
||||
class BillboardShader
|
||||
class BillboardShader : public ShaderHelperSingleton<BillboardShader, core::matrix4, core::matrix4, core::vector3df, core::dimension2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_corner, attrib_texcoord;
|
||||
static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex);
|
||||
BillboardShader();
|
||||
};
|
||||
|
||||
|
||||
class ColorizeShader
|
||||
class ColorizeShader : public ShaderHelperSingleton<ColorizeShader, core::matrix4, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_MM, uniform_col;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, float r, float g, float b);
|
||||
ColorizeShader();
|
||||
};
|
||||
|
||||
class ShadowShader : public ShaderHelper<core::matrix4>
|
||||
class ShadowShader : public ShaderHelperSingleton<ShadowShader, core::matrix4>
|
||||
{
|
||||
public:
|
||||
ShadowShader();
|
||||
};
|
||||
|
||||
extern ShadowShader *ShadowShaderInstance;
|
||||
|
||||
class RSMShader
|
||||
class RSMShader : public ShaderHelperSingleton<RSMShader, core::matrix4, core::matrix4, core::matrix4>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_MM, uniform_RSMMatrix;
|
||||
static GLuint TU_tex;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &ModelMatrix);
|
||||
RSMShader();
|
||||
};
|
||||
|
||||
class InstancedShadowShader : public ShaderHelper<>
|
||||
class SplattingRSMShader : public ShaderHelperSingleton<SplattingRSMShader, core::matrix4, core::matrix4>
|
||||
{
|
||||
public:
|
||||
GLuint TU_layout, TU_detail0, TU_detail1, TU_detail2, TU_detail3;
|
||||
|
||||
SplattingRSMShader();
|
||||
};
|
||||
|
||||
class InstancedShadowShader : public ShaderHelperSingleton<InstancedShadowShader>
|
||||
{
|
||||
public:
|
||||
InstancedShadowShader();
|
||||
};
|
||||
|
||||
extern InstancedShadowShader *InstancedShadowShaderInstance;
|
||||
|
||||
class RefShadowShader : public ShaderHelper<core::matrix4>
|
||||
class RefShadowShader : public ShaderHelperSingleton<RefShadowShader, core::matrix4>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
|
||||
RefShadowShader();
|
||||
};
|
||||
|
||||
extern RefShadowShader *RefShadowShaderInstance;
|
||||
|
||||
class InstancedRefShadowShader : public ShaderHelper<>
|
||||
class InstancedRefShadowShader : public ShaderHelperSingleton<InstancedRefShadowShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
|
||||
InstancedRefShadowShader();
|
||||
};
|
||||
|
||||
extern InstancedRefShadowShader *InstancedRefShadowShaderInstance;
|
||||
|
||||
class GrassShadowShader : public ShaderHelper<core::matrix4, core::vector3df>
|
||||
class GrassShadowShader : public ShaderHelperSingleton<GrassShadowShader, core::matrix4, core::vector3df>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GrassShadowShader();
|
||||
};
|
||||
|
||||
extern GrassShadowShader *GrassShadowShaderInstance;
|
||||
|
||||
class InstancedGrassShadowShader : public ShaderHelper<core::vector3df>
|
||||
class InstancedGrassShadowShader : public ShaderHelperSingleton<InstancedGrassShadowShader, core::vector3df>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
InstancedGrassShadowShader();
|
||||
};
|
||||
|
||||
extern InstancedGrassShadowShader *InstancedGrassShadowShaderInstance;
|
||||
|
||||
class DisplaceMaskShader : public ShaderHelper<core::matrix4>
|
||||
class DisplaceMaskShader : public ShaderHelperSingleton<DisplaceMaskShader, core::matrix4>
|
||||
{
|
||||
public:
|
||||
DisplaceMaskShader();
|
||||
};
|
||||
|
||||
extern DisplaceMaskShader *DisplaceMaskShaderInstance;
|
||||
|
||||
class DisplaceShader : public ShaderHelper<core::matrix4, core::vector2df, core::vector2df>
|
||||
class DisplaceShader : public ShaderHelperSingleton<DisplaceShader, core::matrix4, core::vector2df, core::vector2df>
|
||||
{
|
||||
public:
|
||||
GLuint TU_displacement_tex, TU_mask_tex, TU_color_tex, TU_tex;
|
||||
@ -428,8 +395,6 @@ public:
|
||||
DisplaceShader();
|
||||
};
|
||||
|
||||
extern DisplaceShader *DisplaceShaderInstance;
|
||||
|
||||
class SkyboxShader
|
||||
{
|
||||
public:
|
||||
@ -563,15 +528,13 @@ public:
|
||||
static void setUniforms(unsigned TU_tex_128, unsigned TU_tex_256, unsigned TU_tex_512);
|
||||
};
|
||||
|
||||
class ToneMapShader
|
||||
class ToneMapShader : public ShaderHelperSingleton<ToneMapShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_logluminancetex, uniform_exposure, uniform_lwhite;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_logluminance);
|
||||
ToneMapShader();
|
||||
};
|
||||
|
||||
class DepthOfFieldShader
|
||||
@ -585,15 +548,13 @@ public:
|
||||
static void setUniforms(unsigned TU_tex, unsigned TU_depth);
|
||||
};
|
||||
|
||||
class SunLightShader
|
||||
class SunLightShader : public ShaderHelperSingleton<SunLightShader, core::vector3df, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col;
|
||||
static GLuint vao;
|
||||
GLuint TU_ntex, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
|
||||
SunLightShader();
|
||||
};
|
||||
|
||||
class DiffuseEnvMapShader
|
||||
@ -607,26 +568,13 @@ public:
|
||||
static void setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex);
|
||||
};
|
||||
|
||||
class ShadowedSunLightShader
|
||||
class ShadowedSunLightShader : public ShaderHelperSingleton<ShadowedSunLightShader, core::vector3df, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex, uniform_direction, uniform_col;
|
||||
static GLuint vao;
|
||||
GLuint TU_ntex, TU_dtex, TU_shadowtex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex);
|
||||
};
|
||||
|
||||
class ShadowedSunLightDebugShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex, uniform_direction, uniform_col;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex);
|
||||
ShadowedSunLightShader();
|
||||
};
|
||||
|
||||
class RadianceHintsConstructionShader
|
||||
|
178
src/graphics/stk_text_billboard.cpp
Normal file
178
src/graphics/stk_text_billboard.cpp
Normal file
@ -0,0 +1,178 @@
|
||||
#include "graphics/stk_text_billboard.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/stkbillboard.hpp"
|
||||
#include "graphics/stkmeshscenenode.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
|
||||
#include <SMesh.h>
|
||||
#include <SMeshBuffer.h>
|
||||
#include <ISceneManager.h>
|
||||
#include <ICameraSceneNode.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
STKTextBillboard::STKTextBillboard(core::stringw text, gui::ScalableFont* font,
|
||||
const video::SColor& color_top, const video::SColor& color_bottom,
|
||||
irr::scene::ISceneNode* parent,
|
||||
irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position, const irr::core::vector3df& size) :
|
||||
STKMeshSceneNode(new scene::SMesh(),
|
||||
parent, irr_driver->getSceneManager(), -1,
|
||||
position, core::vector3df(0.0f, 0.0f, 0.0f), size, false)
|
||||
{
|
||||
m_color_top = color_top;
|
||||
m_color_bottom = color_bottom;
|
||||
getTextMesh(text, font);
|
||||
createGLMeshes();
|
||||
Mesh->drop();
|
||||
//setAutomaticCulling(0);
|
||||
updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void STKTextBillboard::updateAbsolutePosition()
|
||||
{
|
||||
if (Parent)
|
||||
{
|
||||
// Override to not use the parent's rotation
|
||||
AbsoluteTransformation = getRelativeTransformation();
|
||||
AbsoluteTransformation.setTranslation(AbsoluteTransformation.getTranslation() + Parent->getAbsolutePosition());
|
||||
}
|
||||
else
|
||||
AbsoluteTransformation = getRelativeTransformation();
|
||||
}
|
||||
|
||||
scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, gui::ScalableFont* font)
|
||||
{
|
||||
font->doDraw(text, core::rect<s32>(0, 0, 1000, 1000), video::SColor(255,255,255,255),
|
||||
false, false, NULL, this);
|
||||
|
||||
const float scale = 0.018f;
|
||||
|
||||
//scene::SMesh* mesh = new scene::SMesh();
|
||||
std::map<video::ITexture*, scene::SMeshBuffer*> buffers;
|
||||
|
||||
int max_x = 0;
|
||||
int min_y = 0;
|
||||
int max_y = 0;
|
||||
for (unsigned int i = 0; i < m_chars.size(); i++)
|
||||
{
|
||||
int char_x = m_chars[i].m_destRect.LowerRightCorner.X;
|
||||
if (char_x > max_x)
|
||||
max_x = char_x;
|
||||
|
||||
int char_min_y = m_chars[i].m_destRect.UpperLeftCorner.Y;
|
||||
int char_max_y = m_chars[i].m_destRect.LowerRightCorner.Y;
|
||||
if (char_min_y < min_y)
|
||||
min_y = char_min_y;
|
||||
if (char_max_y > min_y)
|
||||
max_y = char_max_y;
|
||||
}
|
||||
float scaled_center_x = (max_x / 2.0f) * scale;
|
||||
float scaled_y = (max_y / 2.0f) * scale; // -max_y * scale;
|
||||
|
||||
for (unsigned int i = 0; i < m_chars.size(); i++)
|
||||
{
|
||||
core::vector3df char_pos(m_chars[i].m_destRect.UpperLeftCorner.X,
|
||||
m_chars[i].m_destRect.UpperLeftCorner.Y, 0);
|
||||
char_pos *= scale;
|
||||
|
||||
core::vector3df char_pos2(m_chars[i].m_destRect.LowerRightCorner.X,
|
||||
m_chars[i].m_destRect.LowerRightCorner.Y, 0);
|
||||
char_pos2 *= scale;
|
||||
|
||||
core::dimension2di char_size_i = m_chars[i].m_destRect.getSize();
|
||||
core::dimension2df char_size(char_size_i.Width*scale, char_size_i.Height*scale);
|
||||
|
||||
std::map<video::ITexture*, scene::SMeshBuffer*>::iterator map_itr = buffers.find(m_chars[i].m_texture);
|
||||
scene::SMeshBuffer* buffer;
|
||||
if (map_itr == buffers.end())
|
||||
{
|
||||
buffer = new scene::SMeshBuffer();
|
||||
buffer->getMaterial().setTexture(0, m_chars[i].m_texture);
|
||||
buffer->getMaterial().MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
|
||||
buffers[m_chars[i].m_texture] = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = map_itr->second;
|
||||
}
|
||||
|
||||
float tex_width = m_chars[i].m_texture->getSize().Width;
|
||||
float tex_height = m_chars[i].m_texture->getSize().Height;
|
||||
|
||||
|
||||
video::S3DVertex vertices[] =
|
||||
{
|
||||
video::S3DVertex(char_pos.X - scaled_center_x, char_pos.Y - scaled_y, 0.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
m_color_bottom,
|
||||
m_chars[i].m_sourceRect.UpperLeftCorner.X / tex_width,
|
||||
m_chars[i].m_sourceRect.LowerRightCorner.Y / tex_height),
|
||||
|
||||
video::S3DVertex(char_pos2.X - scaled_center_x, char_pos.Y - scaled_y, 0.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
m_color_bottom,
|
||||
m_chars[i].m_sourceRect.LowerRightCorner.X / tex_width,
|
||||
m_chars[i].m_sourceRect.LowerRightCorner.Y / tex_height),
|
||||
|
||||
video::S3DVertex(char_pos2.X - scaled_center_x, char_pos2.Y - scaled_y, 0.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
m_color_top,
|
||||
m_chars[i].m_sourceRect.LowerRightCorner.X / tex_width,
|
||||
m_chars[i].m_sourceRect.UpperLeftCorner.Y / tex_height),
|
||||
|
||||
video::S3DVertex(char_pos.X - scaled_center_x, char_pos2.Y - scaled_y, 0.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
m_color_top,
|
||||
m_chars[i].m_sourceRect.UpperLeftCorner.X / tex_width,
|
||||
m_chars[i].m_sourceRect.UpperLeftCorner.Y / tex_height)
|
||||
};
|
||||
|
||||
irr::u16 indices[] = { 2, 1, 0, 3, 2, 0 };
|
||||
|
||||
buffer->append(vertices, 4, indices, 6);
|
||||
}
|
||||
|
||||
for (std::map<video::ITexture*, scene::SMeshBuffer*>::iterator map_itr = buffers.begin();
|
||||
map_itr != buffers.end(); map_itr++)
|
||||
{
|
||||
((scene::SMesh*)Mesh)->addMeshBuffer(map_itr->second);
|
||||
|
||||
map_itr->second->recalculateBoundingBox();
|
||||
Mesh->setBoundingBox(map_itr->second->getBoundingBox()); // TODO: wrong if several buffers
|
||||
|
||||
map_itr->second->drop();
|
||||
}
|
||||
|
||||
getMaterial(0).MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
|
||||
|
||||
return Mesh;
|
||||
}
|
||||
|
||||
void STKTextBillboard::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID);
|
||||
|
||||
scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()->getActiveCamera();
|
||||
core::vector3df cam_pos = curr_cam->getPosition();
|
||||
core::vector3df text_pos = this->getAbsolutePosition();
|
||||
float angle = atan2(text_pos.X - cam_pos.X, text_pos.Z - cam_pos.Z);
|
||||
this->setRotation(core::vector3df(0.0f, angle * 180.0f / M_PI, 0.0f));
|
||||
updateAbsolutePosition();
|
||||
}
|
||||
|
||||
ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
|
||||
void STKTextBillboard::collectChar(video::ITexture* texture,
|
||||
const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect,
|
||||
const video::SColor* const colors)
|
||||
{
|
||||
m_chars.push_back(STKTextBillboardChar(texture, destRect, sourceRect, colors));
|
||||
}
|
69
src/graphics/stk_text_billboard.hpp
Normal file
69
src/graphics/stk_text_billboard.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef STK_TEXT_BILLBOARD_HPP
|
||||
#define STK_TEXT_BILLBOARD_HPP
|
||||
|
||||
#include "../lib/irrlicht/source/Irrlicht/CBillboardSceneNode.h"
|
||||
#include <IBillboardSceneNode.h>
|
||||
#include <irrTypes.h>
|
||||
#include <IMesh.h>
|
||||
#include "graphics/stkmeshscenenode.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
|
||||
class STKTextBillboardChar
|
||||
{
|
||||
public:
|
||||
irr::video::ITexture* m_texture;
|
||||
irr::core::rect<irr::s32> m_destRect;
|
||||
irr::core::rect<irr::s32> m_sourceRect;
|
||||
//irr::video::SColor m_colors[4];
|
||||
|
||||
STKTextBillboardChar(irr::video::ITexture* texture,
|
||||
const irr::core::rect<irr::s32>& destRect,
|
||||
const irr::core::rect<irr::s32>& sourceRect,
|
||||
const irr::video::SColor* const colors)
|
||||
{
|
||||
m_texture = texture;
|
||||
m_destRect = destRect;
|
||||
m_sourceRect = sourceRect;
|
||||
//if (colors == NULL)
|
||||
//{
|
||||
// m_colors[0] = m_colors[1] = m_colors[2] = m_colors[3] = NULL;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// m_colors[0] = colors[0];
|
||||
// m_colors[1] = colors[1];
|
||||
// m_colors[2] = colors[2];
|
||||
// m_colors[3] = colors[3];
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
class STKTextBillboard : public STKMeshSceneNode, irr::gui::FontCharCollector
|
||||
{
|
||||
std::vector<STKTextBillboardChar> m_chars;
|
||||
irr::video::SColor m_color_top;
|
||||
irr::video::SColor m_color_bottom;
|
||||
|
||||
irr::scene::IMesh* getTextMesh(irr::core::stringw text, gui::ScalableFont* font);
|
||||
|
||||
public:
|
||||
STKTextBillboard(irr::core::stringw text, irr::gui::ScalableFont* font,
|
||||
const irr::video::SColor& color_top,
|
||||
const irr::video::SColor& color_bottom,
|
||||
irr::scene::ISceneNode* parent,
|
||||
irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position,
|
||||
const irr::core::vector3df& size);
|
||||
|
||||
virtual void OnRegisterSceneNode() OVERRIDE;
|
||||
|
||||
virtual void collectChar(irr::video::ITexture* texture,
|
||||
const irr::core::rect<irr::s32>& destRect,
|
||||
const irr::core::rect<irr::s32>& sourceRect,
|
||||
const irr::video::SColor* const colors);
|
||||
|
||||
virtual void updateAbsolutePosition() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
@ -151,7 +151,7 @@ void STKAnimatedMesh::render()
|
||||
pushVector(ListMatDetails::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterial[MAT_UNLIT])
|
||||
pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY);
|
||||
pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ static void createbillboardvao()
|
||||
glGenVertexArrays(1, &billboardvao);
|
||||
glBindVertexArray(billboardvao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
@ -50,8 +50,8 @@ void STKBillboard::render()
|
||||
compressTexture(tex, true, true);
|
||||
GLuint texid = getTextureGLuint(tex);
|
||||
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
|
||||
glUseProgram(MeshShader::BillboardShader::Program);
|
||||
MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0);
|
||||
glUseProgram(MeshShader::BillboardShader::getInstance()->Program);
|
||||
MeshShader::BillboardShader::getInstance()->setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
return;
|
||||
|
@ -156,7 +156,7 @@ static void drawShadowDefault(GLMesh &mesh, size_t instance_count)
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
MeshShader::InstancedShadowShaderInstance->setUniforms();
|
||||
MeshShader::InstancedShadowShader::getInstance()->setUniforms();
|
||||
|
||||
glBindVertexArray(mesh.vao_shadow_pass);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
@ -185,8 +185,8 @@ static void drawShadowAlphaRefTexture(GLMesh &mesh, size_t instance_count)
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
compressTexture(mesh.textures[0], true);
|
||||
setTexture(MeshShader::InstancedRefShadowShaderInstance->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
MeshShader::InstancedRefShadowShaderInstance->setUniforms();
|
||||
setTexture(MeshShader::InstancedRefShadowShader::getInstance()->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
MeshShader::InstancedRefShadowShader::getInstance()->setUniforms();
|
||||
|
||||
glBindVertexArray(mesh.vao_shadow_pass);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
@ -200,8 +200,8 @@ static void drawShadowGrass(GLMesh &mesh, const core::vector3df &windDir, size_t
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
compressTexture(mesh.textures[0], true);
|
||||
setTexture(MeshShader::InstancedGrassShadowShaderInstance->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
MeshShader::InstancedGrassShadowShaderInstance->setUniforms(windDir);
|
||||
setTexture(MeshShader::InstancedGrassShadowShader::getInstance()->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
MeshShader::InstancedGrassShadowShader::getInstance()->setUniforms(windDir);
|
||||
|
||||
glBindVertexArray(mesh.vao_shadow_pass);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
@ -356,17 +356,17 @@ void STKInstancedSceneNode::render()
|
||||
if (irr_driver->getPhase() == SHADOW_PASS)
|
||||
{
|
||||
if (!MeshSolidMaterial[MAT_DEFAULT].empty())
|
||||
glUseProgram(MeshShader::InstancedShadowShaderInstance->Program);
|
||||
glUseProgram(MeshShader::InstancedShadowShader::getInstance()->Program);
|
||||
for (unsigned i = 0; i < MeshSolidMaterial[MAT_DEFAULT].size(); i++)
|
||||
drawShadowDefault(*MeshSolidMaterial[MAT_DEFAULT][i], instance_pos.size() / 9);
|
||||
|
||||
if (!MeshSolidMaterial[MAT_ALPHA_REF].empty())
|
||||
glUseProgram(MeshShader::InstancedRefShadowShaderInstance->Program);
|
||||
glUseProgram(MeshShader::InstancedRefShadowShader::getInstance()->Program);
|
||||
for (unsigned i = 0; i < MeshSolidMaterial[MAT_ALPHA_REF].size(); i++)
|
||||
drawShadowAlphaRefTexture(*MeshSolidMaterial[MAT_ALPHA_REF][i], instance_pos.size() / 9);
|
||||
|
||||
if (!MeshSolidMaterial[MAT_GRASS].empty())
|
||||
glUseProgram(MeshShader::InstancedGrassShadowShaderInstance->Program);
|
||||
glUseProgram(MeshShader::InstancedGrassShadowShader::getInstance()->Program);
|
||||
for (unsigned i = 0; i < MeshSolidMaterial[MAT_GRASS].size(); i++)
|
||||
drawShadowGrass(*MeshSolidMaterial[MAT_GRASS][i], windDir, instance_pos.size() / 9);
|
||||
return;
|
||||
|
@ -298,7 +298,7 @@ std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> >
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatSphereMap::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatDetails::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df> > ListMatGrass::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatSplatting::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatNormalMap::Arguments;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
class ListMatUnlit
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatDetails
|
||||
|
@ -15,13 +15,15 @@
|
||||
STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position,
|
||||
const irr::core::vector3df& rotation,
|
||||
const irr::core::vector3df& scale) :
|
||||
const irr::core::vector3df& scale, bool createGLMeshes) :
|
||||
CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
|
||||
{
|
||||
isDisplacement = false;
|
||||
immediate_draw = false;
|
||||
update_each_frame = false;
|
||||
createGLMeshes();
|
||||
|
||||
if (createGLMeshes)
|
||||
this->createGLMeshes();
|
||||
}
|
||||
|
||||
void STKMeshSceneNode::setReloadEachFrame(bool val)
|
||||
@ -140,7 +142,7 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
MeshShader::ColorizeShader::setUniforms(AbsoluteTransformation, cb->getRed(), cb->getGreen(), cb->getBlue());
|
||||
MeshShader::ColorizeShader::getInstance()->setUniforms(AbsoluteTransformation, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
|
||||
}
|
||||
|
||||
@ -263,7 +265,7 @@ void STKMeshSceneNode::render()
|
||||
pushVector(ListMatGrass::Arguments, mesh, AbsoluteTransformation, invmodel, windDir);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_UNLIT])
|
||||
pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY);
|
||||
pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_SPLATTING])
|
||||
pushVector(ListMatSplatting::Arguments, mesh, AbsoluteTransformation, invmodel);
|
||||
@ -310,7 +312,7 @@ void STKMeshSceneNode::render()
|
||||
|
||||
if (irr_driver->getPhase() == GLOW_PASS)
|
||||
{
|
||||
glUseProgram(MeshShader::ColorizeShader::Program);
|
||||
glUseProgram(MeshShader::ColorizeShader::getInstance()->Program);
|
||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||
|
@ -29,7 +29,8 @@ public:
|
||||
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
|
||||
const irr::core::vector3df& rotation = irr::core::vector3df(0, 0, 0),
|
||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f),
|
||||
bool createGLMeshes = true);
|
||||
virtual void render();
|
||||
virtual void setMesh(irr::scene::IMesh* mesh);
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
@ -463,6 +463,14 @@ core::dimension2d<u32> ScalableFont::getDimension(const wchar_t* text) const
|
||||
return dim;
|
||||
}
|
||||
|
||||
void ScalableFont::draw(const core::stringw& text,
|
||||
const core::rect<s32>& position, video::SColor color,
|
||||
bool hcenter, bool vcenter,
|
||||
const core::rect<s32>* clip)
|
||||
{
|
||||
doDraw(text, position, color, hcenter, vcenter, clip, NULL);
|
||||
}
|
||||
|
||||
void ScalableFont::draw(const core::stringw& text,
|
||||
const core::rect<s32>& position, video::SColor color,
|
||||
bool hcenter, bool vcenter,
|
||||
@ -471,16 +479,17 @@ void ScalableFont::draw(const core::stringw& text,
|
||||
bool previousRTL = m_rtl;
|
||||
if (ignoreRTL) m_rtl = false;
|
||||
|
||||
draw(text, position, color, hcenter, vcenter, clip);
|
||||
doDraw(text, position, color, hcenter, vcenter, clip, NULL);
|
||||
|
||||
if (ignoreRTL) m_rtl = previousRTL;
|
||||
}
|
||||
|
||||
//! draws some text and clips it to the specified rectangle if wanted
|
||||
void ScalableFont::draw(const core::stringw& text,
|
||||
const core::rect<s32>& position, video::SColor color,
|
||||
bool hcenter, bool vcenter,
|
||||
const core::rect<s32>* clip)
|
||||
void ScalableFont::doDraw(const core::stringw& text,
|
||||
const core::rect<s32>& position, video::SColor color,
|
||||
bool hcenter, bool vcenter,
|
||||
const core::rect<s32>* clip,
|
||||
FontCharCollector* charCollector)
|
||||
{
|
||||
if (!Driver) return;
|
||||
|
||||
@ -637,7 +646,7 @@ void ScalableFont::draw(const core::stringw& text,
|
||||
}
|
||||
}
|
||||
|
||||
if (m_black_border)
|
||||
if (m_black_border && charCollector == NULL)
|
||||
{
|
||||
// draw black border
|
||||
video::SColor black(color.getAlpha(),0,0,0);
|
||||
@ -658,23 +667,45 @@ void ScalableFont::draw(const core::stringw& text,
|
||||
|
||||
if (fallback[n])
|
||||
{
|
||||
// draw text over
|
||||
// TODO: don't hardcode colors?
|
||||
static video::SColor orange(color.getAlpha(), 255, 100, 0);
|
||||
static video::SColor yellow(color.getAlpha(), 255, 220, 15);
|
||||
video::SColor title_colors[] = {yellow, orange, orange, yellow};
|
||||
draw2DImage(texture,
|
||||
dest,
|
||||
source,
|
||||
clip,
|
||||
title_colors, true);
|
||||
|
||||
if (charCollector != NULL)
|
||||
{
|
||||
charCollector->collectChar(texture,
|
||||
dest,
|
||||
source,
|
||||
title_colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw2DImage(texture,
|
||||
dest,
|
||||
source,
|
||||
clip,
|
||||
title_colors, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
draw2DImage(texture,
|
||||
dest,
|
||||
source,
|
||||
clip,
|
||||
color, true);
|
||||
if (charCollector != NULL)
|
||||
{
|
||||
video::SColor colors[] = { color, color, color, color };
|
||||
charCollector->collectChar(texture,
|
||||
dest,
|
||||
source,
|
||||
colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw2DImage(texture,
|
||||
dest,
|
||||
source,
|
||||
clip,
|
||||
color, true);
|
||||
}
|
||||
#ifdef FONT_DEBUG
|
||||
driver->draw2DLine(core::position2d<s32>(dest.UpperLeftCorner.X, dest.UpperLeftCorner.Y),
|
||||
core::position2d<s32>(dest.UpperLeftCorner.X, dest.LowerRightCorner.Y),
|
||||
|
@ -26,6 +26,7 @@ namespace video
|
||||
{
|
||||
class IVideoDriver;
|
||||
class IImage;
|
||||
class ITexture;
|
||||
}
|
||||
|
||||
namespace gui
|
||||
@ -33,6 +34,14 @@ namespace gui
|
||||
|
||||
class IGUIEnvironment;
|
||||
|
||||
class FontCharCollector
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void collectChar(video::ITexture* texture, const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect, const video::SColor* const colors) = 0;
|
||||
};
|
||||
|
||||
class ScalableFont : public IGUIFontBitmap
|
||||
{
|
||||
float m_scale;
|
||||
@ -101,12 +110,17 @@ public:
|
||||
|
||||
//! draws an text and clips it to the specified rectangle if wanted
|
||||
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
||||
video::SColor color, bool hcenter=false,
|
||||
bool vcenter=false, const core::rect<s32>* clip=0);
|
||||
video::SColor color, bool hcenter = false,
|
||||
bool vcenter = false, const core::rect<s32>* clip = 0);
|
||||
|
||||
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
||||
video::SColor color, bool hcenter,
|
||||
bool vcenter, const core::rect<s32>* clip, bool ignoreRTL);
|
||||
void draw(const core::stringw& text, const core::rect<s32>& position,
|
||||
video::SColor color, bool hcenter,
|
||||
bool vcenter, const core::rect<s32>* clip, bool ignoreRTL);
|
||||
|
||||
void doDraw(const core::stringw& text, const core::rect<s32>& position,
|
||||
video::SColor color, bool hcenter,
|
||||
bool vcenter, const core::rect<s32>* clip,
|
||||
FontCharCollector* charCollector = NULL);
|
||||
|
||||
//! returns the dimension of a text
|
||||
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "graphics/shadow.hpp"
|
||||
#include "graphics/skid_marks.hpp"
|
||||
#include "graphics/slip_stream.hpp"
|
||||
#include "graphics/stk_text_billboard.hpp"
|
||||
#include "graphics/stars.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "karts/explosion_animation.hpp"
|
||||
@ -2348,7 +2349,8 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
|
||||
m_sky_particles_emitter =
|
||||
new ParticleEmitter(track->getSkyParticles(),
|
||||
core::vector3df(0.0f, 30.0f, 100.0f),
|
||||
getNode());
|
||||
getNode(),
|
||||
true);
|
||||
|
||||
// FIXME: in multiplayer mode, this will result in several instances
|
||||
// of the heightmap being calculated and kept in memory
|
||||
@ -2597,21 +2599,36 @@ btQuaternion Kart::getVisualRotation() const
|
||||
void Kart::setOnScreenText(const wchar_t *text)
|
||||
{
|
||||
core::dimension2d<u32> textsize = GUIEngine::getFont()->getDimension(text);
|
||||
|
||||
// FIXME: Titlefont is the only font guaranteed to be loaded if STK
|
||||
// is started without splash screen (since "Loading" is shown even in this
|
||||
// case). A smaller font would be better
|
||||
// TODO: Add support in the engine for BillboardText or find a replacement
|
||||
/*scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont()
|
||||
: GUIEngine::getTitleFont(),
|
||||
text,
|
||||
getNode(),
|
||||
core::dimension2df(textsize.Width/55.0f,
|
||||
textsize.Height/55.0f),
|
||||
core::vector3df(0.0f, 1.5f, 0.0f),
|
||||
-1, // id
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0));*/
|
||||
|
||||
if (irr_driver->isGLSL())
|
||||
{
|
||||
gui::ScalableFont* font = GUIEngine::getFont() ? GUIEngine::getFont() : GUIEngine::getTitleFont();
|
||||
STKTextBillboard* tb = new STKTextBillboard(text, font,
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0),
|
||||
getNode(), irr_driver->getSceneManager(), -1,
|
||||
core::vector3df(0.0f, 1.5f, 0.0f),
|
||||
core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont()
|
||||
: GUIEngine::getTitleFont(),
|
||||
text,
|
||||
getNode(),
|
||||
core::dimension2df(textsize.Width/55.0f,
|
||||
textsize.Height/55.0f),
|
||||
core::vector3df(0.0f, 1.5f, 0.0f),
|
||||
-1, // id
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0));
|
||||
}
|
||||
|
||||
// No need to store the reference to the billboard scene node:
|
||||
// It has one reference to the parent, and will get deleted
|
||||
// when the parent is deleted.
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
#include "states_screens/options_screen_video.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
@ -51,7 +52,6 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
|
||||
{
|
||||
getWidget<CheckBoxWidget>("anim_gfx")->setState( UserConfigParams::m_graphical_effects );
|
||||
getWidget<CheckBoxWidget>("weather_gfx")->setState( UserConfigParams::m_weather_effects );
|
||||
getWidget<CheckBoxWidget>("ubo")->setState(!UserConfigParams::m_ubo_disabled);
|
||||
getWidget<CheckBoxWidget>("dof")->setState(UserConfigParams::m_dof);
|
||||
getWidget<CheckBoxWidget>("hd-textures")->setState(UserConfigParams::m_high_definition_textures);
|
||||
|
||||
@ -83,8 +83,10 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
|
||||
shadows->addLabel( _("Disabled") ); // 0
|
||||
shadows->addLabel( _("low") ); // 1
|
||||
shadows->addLabel( _("high") ); // 2
|
||||
shadows->setValue( UserConfigParams::m_shadows );
|
||||
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
shadows->setValue(UserConfigParams::m_shadows);
|
||||
else
|
||||
shadows->setValue(0);
|
||||
getWidget<CheckBoxWidget>("dynamiclight")->setState(UserConfigParams::m_dynamic_lights);
|
||||
getWidget<CheckBoxWidget>("lightshaft")->setState(UserConfigParams::m_light_shaft);
|
||||
getWidget<CheckBoxWidget>("global_illumination")->setState(UserConfigParams::m_gi);
|
||||
@ -107,14 +109,14 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
|
||||
|
||||
UserConfigParams::m_dof =
|
||||
advanced_pipeline && getWidget<CheckBoxWidget>("dof")->getState();
|
||||
|
||||
|
||||
UserConfigParams::m_motionblur =
|
||||
advanced_pipeline && getWidget<CheckBoxWidget>("motionblur")->getState();
|
||||
|
||||
|
||||
if (advanced_pipeline)
|
||||
{
|
||||
UserConfigParams::m_shadows =
|
||||
advanced_pipeline && getWidget<SpinnerWidget>("shadows")->getValue();
|
||||
getWidget<SpinnerWidget>("shadows")->getValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -148,9 +150,6 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
|
||||
UserConfigParams::m_weather_effects =
|
||||
getWidget<CheckBoxWidget>("weather_gfx")->getState();
|
||||
|
||||
UserConfigParams::m_ubo_disabled =
|
||||
!getWidget<CheckBoxWidget>("ubo")->getState();
|
||||
|
||||
UserConfigParams::m_high_definition_textures =
|
||||
getWidget<CheckBoxWidget>("hd-textures")->getState();
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#include "graphics/particle_kind.hpp"
|
||||
#include "graphics/particle_kind_manager.hpp"
|
||||
#include "graphics/stk_text_billboard.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
@ -1102,19 +1103,33 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
|
||||
assert(GUIEngine::getHighresDigitFont() != NULL);
|
||||
|
||||
// TODO: Add support in the engine for BillboardText or find a replacement
|
||||
/* scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
scene::ISceneNode* sn =
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(),
|
||||
msg.c_str(),
|
||||
NULL,
|
||||
core::dimension2df(textsize.Width/45.0f,
|
||||
textsize.Height/45.0f),
|
||||
xyz,
|
||||
-1, // id
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0));
|
||||
m_all_nodes.push_back(sn);*/
|
||||
if (irr_driver->isGLSL())
|
||||
{
|
||||
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||
STKTextBillboard* tb = new STKTextBillboard(msg.c_str(), font,
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0),
|
||||
irr_driver->getSceneManager()->getRootSceneNode(),
|
||||
irr_driver->getSceneManager(), -1, xyz,
|
||||
core::vector3df(1.5f, 1.5f, 1.5f));
|
||||
m_all_nodes.push_back(tb);
|
||||
}
|
||||
else
|
||||
{
|
||||
scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
scene::ISceneNode* sn =
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(),
|
||||
msg.c_str(),
|
||||
NULL,
|
||||
core::dimension2df(textsize.Width / 35.0f,
|
||||
textsize.Height / 35.0f),
|
||||
xyz,
|
||||
-1, // id
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0));
|
||||
m_all_nodes.push_back(sn);
|
||||
}
|
||||
|
||||
if (!shown) continue;
|
||||
}
|
||||
else if (condition == "allchallenges")
|
||||
|
Loading…
Reference in New Issue
Block a user