Fix #2814
This commit is contained in:
parent
ea97258b65
commit
79c6705bb1
@ -20,7 +20,7 @@ out vec2 uv;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
|
||||
vec3 test = sin(windDir * (Position.y * 0.1)) * 1.;
|
||||
test += cos(windDir) * 0.7;
|
||||
|
||||
mat4 new_model_matrix = ModelMatrix;
|
||||
|
@ -1,11 +1,9 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D Albedo;
|
||||
layout(bindless_sampler) uniform sampler2D dtex;
|
||||
layout(bindless_sampler) uniform sampler2D SpecMap;
|
||||
layout(bindless_sampler) uniform sampler2D colorization_mask;
|
||||
#else
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
@ -36,25 +34,8 @@ void main(void)
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
color.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
}
|
||||
|
||||
vec2 texc = gl_FragCoord.xy / screen;
|
||||
float z = texture(dtex, texc).x;
|
||||
|
||||
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
|
||||
xpos = InverseProjectionMatrix * xpos;
|
||||
xpos /= xpos.w;
|
||||
vec3 eyedir = normalize(xpos.xyz);
|
||||
|
||||
// Inspired from http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html
|
||||
vec3 L = normalize((transpose(InverseViewMatrix) * vec4(sun_direction, 0.)).xyz);
|
||||
float fEdotL = clamp(dot(L, eyedir), 0., 1.);
|
||||
float fPowEdotL = pow(fEdotL, 4.);
|
||||
|
||||
float fLdotNBack = max(0., - dot(nor, L) * 0.6 + 0.4);
|
||||
float scattering = mix(fPowEdotL, fLdotNBack, .5);
|
||||
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
|
||||
vec3 LightFactor = getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
|
||||
FragColor = vec4(LightFactor, 1.);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ flat out sampler2D thirdhandle;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
|
||||
vec3 test = sin(windDir * (Position.y * 0.1)) * 1.;
|
||||
test += cos(windDir) * 0.7;
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin + test * Color.r, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + test * Color.r, Orientation, Scale) * InverseViewMatrix);
|
||||
|
@ -1,9 +1,6 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D dtex;
|
||||
#else
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
@ -45,24 +42,6 @@ void main(void)
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
color.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
}
|
||||
|
||||
vec2 texc = gl_FragCoord.xy / screen;
|
||||
float z = texture(dtex, texc).x;
|
||||
|
||||
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
|
||||
xpos = InverseProjectionMatrix * xpos;
|
||||
xpos /= xpos.w;
|
||||
vec3 eyedir = normalize(xpos.xyz);
|
||||
|
||||
// Inspired from http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html
|
||||
vec3 L = normalize((transpose(InverseViewMatrix) * vec4(sun_direction, 0.)).xyz);
|
||||
float fEdotL = clamp(dot(L, eyedir), 0., 1.);
|
||||
float fPowEdotL = pow(fEdotL, 4.);
|
||||
|
||||
float fLdotNBack = max(0., - dot(nor, L) * 0.6 + 0.4);
|
||||
float scattering = mix(fPowEdotL, fLdotNBack, .5);
|
||||
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
|
||||
|
||||
vec3 LightFactor = getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
|
||||
FragColor = vec4(LightFactor, 1.);
|
||||
}
|
||||
|
@ -80,26 +80,6 @@ void InstanceFiller<GlowInstanceData>::add(GLMesh* mesh,
|
||||
instance.Color = nd->getGlowColor().color;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<>
|
||||
void expandTexSecondPass<GrassMat>(const GLMesh &mesh,
|
||||
const std::vector<GLuint> &prefilled_tex)
|
||||
{
|
||||
TexExpander<typename GrassMat::InstancedSecondPassShader>::
|
||||
expandTex(mesh, GrassMat::SecondPassTextures, prefilled_tex[0],
|
||||
prefilled_tex[1], prefilled_tex[2], prefilled_tex[3]);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<>
|
||||
void expandHandlesSecondPass<GrassMat>(const std::vector<uint64_t> &handles)
|
||||
{
|
||||
uint64_t nulltex[10] = {};
|
||||
HandleExpander<GrassMat::InstancedSecondPassShader>::
|
||||
expand(nulltex, GrassMat::SecondPassTextures,
|
||||
handles[0], handles[1], handles[2], handles[3]);
|
||||
}
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
// ----------------------------------------------------------------------------
|
||||
template<int N>
|
||||
|
@ -112,11 +112,7 @@ void expandTexSecondPass(const GLMesh &mesh,
|
||||
expandTex(mesh, T::SecondPassTextures, prefilled_tex[0],
|
||||
prefilled_tex[1], prefilled_tex[2]);
|
||||
}
|
||||
|
||||
template<>
|
||||
void expandTexSecondPass<GrassMat>(const GLMesh &mesh,
|
||||
const std::vector<GLuint> &prefilled_tex);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Give acces textures for second rendering pass in shaders
|
||||
* without first binding them in order to reduce driver overhead.
|
||||
@ -133,10 +129,6 @@ void expandHandlesSecondPass(const std::vector<uint64_t> &handles)
|
||||
handles[0], handles[1], handles[2]);
|
||||
}
|
||||
|
||||
template<>
|
||||
void expandHandlesSecondPass<GrassMat>(const std::vector<uint64_t> &handles);
|
||||
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
// ----------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -89,49 +89,6 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
|
||||
}
|
||||
} // renderMeshes2ndPass
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<>
|
||||
void renderMeshes2ndPass<GrassMat, 4, 3, 1>
|
||||
(const std::vector<uint64_t> &Prefilled_Handle,
|
||||
const std::vector<GLuint> &Prefilled_Tex)
|
||||
{
|
||||
auto &meshes = GrassMat::List::getInstance()->SolidPass;
|
||||
GrassMat::SecondPassShader::getInstance()->use();
|
||||
if (CVS->isARBBaseInstanceUsable())
|
||||
glBindVertexArray(VAOManager::getInstance()->getVAO(GrassMat::VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(std::get<0>(meshes.at(i)));
|
||||
if (!CVS->isARBBaseInstanceUsable())
|
||||
glBindVertexArray(mesh.vao);
|
||||
|
||||
if (mesh.VAOType != GrassMat::VertexType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Log::error("Materials", "Wrong vertex Type associed to pass 2 "
|
||||
"(hint texture : %s)",
|
||||
mesh.textures[0]->getName().getPath().c_str());
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CVS->isAZDOEnabled())
|
||||
{
|
||||
HandleExpander<GrassMat::SecondPassShader>::
|
||||
expand(mesh.TextureHandles, GrassMat::SecondPassTextures,
|
||||
Prefilled_Handle[0], Prefilled_Handle[1],
|
||||
Prefilled_Handle[2], Prefilled_Handle[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
TexExpander<GrassMat::SecondPassShader>::
|
||||
expandTex(mesh, GrassMat::SecondPassTextures, Prefilled_Tex[0],
|
||||
Prefilled_Tex[1], Prefilled_Tex[2], Prefilled_Tex[3]);
|
||||
}
|
||||
CustomUnrollArgs<4, 3, 1>::drawMesh<GrassMat::SecondPassShader>(meshes.at(i));
|
||||
}
|
||||
} // renderMeshes2ndPass
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<typename T, int...List>
|
||||
void renderShadow(unsigned cascade)
|
||||
|
@ -432,10 +432,9 @@ GrassPass2Shader::GrassPass2Shader()
|
||||
assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "dtex", ST_NEAREST_FILTERED,
|
||||
4, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
6, "colorization_mask",
|
||||
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "colorization_mask",
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
} // GrassPass2Shader
|
||||
|
||||
@ -448,10 +447,9 @@ InstancedGrassPass2Shader::InstancedGrassPass2Shader()
|
||||
assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "dtex", ST_NEAREST_FILTERED,
|
||||
4, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
6, "colorization_mask",
|
||||
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
5, "colorization_mask",
|
||||
ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
} // InstancedGrassPass2Shader
|
||||
|
||||
|
@ -260,7 +260,7 @@ public:
|
||||
}; // InstancedGrassShadowShader
|
||||
|
||||
// ============================================================================
|
||||
class GrassPass2Shader : public TextureShader<GrassPass2Shader, 7,
|
||||
class GrassPass2Shader : public TextureShader<GrassPass2Shader, 6,
|
||||
core::matrix4, core::vector3df,
|
||||
core::vector2df>
|
||||
{
|
||||
@ -270,7 +270,7 @@ public:
|
||||
|
||||
// ============================================================================
|
||||
class InstancedGrassPass2Shader
|
||||
: public TextureShader<InstancedGrassPass2Shader, 7, core::vector3df>
|
||||
: public TextureShader<InstancedGrassPass2Shader, 6, core::vector3df>
|
||||
{
|
||||
public:
|
||||
InstancedGrassPass2Shader();
|
||||
|
Loading…
x
Reference in New Issue
Block a user