Use prefix "s" for sampler uniforms

This commit is contained in:
Vsevolod Kremianskii 2021-05-16 13:03:36 +07:00
parent 5f290bc18b
commit a937fab08b
23 changed files with 103 additions and 103 deletions

View file

@ -198,7 +198,7 @@ void SelectionOverlay::draw() {
} }
void SelectionOverlay::drawReticle(Texture &texture, const glm::vec3 &screenCoords) { void SelectionOverlay::drawReticle(Texture &texture, const glm::vec3 &screenCoords) {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
texture.bind(); texture.bind();
const GraphicsOptions &opts = _game->options().graphics; const GraphicsOptions &opts = _game->options().graphics;
@ -287,7 +287,7 @@ void SelectionOverlay::drawActionBar() {
} else { } else {
frameTexture = _friendlyScroll; frameTexture = _friendlyScroll;
} }
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
frameTexture->bind(); frameTexture->bind();
float frameX, frameY; float frameX, frameY;
@ -309,7 +309,7 @@ void SelectionOverlay::drawActionBar() {
shared_ptr<Texture> texture(_textureByAction.find(action)->second); shared_ptr<Texture> texture(_textureByAction.find(action)->second);
if (texture) { if (texture) {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
texture->bind(); texture->bind();
float y = opts.height * (1.0f - _selectedScreenCoords.y) - (_reticleHeight + kActionHeight + kActionWidth) / 2.0f - kOffsetToReticle - kActionBarMargin; float y = opts.height * (1.0f - _selectedScreenCoords.y) - (_reticleHeight + kActionHeight + kActionWidth) / 2.0f - kOffsetToReticle - kActionBarMargin;

View file

@ -99,7 +99,7 @@ void Map::drawArea(Mode mode, const glm::vec4 &bounds) {
shared_ptr<Creature> partyLeader(_game->party().getLeader()); shared_ptr<Creature> partyLeader(_game->party().getLeader());
if (!partyLeader) return; if (!partyLeader) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_areaTexture->bind(); _areaTexture->bind();
glm::vec2 worldPos(partyLeader->position()); glm::vec2 worldPos(partyLeader->position());
@ -123,7 +123,7 @@ void Map::drawArea(Mode mode, const glm::vec4 &bounds) {
StateManager::instance().withScissorTest(scissorBounds, []() { Meshes::instance().getQuad()->draw(); }); StateManager::instance().withScissorTest(scissorBounds, []() { Meshes::instance().getQuad()->draw(); });
} else { } else {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_areaTexture->bind(); _areaTexture->bind();
glm::mat4 transform(1.0f); glm::mat4 transform(1.0f);
@ -142,7 +142,7 @@ void Map::drawArea(Mode mode, const glm::vec4 &bounds) {
void Map::drawNotes(Mode mode, const glm::vec4 &bounds) { void Map::drawNotes(Mode mode, const glm::vec4 &bounds) {
if (mode != Mode::Default) return; if (mode != Mode::Default) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_noteTexture->bind(); _noteTexture->bind();
for (auto &object : _game->module()->area()->getObjectsByType(ObjectType::Waypoint)) { for (auto &object : _game->module()->area()->getObjectsByType(ObjectType::Waypoint)) {
@ -205,7 +205,7 @@ void Map::drawPartyLeader(Mode mode, const glm::vec4 &bounds) {
shared_ptr<Creature> partyLeader(_game->party().getLeader()); shared_ptr<Creature> partyLeader(_game->party().getLeader());
if (!partyLeader) return; if (!partyLeader) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_arrowTexture->bind(); _arrowTexture->bind();
glm::vec3 arrowPos(0.0f); glm::vec3 arrowPos(0.0f);

View file

@ -45,7 +45,7 @@ Cursor::Cursor(const shared_ptr<Texture> &up, const shared_ptr<Texture> &down) :
void Cursor::draw() { void Cursor::draw() {
shared_ptr<Texture> texture(_pressed ? _down : _up); shared_ptr<Texture> texture(_pressed ? _down : _up);
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
texture->bind(); texture->bind();
glm::mat4 transform(1.0f); glm::mat4 transform(1.0f);

View file

@ -65,7 +65,7 @@ void Font::load(const shared_ptr<Texture> &texture) {
void Font::draw(const string &text, const glm::vec3 &position, const glm::vec3 &color, TextGravity gravity) { void Font::draw(const string &text, const glm::vec3 &position, const glm::vec3 &color, TextGravity gravity) {
if (text.empty()) return; if (text.empty()) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_texture->bind(); _texture->bind();
glm::vec3 textOffset(getTextOffset(text, gravity), 0.0f); glm::vec3 textOffset(getTextOffset(text, gravity), 0.0f);

View file

@ -111,7 +111,7 @@ shared_ptr<Texture> PBRIBL::computeIrradianceMap(const Texture *envmap) {
_irradianceFB.bind(); _irradianceFB.bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::envmap); StateManager::instance().setActiveTextureUnit(TextureUnits::environmentMap);
envmap->bind(); envmap->bind();
StateManager::instance().withViewport(viewport, [&]() { StateManager::instance().withViewport(viewport, [&]() {
@ -148,7 +148,7 @@ shared_ptr<Texture> PBRIBL::computePrefilterMap(const Texture *envmap) {
_prefilterFB.bind(); _prefilterFB.bind();
_prefilterFB.attachDepth(*prefilterDepth); _prefilterFB.attachDepth(*prefilterDepth);
StateManager::instance().setActiveTextureUnit(TextureUnits::envmap); StateManager::instance().setActiveTextureUnit(TextureUnits::environmentMap);
envmap->bind(); envmap->bind();
for (int mip = 0; mip < kNumPrefilterMipMaps; ++mip) { for (int mip = 0; mip < kNumPrefilterMipMaps; ++mip) {

View file

@ -215,16 +215,16 @@ void Shaders::initUBO(const string &block, int bindingPoint, uint32_t ubo, const
} }
void Shaders::initTextureUniforms() { void Shaders::initTextureUniforms() {
setUniform("uDiffuse", TextureUnits::diffuse); setUniform("sDiffuseMap", TextureUnits::diffuseMap);
setUniform("uLightmap", TextureUnits::lightmap); setUniform("sLightmap", TextureUnits::lightmap);
setUniform("uEnvmap", TextureUnits::envmap); setUniform("sEnvironmentMap", TextureUnits::environmentMap);
setUniform("uBumpmap", TextureUnits::bumpmap); setUniform("sBumpMap", TextureUnits::bumpMap);
setUniform("uBloom", TextureUnits::bloom); setUniform("sBloom", TextureUnits::bloom);
setUniform("uIrradianceMap", TextureUnits::irradianceMap); setUniform("sIrradianceMap", TextureUnits::irradianceMap);
setUniform("uPrefilterMap", TextureUnits::prefilterMap); setUniform("sPrefilterMap", TextureUnits::prefilterMap);
setUniform("uBRDFLookup", TextureUnits::brdfLookup); setUniform("sBRDFLookup", TextureUnits::brdfLookup);
setUniform("uShadowMap", TextureUnits::shadowMap); setUniform("sShadowMap", TextureUnits::shadowMap);
setUniform("uCubeShadowMap", TextureUnits::cubeShadowMap); setUniform("sShadowMapCube", TextureUnits::shadowMapCube);
} }
Shaders::~Shaders() { Shaders::~Shaders() {

View file

@ -180,12 +180,12 @@ bool isFeatureEnabled(int flag) {
char g_shaderBaseModel[] = R"END( char g_shaderBaseModel[] = R"END(
const float SELFILLUM_THRESHOLD = 0.85; const float SELFILLUM_THRESHOLD = 0.85;
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
uniform sampler2D uLightmap; uniform sampler2D sLightmap;
uniform sampler2D uBumpmap; uniform sampler2D sBumpMap;
uniform sampler2D uShadowMap; uniform sampler2D sShadowMap;
uniform samplerCube uEnvmap; uniform samplerCube sEnvironmentMap;
uniform samplerCube uCubeShadowMap; uniform samplerCube sShadowMapCube;
in vec3 fragPosition; in vec3 fragPosition;
in vec3 fragNormal; in vec3 fragNormal;
@ -219,9 +219,9 @@ vec3 getNormalFromBumpMap(vec2 uv) {
vec2 packedUv = packUV(uv, frameBounds); vec2 packedUv = packUV(uv, frameBounds);
vec2 packedUvDu = packUV(uv + du, frameBounds); vec2 packedUvDu = packUV(uv + du, frameBounds);
vec2 packedUvDv = packUV(uv + dv, frameBounds); vec2 packedUvDv = packUV(uv + dv, frameBounds);
vec4 bumpmapSample = texture(uBumpmap, packedUv); vec4 bumpmapSample = texture(sBumpMap, packedUv);
vec4 bumpmapSampleDu = texture(uBumpmap, packedUvDu); vec4 bumpmapSampleDu = texture(sBumpMap, packedUvDu);
vec4 bumpmapSampleDv = texture(uBumpmap, packedUvDv); vec4 bumpmapSampleDv = texture(sBumpMap, packedUvDv);
float dBx = bumpmapSampleDu.r - bumpmapSample.r; float dBx = bumpmapSampleDu.r - bumpmapSample.r;
float dBy = bumpmapSampleDv.r - bumpmapSample.r; float dBy = bumpmapSampleDv.r - bumpmapSample.r;
vec3 normal = vec3(-dBx * uBumpmaps.scaling, -dBy * uBumpmaps.scaling, 1.0); vec3 normal = vec3(-dBx * uBumpmaps.scaling, -dBy * uBumpmaps.scaling, 1.0);
@ -230,7 +230,7 @@ vec3 getNormalFromBumpMap(vec2 uv) {
} }
vec3 getNormalFromNormalMap(vec2 uv) { vec3 getNormalFromNormalMap(vec2 uv) {
vec4 bumpmapSample = texture(uBumpmap, uv); vec4 bumpmapSample = texture(sBumpMap, uv);
vec3 normal = bumpmapSample.rgb * 2.0 - 1.0; vec3 normal = bumpmapSample.rgb * 2.0 - 1.0;
return normalize(normal * fragTanSpace); return normalize(normal * fragTanSpace);
} }
@ -259,13 +259,13 @@ float getShadow() {
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
projCoords = projCoords * 0.5 + 0.5; projCoords = projCoords * 0.5 + 0.5;
float closestDepth = texture(uShadowMap, projCoords.xy).r; float closestDepth = texture(sShadowMap, projCoords.xy).r;
float currentDepth = projCoords.z; float currentDepth = projCoords.z;
vec2 texelSize = 1.0 / textureSize(uShadowMap, 0); vec2 texelSize = 1.0 / textureSize(sShadowMap, 0);
for (int x = -1; x <= 1; ++x) { for (int x = -1; x <= 1; ++x) {
for (int y = -1; y <= 1; ++y) { for (int y = -1; y <= 1; ++y) {
float pcfDepth = texture(uShadowMap, projCoords.xy + vec2(x, y) * texelSize).r; float pcfDepth = texture(sShadowMap, projCoords.xy + vec2(x, y) * texelSize).r;
result += currentDepth > pcfDepth ? 1.0 : 0.0; result += currentDepth > pcfDepth ? 1.0 : 0.0;
} }
} }
@ -287,7 +287,7 @@ float getShadow() {
for (float x = -offset; x < offset; x += offset / (samples * 0.5)) { for (float x = -offset; x < offset; x += offset / (samples * 0.5)) {
for (float y = -offset; y < offset; y += offset / (samples * 0.5)) { for (float y = -offset; y < offset; y += offset / (samples * 0.5)) {
for (float z = -offset; z < offset; z += offset / (samples * 0.5)) { for (float z = -offset; z < offset; z += offset / (samples * 0.5)) {
float closestDepth = texture(uCubeShadowMap, fragToLight + vec3(x, y, z)).r; float closestDepth = texture(sShadowMapCube, fragToLight + vec3(x, y, z)).r;
closestDepth *= SHADOW_FAR_PLANE; closestDepth *= SHADOW_FAR_PLANE;
if (currentDepth - bias > closestDepth) { if (currentDepth - bias > closestDepth) {
@ -575,7 +575,7 @@ void main() {
)END"; )END";
char g_shaderFragmentGUI[] = R"END( char g_shaderFragmentGUI[] = R"END(
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
in vec2 fragTexCoords; in vec2 fragTexCoords;
@ -583,7 +583,7 @@ layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 fragColorBright; layout(location = 1) out vec4 fragColorBright;
void main() { void main() {
vec4 diffuseSample = texture(uDiffuse, fragTexCoords); vec4 diffuseSample = texture(sDiffuseMap, fragTexCoords);
vec3 objectColor = uGeneral.color.rgb * diffuseSample.rgb; vec3 objectColor = uGeneral.color.rgb * diffuseSample.rgb;
if (isFeatureEnabled(FEATURE_DISCARD) && length(uGeneral.discardColor.rgb - objectColor) < 0.01) discard; if (isFeatureEnabled(FEATURE_DISCARD) && length(uGeneral.discardColor.rgb - objectColor) < 0.01) discard;
@ -594,7 +594,7 @@ void main() {
)END"; )END";
char g_shaderFragmentText[] = R"END( char g_shaderFragmentText[] = R"END(
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
in vec2 fragTexCoords; in vec2 fragTexCoords;
flat in int fragInstanceID; flat in int fragInstanceID;
@ -603,14 +603,14 @@ out vec4 fragColor;
void main() { void main() {
vec2 uv = fragTexCoords * uChars[fragInstanceID].uv.zw + uChars[fragInstanceID].uv.xy; vec2 uv = fragTexCoords * uChars[fragInstanceID].uv.zw + uChars[fragInstanceID].uv.xy;
vec4 diffuseSample = texture(uDiffuse, uv); vec4 diffuseSample = texture(sDiffuseMap, uv);
vec3 objectColor = uGeneral.color.rgb * diffuseSample.rgb; vec3 objectColor = uGeneral.color.rgb * diffuseSample.rgb;
fragColor = vec4(objectColor, diffuseSample.a); fragColor = vec4(objectColor, diffuseSample.a);
} }
)END"; )END";
char g_shaderFragmentParticle[] = R"END( char g_shaderFragmentParticle[] = R"END(
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
in vec2 fragTexCoords; in vec2 fragTexCoords;
flat in int fragInstanceID; flat in int fragInstanceID;
@ -631,7 +631,7 @@ void main() {
texCoords.x += oneOverGridX * (uParticles[fragInstanceID].frame % int(uParticleGridSize.x)); texCoords.x += oneOverGridX * (uParticles[fragInstanceID].frame % int(uParticleGridSize.x));
} }
vec4 diffuseSample = texture(uDiffuse, texCoords); vec4 diffuseSample = texture(sDiffuseMap, texCoords);
fragColor = vec4(uParticles[fragInstanceID].color.rgb * diffuseSample.rgb, uParticles[fragInstanceID].alpha * diffuseSample.a); fragColor = vec4(uParticles[fragInstanceID].color.rgb * diffuseSample.rgb, uParticles[fragInstanceID].alpha * diffuseSample.a);
fragColorBright = vec4(vec3(0.0), 0.0); fragColorBright = vec4(vec3(0.0), 0.0);
@ -639,8 +639,8 @@ void main() {
)END"; )END";
char g_shaderFragmentGrass[] = R"END( char g_shaderFragmentGrass[] = R"END(
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
uniform sampler2D uLightmap; uniform sampler2D sLightmap;
in vec2 fragTexCoords; in vec2 fragTexCoords;
flat in int fragInstanceID; flat in int fragInstanceID;
@ -653,11 +653,11 @@ void main() {
uv.y += 0.5 * (int(uGrassClusters[fragInstanceID].positionVariant[3]) / 2); uv.y += 0.5 * (int(uGrassClusters[fragInstanceID].positionVariant[3]) / 2);
uv.x += 0.5 * (int(uGrassClusters[fragInstanceID].positionVariant[3]) % 2); uv.x += 0.5 * (int(uGrassClusters[fragInstanceID].positionVariant[3]) % 2);
vec4 diffuseSample = texture(uDiffuse, uv); vec4 diffuseSample = texture(sDiffuseMap, uv);
vec3 objectColor = diffuseSample.rgb; vec3 objectColor = diffuseSample.rgb;
if (isFeatureEnabled(FEATURE_LIGHTMAP)) { if (isFeatureEnabled(FEATURE_LIGHTMAP)) {
vec4 lightmapSample = texture(uLightmap, uGrassClusters[fragInstanceID].lightmapUV); vec4 lightmapSample = texture(sLightmap, uGrassClusters[fragInstanceID].lightmapUV);
objectColor *= lightmapSample.rgb; objectColor *= lightmapSample.rgb;
} }
@ -667,7 +667,7 @@ void main() {
)END"; )END";
char g_shaderFragmentBlur[] = R"END( char g_shaderFragmentBlur[] = R"END(
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
out vec4 fragColor; out vec4 fragColor;
@ -676,27 +676,27 @@ void main() {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3846153846) * uBlur.direction; vec2 off1 = vec2(1.3846153846) * uBlur.direction;
vec2 off2 = vec2(3.2307692308) * uBlur.direction; vec2 off2 = vec2(3.2307692308) * uBlur.direction;
color += texture(uDiffuse, uv) * 0.2270270270; color += texture(sDiffuseMap, uv) * 0.2270270270;
color += texture(uDiffuse, uv + (off1 / uBlur.resolution)) * 0.3162162162; color += texture(sDiffuseMap, uv + (off1 / uBlur.resolution)) * 0.3162162162;
color += texture(uDiffuse, uv - (off1 / uBlur.resolution)) * 0.3162162162; color += texture(sDiffuseMap, uv - (off1 / uBlur.resolution)) * 0.3162162162;
color += texture(uDiffuse, uv + (off2 / uBlur.resolution)) * 0.0702702703; color += texture(sDiffuseMap, uv + (off2 / uBlur.resolution)) * 0.0702702703;
color += texture(uDiffuse, uv - (off2 / uBlur.resolution)) * 0.0702702703; color += texture(sDiffuseMap, uv - (off2 / uBlur.resolution)) * 0.0702702703;
fragColor = color; fragColor = color;
} }
)END"; )END";
char g_shaderFragmentPresentWorld[] = R"END( char g_shaderFragmentPresentWorld[] = R"END(
uniform sampler2D uDiffuse; uniform sampler2D sDiffuseMap;
uniform sampler2D uBloom; uniform sampler2D sBloom;
in vec2 fragTexCoords; in vec2 fragTexCoords;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 diffuseSample = texture(uDiffuse, fragTexCoords); vec4 diffuseSample = texture(sDiffuseMap, fragTexCoords);
vec4 bloomSample = texture(uBloom, fragTexCoords); vec4 bloomSample = texture(sBloom, fragTexCoords);
vec3 color = diffuseSample.rgb + bloomSample.rgb; vec3 color = diffuseSample.rgb + bloomSample.rgb;
fragColor = vec4(color, 1.0); fragColor = vec4(color, 1.0);

View file

@ -131,7 +131,7 @@ vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) {
)END"; )END";
char g_shaderFragmentIrradiance[] = R"END( char g_shaderFragmentIrradiance[] = R"END(
uniform samplerCube uEnvmap; uniform samplerCube sEnvironmentMap;
in vec3 fragPosition; in vec3 fragPosition;
@ -152,7 +152,7 @@ void main() {
vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)); vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * N; vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * N;
irradiance += texture(uEnvmap, sampleVec).rgb * cos(theta) * sin(theta); irradiance += texture(sEnvironmentMap, sampleVec).rgb * cos(theta) * sin(theta);
++numSamples; ++numSamples;
} }
} }
@ -163,7 +163,7 @@ void main() {
)END"; )END";
char g_shaderFragmentPrefilter[] = R"END( char g_shaderFragmentPrefilter[] = R"END(
uniform samplerCube uEnvmap; uniform samplerCube sEnvironmentMap;
in vec3 fragPosition; in vec3 fragPosition;
@ -200,7 +200,7 @@ void main() {
float mipLevel = uGeneral.roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel); float mipLevel = uGeneral.roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel);
prefilteredColor += textureLod(uEnvmap, L, mipLevel).rgb * NdotL; prefilteredColor += textureLod(sEnvironmentMap, L, mipLevel).rgb * NdotL;
totalWeight += NdotL; totalWeight += NdotL;
} }
} }
@ -223,9 +223,9 @@ void main() {
)END"; )END";
char g_shaderFragmentPBR[] = R"END( char g_shaderFragmentPBR[] = R"END(
uniform sampler2D uBRDFLookup; uniform sampler2D sBRDFLookup;
uniform samplerCube uIrradianceMap; uniform samplerCube sIrradianceMap;
uniform samplerCube uPrefilterMap; uniform samplerCube sPrefilterMap;
void main() { void main() {
vec2 uv = getUV(); vec2 uv = getUV();
@ -236,7 +236,7 @@ void main() {
vec3 N = getNormal(uv); vec3 N = getNormal(uv);
vec3 R = reflect(-V, N); vec3 R = reflect(-V, N);
vec4 diffuseSample = texture(uDiffuse, uv); vec4 diffuseSample = texture(sDiffuseMap, uv);
if (isFeatureEnabled(FEATURE_HDR)) { if (isFeatureEnabled(FEATURE_HDR)) {
diffuseSample.rgb = pow(diffuseSample.rgb, vec3(GAMMA)); diffuseSample.rgb = pow(diffuseSample.rgb, vec3(GAMMA));
} }
@ -247,7 +247,7 @@ void main() {
vec3 objectColor; vec3 objectColor;
if (isFeatureEnabled(FEATURE_LIGHTMAP)) { if (isFeatureEnabled(FEATURE_LIGHTMAP)) {
vec4 lightmapSample = texture(uLightmap, fragLightmapCoords); vec4 lightmapSample = texture(sLightmap, fragLightmapCoords);
if (isFeatureEnabled(FEATURE_HDR)) { if (isFeatureEnabled(FEATURE_HDR)) {
lightmapSample.rgb = pow(lightmapSample.rgb, vec3(GAMMA)); lightmapSample.rgb = pow(lightmapSample.rgb, vec3(GAMMA));
} }
@ -259,7 +259,7 @@ void main() {
if (isFeatureEnabled(FEATURE_ENVMAP)) { if (isFeatureEnabled(FEATURE_ENVMAP)) {
vec3 R = reflect(-V, N); vec3 R = reflect(-V, N);
vec4 envmapSample = texture(uEnvmap, R); vec4 envmapSample = texture(sEnvironmentMap, R);
if (isFeatureEnabled(FEATURE_HDR)) { if (isFeatureEnabled(FEATURE_HDR)) {
envmapSample.rgb = pow(envmapSample.rgb, vec3(GAMMA)); envmapSample.rgb = pow(envmapSample.rgb, vec3(GAMMA));
} }
@ -280,15 +280,15 @@ void main() {
vec3 kD = 1.0 - kS; vec3 kD = 1.0 - kS;
kD *= 1.0 - metallic; kD *= 1.0 - metallic;
vec3 irradiance = texture(uIrradianceMap, N).rgb; vec3 irradiance = texture(sIrradianceMap, N).rgb;
vec3 diffuse = irradiance * albedo; vec3 diffuse = irradiance * albedo;
const float MAX_REFLECTION_LOD = 4.0; const float MAX_REFLECTION_LOD = 4.0;
vec3 prefilteredColor = textureLod(uPrefilterMap, R, roughness * MAX_REFLECTION_LOD).rgb; vec3 prefilteredColor = textureLod(sPrefilterMap, R, roughness * MAX_REFLECTION_LOD).rgb;
if (isFeatureEnabled(FEATURE_HDR)) { if (isFeatureEnabled(FEATURE_HDR)) {
prefilteredColor = pow(prefilteredColor, vec3(GAMMA)); prefilteredColor = pow(prefilteredColor, vec3(GAMMA));
} }
vec2 brdf = texture(uBRDFLookup, vec2(max(dot(N, V), 0.0), roughness)).rg; vec2 brdf = texture(sBRDFLookup, vec2(max(dot(N, V), 0.0), roughness)).rg;
vec3 specular = (1.0 - diffuseSample.a) * prefilteredColor * (F * brdf.x + brdf.y); vec3 specular = (1.0 - diffuseSample.a) * prefilteredColor * (F * brdf.x + brdf.y);
ambient += (kD * diffuse + specular) * ao; ambient += (kD * diffuse + specular) * ao;
@ -335,7 +335,7 @@ void main() {
} }
if (isFeatureEnabled(FEATURE_ENVMAP)) { if (isFeatureEnabled(FEATURE_ENVMAP)) {
vec3 R = reflect(-V, N); vec3 R = reflect(-V, N);
vec4 envmapSample = texture(uEnvmap, R); vec4 envmapSample = texture(sEnvironmentMap, R);
if (isFeatureEnabled(FEATURE_HDR)) { if (isFeatureEnabled(FEATURE_HDR)) {
envmapSample.rgb = pow(envmapSample.rgb, vec3(GAMMA)); envmapSample.rgb = pow(envmapSample.rgb, vec3(GAMMA));
} }

View file

@ -60,12 +60,12 @@ void main() {
vec2 uv = getUV(); vec2 uv = getUV();
vec3 N = getNormal(uv); vec3 N = getNormal(uv);
float shadow = getShadow(); float shadow = getShadow();
vec4 diffuseSample = texture(uDiffuse, uv); vec4 diffuseSample = texture(sDiffuseMap, uv);
bool opaque = isFeatureEnabled(FEATURE_ENVMAP) || isFeatureEnabled(FEATURE_BUMPMAP) || isFeatureEnabled(FEATURE_NORMALMAP); bool opaque = isFeatureEnabled(FEATURE_ENVMAP) || isFeatureEnabled(FEATURE_BUMPMAP) || isFeatureEnabled(FEATURE_NORMALMAP);
vec3 lighting; vec3 lighting;
if (isFeatureEnabled(FEATURE_LIGHTMAP)) { if (isFeatureEnabled(FEATURE_LIGHTMAP)) {
vec4 lightmapSample = texture(uLightmap, fragLightmapCoords); vec4 lightmapSample = texture(sLightmap, fragLightmapCoords);
lighting = (1.0 - 0.5 * shadow) * lightmapSample.rgb; lighting = (1.0 - 0.5 * shadow) * lightmapSample.rgb;
if (isFeatureEnabled(FEATURE_WATER)) { if (isFeatureEnabled(FEATURE_WATER)) {
lighting = mix(vec3(1.0), lighting, 0.2); lighting = mix(vec3(1.0), lighting, 0.2);
@ -86,7 +86,7 @@ void main() {
if (isFeatureEnabled(FEATURE_ENVMAP)) { if (isFeatureEnabled(FEATURE_ENVMAP)) {
vec3 V = normalize(uGeneral.cameraPosition.xyz - fragPosition); vec3 V = normalize(uGeneral.cameraPosition.xyz - fragPosition);
vec3 R = reflect(-V, N); vec3 R = reflect(-V, N);
vec4 envmapSample = texture(uEnvmap, R); vec4 envmapSample = texture(sEnvironmentMap, R);
objectColor += (1.0 - diffuseSample.a) * envmapSample.rgb; objectColor += (1.0 - diffuseSample.a) * envmapSample.rgb;
} }
if (isFeatureEnabled(FEATURE_WATER)) { if (isFeatureEnabled(FEATURE_WATER)) {
@ -116,7 +116,7 @@ void main() {
vec3 lighting; vec3 lighting;
if (isFeatureEnabled(FEATURE_LIGHTMAP)) { if (isFeatureEnabled(FEATURE_LIGHTMAP)) {
vec4 lightmapSample = texture(uLightmap, fragLightmapCoords); vec4 lightmapSample = texture(sLightmap, fragLightmapCoords);
lighting = (1.0 - 0.5 * shadow) * lightmapSample.rgb; lighting = (1.0 - 0.5 * shadow) * lightmapSample.rgb;
} else if (isFeatureEnabled(FEATURE_LIGHTING)) { } else if (isFeatureEnabled(FEATURE_LIGHTING)) {
vec3 indirect = getLightingIndirect(N); vec3 indirect = getLightingIndirect(N);

View file

@ -64,16 +64,16 @@ void Textures::invalidateCache() {
} }
void Textures::bindDefaults() { void Textures::bindDefaults() {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_default->bind(); _default->bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::lightmap); StateManager::instance().setActiveTextureUnit(TextureUnits::lightmap);
_default->bind(); _default->bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::envmap); StateManager::instance().setActiveTextureUnit(TextureUnits::environmentMap);
_defaultCubemap->bind(); _defaultCubemap->bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::bumpmap); StateManager::instance().setActiveTextureUnit(TextureUnits::bumpMap);
_default->bind(); _default->bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::bloom); StateManager::instance().setActiveTextureUnit(TextureUnits::bloom);
@ -91,7 +91,7 @@ void Textures::bindDefaults() {
StateManager::instance().setActiveTextureUnit(TextureUnits::shadowMap); StateManager::instance().setActiveTextureUnit(TextureUnits::shadowMap);
_default->bind(); _default->bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::cubeShadowMap); StateManager::instance().setActiveTextureUnit(TextureUnits::shadowMapCube);
_defaultCubemap->bind(); _defaultCubemap->bind();
} }

View file

@ -89,16 +89,16 @@ struct GraphicsOptions {
}; };
struct TextureUnits { struct TextureUnits {
static constexpr int diffuse { 0 }; static constexpr int diffuseMap { 0 };
static constexpr int lightmap { 1 }; static constexpr int lightmap { 1 };
static constexpr int envmap { 2 }; static constexpr int environmentMap { 2 };
static constexpr int bumpmap { 3 }; static constexpr int bumpMap { 3 };
static constexpr int bloom { 4 }; static constexpr int bloom { 4 };
static constexpr int irradianceMap { 5 }; static constexpr int irradianceMap { 5 };
static constexpr int prefilterMap { 6 }; static constexpr int prefilterMap { 6 };
static constexpr int brdfLookup { 7 }; static constexpr int brdfLookup { 7 };
static constexpr int shadowMap { 8 }; static constexpr int shadowMap { 8 };
static constexpr int cubeShadowMap { 9 }; static constexpr int shadowMapCube { 9 };
}; };
class IEventHandler { class IEventHandler {

View file

@ -264,7 +264,7 @@ void Control::drawBorder(const Border &border, const glm::ivec2 &offset, const g
Shaders::instance().activate(ShaderProgram::SimpleGUI, uniforms); Shaders::instance().activate(ShaderProgram::SimpleGUI, uniforms);
} }
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
border.fill->bind(); border.fill->bind();
bool additive = border.fill->isAdditive(); bool additive = border.fill->isAdditive();
@ -280,7 +280,7 @@ void Control::drawBorder(const Border &border, const glm::ivec2 &offset, const g
int width = size.x - 2 * border.dimension; int width = size.x - 2 * border.dimension;
int height = size.y - 2 * border.dimension; int height = size.y - 2 * border.dimension;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
border.edge->bind(); border.edge->bind();
if (height > 0.0f) { if (height > 0.0f) {
@ -357,7 +357,7 @@ void Control::drawBorder(const Border &border, const glm::ivec2 &offset, const g
int x = _extent.left + offset.x; int x = _extent.left + offset.x;
int y = _extent.top + offset.y; int y = _extent.top + offset.y;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
border.corner->bind(); border.corner->bind();
// Top left corner // Top left corner

View file

@ -85,7 +85,7 @@ void ImageButton::drawIcon(
} }
if (iconFrame) { if (iconFrame) {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
iconFrame->bind(); iconFrame->bind();
glm::mat4 transform(1.0f); glm::mat4 transform(1.0f);
@ -102,7 +102,7 @@ void ImageButton::drawIcon(
} }
if (iconTexture) { if (iconTexture) {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
iconTexture->bind(); iconTexture->bind();
glm::mat4 transform(1.0f); glm::mat4 transform(1.0f);

View file

@ -47,7 +47,7 @@ void ProgressBar::load(const GffStruct &gffs) {
void ProgressBar::draw(const glm::ivec2 &offset, const vector<string> &text) { void ProgressBar::draw(const glm::ivec2 &offset, const vector<string> &text) {
if (_value == 0 || !_progress.fill) return; if (_value == 0 || !_progress.fill) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_progress.fill->bind(); _progress.fill->bind();
float w = _extent.width * _value / 100.0f; float w = _extent.width * _value / 100.0f;

View file

@ -60,7 +60,7 @@ void ScrollBar::draw(const glm::ivec2 &offset, const vector<string> &text) {
void ScrollBar::drawThumb(const glm::ivec2 &offset) { void ScrollBar::drawThumb(const glm::ivec2 &offset) {
if (!_thumb.image || _state.numVisible >= _state.count) return; if (!_thumb.image || _state.numVisible >= _state.count) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_thumb.image->bind(); _thumb.image->bind();
ShaderUniforms uniforms; ShaderUniforms uniforms;
@ -107,7 +107,7 @@ void ScrollBar::drawArrows(const glm::ivec2 &offset) {
bool canScrollDown = _state.count - _state.offset > _state.numVisible; bool canScrollDown = _state.count - _state.offset > _state.numVisible;
if (!canScrollUp && !canScrollDown) return; if (!canScrollUp && !canScrollDown) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_dir.image->bind(); _dir.image->bind();
if (canScrollUp) { if (canScrollUp) {

View file

@ -250,7 +250,7 @@ void GUI::draw3D() {
} }
void GUI::drawBackground() { void GUI::drawBackground() {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_background->bind(); _background->bind();
glm::mat4 transform(1.0f); glm::mat4 transform(1.0f);

View file

@ -177,7 +177,7 @@ void EmitterSceneNode::drawParticles(const vector<Particle *> &particles) {
Shaders::instance().activate(ShaderProgram::ParticleParticle, uniforms); Shaders::instance().activate(ShaderProgram::ParticleParticle, uniforms);
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
texture->bind(); texture->bind();
bool lighten = emitter->blendMode == ModelNode::Emitter::BlendMode::Lighten; bool lighten = emitter->blendMode == ModelNode::Emitter::BlendMode::Lighten;

View file

@ -53,7 +53,7 @@ void GrassSceneNode::addCluster(Cluster cluster) {
} }
void GrassSceneNode::drawClusters(const vector<Cluster> &clusters) { void GrassSceneNode::drawClusters(const vector<Cluster> &clusters) {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_texture->bind(); _texture->bind();
ShaderUniforms uniforms(_sceneGraph->uniformsPrototype()); ShaderUniforms uniforms(_sceneGraph->uniformsPrototype());

View file

@ -56,7 +56,7 @@ void LightSceneNode::drawLensFlares(const ModelNode::LensFlare &flare) {
shared_ptr<CameraSceneNode> camera(_sceneGraph->activeCamera()); shared_ptr<CameraSceneNode> camera(_sceneGraph->activeCamera());
if (!camera) return; if (!camera) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
flare.texture->bind(); flare.texture->bind();
glm::vec4 lightPos(_absTransform[3]); glm::vec4 lightPos(_absTransform[3]);

View file

@ -371,7 +371,7 @@ void MeshSceneNode::drawSingle(bool shadowPass) {
// Setup textures // Setup textures
if (_textures.diffuse) { if (_textures.diffuse) {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_textures.diffuse->bind(); _textures.diffuse->bind();
additive = _textures.diffuse->isAdditive(); additive = _textures.diffuse->isAdditive();
} }
@ -380,7 +380,7 @@ void MeshSceneNode::drawSingle(bool shadowPass) {
_textures.lightmap->bind(); _textures.lightmap->bind();
} }
if (_textures.envmap) { if (_textures.envmap) {
StateManager::instance().setActiveTextureUnit(TextureUnits::envmap); StateManager::instance().setActiveTextureUnit(TextureUnits::environmentMap);
_textures.envmap->bind(); _textures.envmap->bind();
PBRIBL::Derived derived; PBRIBL::Derived derived;
@ -394,7 +394,7 @@ void MeshSceneNode::drawSingle(bool shadowPass) {
} }
} }
if (_textures.bumpmap) { if (_textures.bumpmap) {
StateManager::instance().setActiveTextureUnit(TextureUnits::bumpmap); StateManager::instance().setActiveTextureUnit(TextureUnits::bumpMap);
_textures.bumpmap->bind(); _textures.bumpmap->bind();
} }

View file

@ -85,7 +85,7 @@ void ControlRenderPipeline::render(const glm::ivec2 &offset) {
// Render control // Render control
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_geometryColor->bind(); _geometryColor->bind();
int viewport[4]; int viewport[4];

View file

@ -255,7 +255,7 @@ void WorldRenderPipeline::drawGeometry() {
StateManager::instance().setActiveTextureUnit(TextureUnits::shadowMap); StateManager::instance().setActiveTextureUnit(TextureUnits::shadowMap);
_shadowsDepth->bind(); _shadowsDepth->bind();
} else { } else {
StateManager::instance().setActiveTextureUnit(TextureUnits::cubeShadowMap); StateManager::instance().setActiveTextureUnit(TextureUnits::shadowMapCube);
_cubeShadowsDepth->bind(); _cubeShadowsDepth->bind();
} }
} }
@ -279,7 +279,7 @@ void WorldRenderPipeline::applyHorizontalBlur() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_geometryColor2->bind(); _geometryColor2->bind();
ShaderUniforms uniforms; ShaderUniforms uniforms;
@ -302,7 +302,7 @@ void WorldRenderPipeline::applyVerticalBlur() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_horizontalBlurColor->bind(); _horizontalBlurColor->bind();
ShaderUniforms uniforms; ShaderUniforms uniforms;
@ -320,7 +320,7 @@ void WorldRenderPipeline::applyVerticalBlur() {
} }
void WorldRenderPipeline::drawResult() { void WorldRenderPipeline::drawResult() {
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_geometryColor1->bind(); _geometryColor1->bind();
StateManager::instance().setActiveTextureUnit(TextureUnits::bloom); StateManager::instance().setActiveTextureUnit(TextureUnits::bloom);

View file

@ -74,7 +74,7 @@ void Video::updateFrame(float dt) {
void Video::updateFrameTexture() { void Video::updateFrameTexture() {
if (!_frame) return; if (!_frame) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_texture->bind(); _texture->bind();
_texture->setPixels(_width, _height, PixelFormat::RGB, _frame->pixels); _texture->setPixels(_width, _height, PixelFormat::RGB, _frame->pixels);
} }
@ -82,7 +82,7 @@ void Video::updateFrameTexture() {
void Video::draw() { void Video::draw() {
if (!_inited) return; if (!_inited) return;
StateManager::instance().setActiveTextureUnit(TextureUnits::diffuse); StateManager::instance().setActiveTextureUnit(TextureUnits::diffuseMap);
_texture->bind(); _texture->bind();
ShaderUniforms uniforms; ShaderUniforms uniforms;