diff --git a/build/Encode Shaders.bat b/build/Encode Shaders.bat new file mode 100644 index 000000000..b429824ed --- /dev/null +++ b/build/Encode Shaders.bat @@ -0,0 +1,2 @@ +premake4 encodeshaders +pause \ No newline at end of file diff --git a/build/scripts/actions/encodeshaders.lua b/build/scripts/actions/encodeshaders.lua new file mode 100644 index 000000000..e933d45e1 --- /dev/null +++ b/build/scripts/actions/encodeshaders.lua @@ -0,0 +1,42 @@ +function encodeShaders() + local targets = os.matchdirs("../src/Nazara/Renderer/Shaders/*") + for k, targetPath in pairs(targets) do + local shaders = os.matchfiles(targetPath .. "/*") + for k, filePath in pairs(shaders) do + local ext = filePath:sub(-5) + if (ext == ".frag" or ext == ".geom" or ext == ".vert") then + local shader, err = io.open(filePath, "rb") + if (not shader) then + error("Failed to read shader file: " .. err) + end + + local header, err = io.open(filePath .. ".h", "w+") + if (not header) then + error("Failed to create header file: " .. err) + end + + local str = shader:read(64) + repeat + local l = str:len() + for i = 1, l do + local byte = str:sub(i, i):byte() + if (byte >= 128) then + byte = byte - 256 + end + header:write(string.format("%d,", byte)) + end + str = shader:read(64) + until (not str) + + header:close() + end + end + end +end + +newaction +{ + trigger = "encodeshaders", + description = "Generate a includable header version of shaders", + execute = encodeShaders +} diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 2e38c68df..ede7fa8e5 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -157,9 +157,9 @@ enum nzShaderFlags { nzShaderFlags_None = 0, - //nzShaderFlags_Deferred = 0x1, - nzShaderFlags_FlipUVs = 0x1, - nzShaderFlags_Instancing = 0x2, + nzShaderFlags_Deferred = 0x1, + nzShaderFlags_FlipUVs = 0x2, + nzShaderFlags_Instancing = 0x4, nzShaderFlags_Max = nzShaderFlags_Instancing*2-1 }; diff --git a/src/Nazara/Renderer/ShaderProgramManager.cpp b/src/Nazara/Renderer/ShaderProgramManager.cpp index 37b17852a..84ee65987 100644 --- a/src/Nazara/Renderer/ShaderProgramManager.cpp +++ b/src/Nazara/Renderer/ShaderProgramManager.cpp @@ -85,10 +85,6 @@ namespace std::unordered_map s_programs; NzString s_cacheDirectory("shaderCache"); - NzString s_inKW; - NzString s_outKW; - NzString s_fragmentColorKW; - NzString s_textureLookupKW; bool s_cacheEnabled = false; bool s_earlyFragmentTest; bool s_glsl140; @@ -163,7 +159,9 @@ const NzShaderProgram* NzShaderProgramManager::Get(const NzShaderProgramManagerP else program.reset(GenerateProgram(params)); - if (!program) + if (program) + s_programs[params] = program.get(); + else { NazaraWarning("Failed to build program, using default one..."); @@ -191,507 +189,171 @@ NzString NzShaderProgramManager::BuildFragmentCode(const NzShaderProgramManagerP #endif NzString source; - source.Reserve(2048); // Le shader peut faire plus, mais cela évite déjà beaucoup de petites allocations /********************Header********************/ + source.Reserve(14 + 24 + 1); source += "#version "; source += NzString::Number(s_glslVersion); source += "\n\n"; + source += "#define FLAG_DEFERRED "; + source += (params.flags & nzShaderFlags_Deferred) ? '1' : '0'; + source += '\n'; + + source += '\n'; + switch (params.target) { case nzShaderTarget_FullscreenQuad: { + char coreFragmentShader[] = { + #include + }; + + char compatibilityFragmentShader[] = { + #include + }; + + const char* shaderSource = (s_glsl140) ? coreFragmentShader : compatibilityFragmentShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreFragmentShader) : sizeof(compatibilityFragmentShader); + + + source.Reserve(source.GetCapacity() + 34 + 24 + 21 + 26 + 1 + shaderSourceSize); + // "discard" ne s'entend pas bien avec les early fragment tests if (s_earlyFragmentTest && !params.fullscreenQuad.alphaMapping) - source += "layout(early_fragment_tests) in;" "\n\n"; + source += "layout(early_fragment_tests) in;\n\n"; - /********************Entrant********************/ - if (params.fullscreenQuad.alphaMapping || params.fullscreenQuad.diffuseMapping) - source += s_inKW + " vec2 vTexCoord;" "\n\n"; + source += "#define ALPHA_MAPPING "; + source += (params.fullscreenQuad.alphaMapping) ? '1' : '0'; + source += '\n'; - /********************Sortant********************/ - if (s_glsl140) - source += "out vec4 RenderTarget0;" "\n\n"; + source += "#define ALPHA_TEST "; + source += (params.fullscreenQuad.alphaTest) ? '1' : '0'; + source += '\n'; - /********************Uniformes********************/ - if (params.fullscreenQuad.alphaMapping) - source += "uniform sampler2D MaterialAlphaMap;" "\n"; - - if (params.fullscreenQuad.alphaTest) - source += "uniform float MaterialAlphaThreshold;" "\n"; - - source += "uniform vec4 MaterialDiffuse;" "\n"; - - if (params.fullscreenQuad.diffuseMapping) - source += "uniform sampler2D MaterialDiffuseMap;" "\n"; + source += "#define DIFFUSE_MAPPING "; + source += (params.fullscreenQuad.diffuseMapping) ? '1' : '0'; + source += '\n'; source += '\n'; - /********************Fonctions********************/ - source += "void main()" "\n" - "{" "\n"; - - source += "\t" "vec4 fragmentColor = MaterialDiffuse"; - if (params.fullscreenQuad.diffuseMapping) - source += '*' + s_textureLookupKW + "(MaterialDiffuseMap, vTexCoord)"; - - source += ";" "\n"; - - if (params.fullscreenQuad.alphaMapping) - source += "fragmentColor.a *= " + s_textureLookupKW + "(MaterialAlphaMap, vTexCoord).r"; - - source += ";" "\n"; - - if (params.fullscreenQuad.alphaMapping) - { - source += "\t" "if (fragmentColor.a < MaterialAlphaThreshold)" "\n" - "\t\t" "discard;" "\n"; - } - - source += "\t" + s_fragmentColorKW + " = fragmentColor;" "\n" - "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } case nzShaderTarget_Model: { - //bool parallaxMapping = (params.model.lighting && params.model.parallaxMapping); - bool uvMapping = (params.model.alphaMapping || params.model.diffuseMapping || params.model.normalMapping || params.model.specularMapping); + char coreFragmentShader[] = { + #include + }; + + char compatibilityFragmentShader[] = { + #include + }; + + const char* shaderSource = (s_glsl140) ? coreFragmentShader : compatibilityFragmentShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreFragmentShader) : sizeof(compatibilityFragmentShader); + + source.Reserve(source.GetCapacity() + 34 + 24 + 21 + 26 + 27 + 19 + 25 + 27 + 27 + 1 + shaderSourceSize); - // "discard" ne s'entend pas bien avec les early fragment tests if (s_earlyFragmentTest && !params.model.alphaMapping) - source += "layout(early_fragment_tests) in;" "\n\n"; + source += "layout(early_fragment_tests) in;\n\n"; - if (params.model.lighting) - { - source += "#define LIGHT_DIRECTIONAL 0" "\n" - "#define LIGHT_POINT 1" "\n" - "#define LIGHT_SPOT 2" "\n\n"; - } + source += "#define ALPHA_MAPPING "; + source += (params.model.alphaMapping) ? '1' : '0'; + source += '\n'; - /********************Entrant********************/ - if (params.model.lighting) - { - if (params.model.normalMapping) - source += s_inKW + " mat3 vLightToWorld;" "\n"; - else - source += s_inKW + " vec3 vNormal;" "\n"; - } + source += "#define ALPHA_TEST "; + source += (params.model.alphaTest) ? '1' : '0'; + source += '\n'; - if (uvMapping) - source += s_inKW + " vec2 vTexCoord;" "\n"; + source += "#define DIFFUSE_MAPPING "; + source += (params.model.diffuseMapping) ? '1' : '0'; + source += '\n'; - if (params.model.lighting) - source += s_inKW + " vec3 vWorldPos;" "\n"; + source += "#define EMISSIVE_MAPPING "; + source += (params.model.emissiveMapping) ? '1' : '0'; + source += '\n'; - if (params.model.lighting || uvMapping) - source += '\n'; + source += "#define LIGHTING "; + source += (params.model.lighting) ? '1' : '0'; + source += '\n'; - /********************Sortant********************/ - if (s_glsl140) - source += "out vec4 RenderTarget0;" "\n\n"; + source += "#define NORMAL_MAPPING "; + source += (params.model.normalMapping) ? '1' : '0'; + source += '\n'; - /********************Uniformes********************/ - if (params.model.lighting) - { - source += "struct Light" "\n" - "{" "\n" - "\t" "int type;" "\n" - "\t" "vec4 ambient;" "\n" - "\t" "vec4 diffuse;" "\n" - "\t" "vec4 specular;" "\n\n" + source += "#define PARALLAX_MAPPING "; + source += (params.model.parallaxMapping) ? '1' : '0'; + source += '\n'; - "\t" "vec4 parameters1;" "\n" - "\t" "vec4 parameters2;" "\n" - "\t" "vec2 parameters3;" "\n" - "};" "\n\n" - - "uniform vec3 EyePosition;" "\n" - "uniform Light Lights[3];" "\n" - "uniform vec4 MaterialAmbient;" "\n"; - } - - if (params.model.alphaMapping) - source += "uniform sampler2D MaterialAlphaMap;" "\n"; - - if (params.model.alphaTest) - source += "uniform float MaterialAlphaThreshold;" "\n"; - - source += "uniform vec4 MaterialDiffuse;" "\n"; - - if (params.model.diffuseMapping) - source += "uniform sampler2D MaterialDiffuseMap;" "\n"; - - if (params.model.emissiveMapping) - source += "uniform sampler2D MaterialEmissiveMap;" "\n"; - - if (params.model.lighting) - { - if (params.model.normalMapping) - source += "uniform sampler2D MaterialNormalMap;" "\n"; - - source += "uniform float MaterialShininess;" "\n" - "uniform vec4 MaterialSpecular;" "\n"; - - if (params.model.specularMapping) - source += "uniform sampler2D MaterialSpecularMap;" "\n"; - - source += "uniform vec4 SceneAmbient;" "\n"; - } + source += "#define SPECULAR_MAPPING "; + source += (params.model.specularMapping) ? '1' : '0'; + source += '\n'; source += '\n'; - /********************Fonctions********************/ - source += "void main()" "\n" - "{" "\n"; - - /*if (!parallaxMapping) - {*/ - source += "\t" "vec4 fragmentColor = MaterialDiffuse"; - if (params.model.diffuseMapping) - source += '*' + s_textureLookupKW + "(MaterialDiffuseMap, vTexCoord)"; - - source += ";" "\n"; - //} - - if (params.model.alphaMapping) - { - source += "\t" "fragmentColor.a *= "; - - if (params.model.alphaMapping) - source += s_textureLookupKW + "(MaterialAlphaMap, vTexCoord).r"; - - /*if (parallaxMapping && params.model.diffuseMapping) - source += '*' + s_textureLookupKW + "(MaterialDiffuseMap, vTexCoord).a";*/ - - source += ";" "\n"; - } - - if (params.model.alphaTest) - { - source += "\t" "if (fragmentColor.a < MaterialAlphaThreshold)" "\n" - "\t\t" "discard;" "\n"; - } - - if (params.model.lighting) - { - source += "\t" "vec3 lightColor = vec3(0.0);" "\n"; - - if (params.model.specularMapping) - source += "\t" "vec3 specularColor = vec3(0.0);" "\n"; - - if (params.model.normalMapping) - source += "\t" "vec3 normal = normalize(vLightToWorld * (2.0 * vec3(" + s_textureLookupKW + "(MaterialNormalMap, vTexCoord)) - 1.0));" "\n"; - else - source += "\t" "vec3 normal = normalize(vNormal);" "\n"; - - source += '\n'; - - source += "\t" "if (MaterialShininess > 0.0)" "\n" - "\t" "{" "\n" - "\t\t" "vec3 eyeVec = normalize(EyePosition - vWorldPos);" "\n\n" - - "\t\t" "for (int i = 0; i < 3; ++i)" "\n" - "\t\t" "{" "\n"; - - if (s_glsl140) - { - source += "\t\t\t" "switch (Lights[i].type)" "\n" - "\t\t\t" "{" "\n" - "\t\t\t\t" "case LIGHT_DIRECTIONAL:" "\n"; - } - else // Le GLSL 110 n'a pas d'instruction switch - source += "\t\t\t" "if (Lights[i].type == LIGHT_DIRECTIONAL)" "\n"; - - // Directional Light - source += "\t\t\t\t" "{" "\n" - "\t\t\t\t\t" "vec3 lightDir = normalize(-Lights[i].parameters1.xyz);" "\n" - "\t\t\t\t\t" "lightColor += Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb);" "\n\n" - - "\t\t\t\t\t" "float lambert = max(dot(normal, lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb;" "\n\n" - - "\t\t\t\t\t" "vec3 reflection = reflect(-lightDir, normal);" "\n" - "\t\t\t\t\t" "float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess);" "\n"; - - if (params.model.specularMapping) - source += "\t\t\t\t\t" "specularColor"; - else - source += "\t\t\t\t\t" "lightColor"; - - source += " += specular * Lights[i].specular.rgb * MaterialSpecular.rgb;" "\n"; - - if (s_glsl140) - { - source += "\t\t\t\t\t" "break;" "\n" - "\t\t\t\t" "}" "\n\n" - - "\t\t\t\t" "case LIGHT_POINT:" "\n"; - } - else - source += "\t\t\t" "}" "\n" - "\t\t\t" "else if (Lights[i].type == LIGHT_POINT)" "\n"; - - // Point Light - source += "\t\t\t\t" "{" "\n" - "\t\t\t\t\t" "vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;" "\n\n" - - "\t\t\t\t\t" "float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb);" "\n" - - "\t\t\t\t\t" "lightDir = normalize(lightDir);" "\n" - "\t\t\t\t\t" "float lambert = max(dot(normal, lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb;" "\n\n" - - "\t\t\t\t\t" "vec3 reflection = reflect(-lightDir, normal);" "\n" - "\t\t\t\t\t" "float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess);" "\n"; - - if (params.model.specularMapping) - source += "\t\t\t\t\t" "specularColor"; - else - source += "\t\t\t\t\t" "lightColor"; - - source += " += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb;" "\n"; - - if (s_glsl140) - { - source += "\t\t\t\t\t" "break;" "\n" - "\t\t\t\t" "}" "\n\n" - - "\t\t\t\t" "case LIGHT_SPOT:" "\n"; - } - else - { - source += "\t\t\t" "}" "\n" - "\t\t\t" "else if (Lights[i].type == LIGHT_SPOT)" "\n"; - } - - // Spot Light - source += "\t\t\t\t" "{" "\n" - "\t\t\t\t\t" "vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;" "\n\n" - - "\t\t\t\t\t" "float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*length(lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb);" "\n\n" - - "\t\t\t\t\t" "lightDir = normalize(lightDir);" "\n\n" - - "\t\t\t\t\t" "float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);" "\n" - "\t\t\t\t\t" "float outerAngle = Lights[i].parameters3.y;" "\n" - "\t\t\t\t\t" "float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;" "\n" - "\t\t\t\t\t" "float lambert = max(dot(normal, lightDir), 0.0);" "\n" - "\t\t\t\t\t" "att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb;" "\n\n" - - "\t\t\t\t\t" "vec3 reflection = reflect(-lightDir, normal);" "\n" - "\t\t\t\t\t" "float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess);" "\n"; - - if (params.model.specularMapping) - source += "\t\t\t\t\t" "specularColor"; - else - source += "\t\t\t\t\t" "lightColor"; - - source += " += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb;\n"; - - if (s_glsl140) - { - source += "\t\t\t\t\t" "break;" "\n" - "\t\t\t\t" "}" "\n\n" - "\t\t\t\t" "default:" "\n" - "\t\t\t\t\t" "break;" "\n" - "\t\t\t" "}" "\n"; - } - else - source += "\t\t\t" "}" "\n"; - - source += "\t\t" "}" "\n" - "\t" "}" "\n" - "\t" "else" "\n" - "\t" "{" "\n"; - - source += "\t\t" "for (int i = 0; i < 3; ++i)" "\n" - "\t\t" "{" "\n"; - - if (s_glsl140) - { - source += "\t\t\t" "switch (Lights[i].type)" "\n" - "\t\t\t" "{" "\n" - "\t\t\t\t" "case LIGHT_DIRECTIONAL:" "\n"; - } - else // Le GLSL 110 n'a pas d'instruction switch - source += "\t\t\t" "if (Lights[i].type == LIGHT_DIRECTIONAL)" "\n"; - - // Directional Light - source += "\t\t\t\t" "{" "\n" - "\t\t\t\t\t" "vec3 lightDir = normalize(-Lights[i].parameters1.xyz);" "\n" - "\t\t\t\t\t" "lightColor += Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb);" "\n\n" - - "\t\t\t\t\t" "float lambert = max(dot(normal, lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb;" "\n\n"; - - if (s_glsl140) - { - source += "\t\t\t\t\t" "break;" "\n" - "\t\t\t\t" "}" "\n\n" - - "\t\t\t\t" "case LIGHT_POINT:" "\n"; - } - else - source += "\t\t\t" "}" "\n" - "\t\t\t" "else if (Lights[i].type == LIGHT_POINT)" "\n"; - - // Point Light - source += "\t\t\t\t" "{" "\n" - "\t\t\t\t\t" "vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;" "\n\n" - - "\t\t\t\t\t" "float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb);" "\n" - - "\t\t\t\t\t" "lightDir = normalize(lightDir);" "\n" - "\t\t\t\t\t" "float lambert = max(dot(normal, lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb;" "\n\n"; - - if (s_glsl140) - { - source += "\t\t\t\t\t" "break;" "\n" - "\t\t\t\t" "}" "\n\n" - - "\t\t\t\t" "case LIGHT_SPOT:" "\n"; - } - else - { - source += "\t\t\t" "}" "\n" - "\t\t\t" "else if (Lights[i].type == LIGHT_SPOT)" "\n"; - } - - // Spot Light - source += "\t\t\t\t" "{" "\n" - "\t\t\t\t\t" "vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;" "\n\n" - - "\t\t\t\t\t" "float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*length(lightDir), 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb);" "\n\n" - - "\t\t\t\t\t" "lightDir = normalize(lightDir);" "\n\n" - - "\t\t\t\t\t" "float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);" "\n" - "\t\t\t\t\t" "float outerAngle = Lights[i].parameters3.y;" "\n" - "\t\t\t\t\t" "float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;" "\n" - "\t\t\t\t\t" "float lambert = max(dot(normal, lightDir), 0.0);" "\n" - "\t\t\t\t\t" "att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);" "\n" - "\t\t\t\t\t" "lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb;" "\n\n"; - - if (s_glsl140) - { - source += "\t\t\t\t\t" "break;" "\n" - "\t\t\t\t" "}" "\n\n" - "\t\t\t\t" "default:" "\n" - "\t\t\t\t\t" "break;" "\n" - "\t\t\t" "}" "\n"; - } - else - source += "\t\t\t" "}" "\n"; - - source += "\t\t" "}" "\n" - "\t" "}" "\n\n" - - "\t" "fragmentColor *= vec4(lightColor"; - - if (params.model.specularMapping) - source += "+ specularColor*" + s_textureLookupKW + "(MaterialSpecularMap, vTexCoord).rgb"; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens - - source += ", 1.0);" "\n"; - - if (params.model.emissiveMapping) - { - if (params.model.specularMapping) - source += "\t" "float lightIntensity = dot(lightColor + specularColor, vec3(0.3, 0.59, 0.11));" "\n"; - else - source += "\t" "float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11));" "\n"; - - source += "\t" "vec3 emissionColor = MaterialDiffuse.rgb*" + s_textureLookupKW + "(MaterialEmissiveMap, vTexCoord).rgb;" "\n" - "\t" + s_fragmentColorKW + " = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a);" "\n"; - } - else - source += '\t' + s_fragmentColorKW + " = fragmentColor;" "\n"; - } - else - source += '\t' + s_fragmentColorKW + " = fragmentColor;" "\n"; - - source += "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } case nzShaderTarget_None: { + char coreFragmentShader[] = { + #include + }; + + char compatibilityFragmentShader[] = { + #include + }; + + const char* shaderSource = (s_glsl140) ? coreFragmentShader : compatibilityFragmentShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreFragmentShader) : sizeof(compatibilityFragmentShader); + + source.Reserve(source.GetCapacity() + 34 + shaderSourceSize); + if (s_earlyFragmentTest) - source += "layout(early_fragment_tests) in;" "\n\n"; + source += "layout(early_fragment_tests) in;\n\n"; - /********************Sortant********************/ - if (s_glsl140) - source += "out vec4 RenderTarget0;" "\n\n"; - - /********************Uniformes********************/ - source += "uniform vec4 MaterialDiffuse;" "\n\n"; - - /********************Fonctions********************/ - source += "void main()" "\n" - "{" "\n"; - source += '\t' + s_fragmentColorKW + " = MaterialDiffuse;" "\n"; - source += "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } case nzShaderTarget_Sprite: { + char coreFragmentShader[] = { + #include + }; + + char compatibilityFragmentShader[] = { + #include + }; + + const char* shaderSource = (s_glsl140) ? coreFragmentShader : compatibilityFragmentShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreFragmentShader) : sizeof(compatibilityFragmentShader); + + source.Reserve(source.GetCapacity() + 34 + 24 + 21 + 26 + 1 + shaderSourceSize); + // "discard" ne s'entend pas bien avec les early fragment tests if (s_earlyFragmentTest && !params.sprite.alphaMapping) - source += "layout(early_fragment_tests) in;" "\n\n"; + source += "layout(early_fragment_tests) in;\n\n"; - /********************Entrant********************/ - if (params.sprite.alphaMapping || params.sprite.diffuseMapping) - source += s_inKW + " vec2 vTexCoord;" "\n\n"; + source += "#define ALPHA_MAPPING "; + source += (params.sprite.alphaMapping) ? '1' : '0'; + source += '\n'; - /********************Sortant********************/ - if (s_glsl140) - source += "out vec4 RenderTarget0;" "\n\n"; + source += "#define ALPHA_TEST "; + source += (params.sprite.alphaTest) ? '1' : '0'; + source += '\n'; - /********************Uniformes********************/ - if (params.sprite.alphaMapping) - source += "uniform sampler2D MaterialAlphaMap;" "\n"; - - if (params.sprite.alphaTest) - source += "uniform float MaterialAlphaThreshold;" "\n"; - - source += "uniform vec4 MaterialDiffuse;" "\n"; - - if (params.sprite.diffuseMapping) - source += "uniform sampler2D MaterialDiffuseMap;" "\n"; + source += "#define DIFFUSE_MAPPING "; + source += (params.sprite.diffuseMapping) ? '1' : '0'; + source += '\n'; source += '\n'; - /********************Fonctions********************/ - source += "void main()" "\n" - "{" "\n"; - - source += "\t" "vec4 fragmentColor = MaterialDiffuse"; - if (params.sprite.diffuseMapping) - source += '*' + s_textureLookupKW + "(MaterialDiffuseMap, vTexCoord)"; - - source += ";" "\n"; - - if (params.sprite.alphaMapping) - source += "fragmentColor.a *= " + s_textureLookupKW + "(MaterialAlphaMap, vTexCoord).r"; - - source += ";" "\n"; - - if (params.sprite.alphaMapping) - { - source += "\t" "if (fragmentColor.a < MaterialAlphaThreshold)" "\n" - "\t\t" "discard;" "\n"; - } - - source += "\t" + s_fragmentColorKW + " = fragmentColor;" "\n" - "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } } @@ -710,225 +372,158 @@ NzString NzShaderProgramManager::BuildVertexCode(const NzShaderProgramManagerPar #endif NzString source; - source.Reserve(2048); // Le shader peut faire plus, mais cela évite déjà beaucoup de petites allocations /********************Header********************/ + source.Reserve(14 + 24 + 26 + 1); source += "#version "; source += NzString::Number(s_glslVersion); source += "\n\n"; + source += "#define FLAG_FLIP_UVS "; + source += (params.flags & nzShaderFlags_FlipUVs) ? '1' : '0'; + source += '\n'; + + source += "#define FLAG_INSTANCING "; + source += (params.flags & nzShaderFlags_Instancing) ? '1' : '0'; + source += '\n'; + + source += '\n'; + switch (params.target) { case nzShaderTarget_FullscreenQuad: { - bool uvMapping = (params.fullscreenQuad.alphaMapping || params.fullscreenQuad.diffuseMapping); + char coreVertexShader[] = { + #include + }; - /********************Entrant********************/ - source += s_inKW + " vec2 VertexPosition;" "\n\n"; + char compatibilityVertexShader[] = { + #include + }; - /********************Sortant********************/ - if (uvMapping) - source += s_outKW + " vec2 vTexCoord;" "\n\n"; + const char* shaderSource = (s_glsl140) ? coreVertexShader : compatibilityVertexShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreVertexShader) : sizeof(compatibilityVertexShader); - /********************Code********************/ - source += "void main()" "\n" - "{" "\n" - "\t" "gl_Position = vec4(VertexPosition, 0.0, 1.0);" "\n"; + source.Reserve(source.GetCapacity() + 24 + 21 + 26 + 1 + shaderSourceSize); - if (uvMapping) - { - if (params.flags & nzShaderFlags_FlipUVs) - source += "\t" "vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, 0.5 - VertexPosition.y*0.5;" "\n"; - else - source += "\t" "vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, (VertexPosition.y + 1.0)*0.5);" "\n"; - } + source += "#define ALPHA_MAPPING "; + source += (params.fullscreenQuad.alphaMapping) ? '1' : '0'; + source += '\n'; - source += "}" "\n"; + source += "#define ALPHA_TEST "; + source += (params.fullscreenQuad.alphaTest) ? '1' : '0'; + source += '\n'; + + source += "#define DIFFUSE_MAPPING "; + source += (params.fullscreenQuad.diffuseMapping) ? '1' : '0'; + source += '\n'; + + source += '\n'; + + source.Append(shaderSource, shaderSourceSize); break; } case nzShaderTarget_Model: { - bool uvMapping = (params.model.diffuseMapping || params.model.normalMapping || params.model.specularMapping); + char coreVertexShader[] = { + #include + }; - /********************Entrant********************/ - if (params.flags & nzShaderFlags_Instancing) - source += s_inKW + " mat4 InstanceData0;" "\n"; + char compatibilityVertexShader[] = { + #include + }; - source += s_inKW + " vec3 VertexPosition;" "\n"; + const char* shaderSource = (s_glsl140) ? coreVertexShader : compatibilityVertexShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreVertexShader) : sizeof(compatibilityVertexShader); - if (params.model.lighting) - { - source += s_inKW + " vec3 VertexNormal;" "\n"; - source += s_inKW + " vec3 VertexTangent;" "\n"; - } + source.Reserve(source.GetCapacity() + 24 + 21 + 26 + 27 + 19 + 25 + 27 + 27 + 1 + shaderSourceSize); - if (uvMapping) - source += s_inKW + " vec2 VertexTexCoord;" "\n"; + source += "#define ALPHA_MAPPING "; + source += (params.model.alphaMapping) ? '1' : '0'; + source += '\n'; + + source += "#define ALPHA_TEST "; + source += (params.model.alphaTest) ? '1' : '0'; + source += '\n'; + + source += "#define DIFFUSE_MAPPING "; + source += (params.model.diffuseMapping) ? '1' : '0'; + source += '\n'; + + source += "#define EMISSIVE_MAPPING "; + source += (params.model.emissiveMapping) ? '1' : '0'; + source += '\n'; + + source += "#define LIGHTING "; + source += (params.model.lighting) ? '1' : '0'; + source += '\n'; + + source += "#define NORMAL_MAPPING "; + source += (params.model.normalMapping) ? '1' : '0'; + source += '\n'; + + source += "#define PARALLAX_MAPPING "; + source += (params.model.parallaxMapping) ? '1' : '0'; + source += '\n'; + + source += "#define SPECULAR_MAPPING "; + source += (params.model.specularMapping) ? '1' : '0'; + source += '\n'; source += '\n'; - /********************Sortant********************/ - if (params.model.lighting) - { - if (params.model.normalMapping) - source += s_outKW + " mat3 vLightToWorld;" "\n"; - else - source += s_outKW + " vec3 vNormal;" "\n"; - } - - if (uvMapping) - source += s_outKW + " vec2 vTexCoord;" "\n"; - - if (params.model.lighting) - source += s_outKW + " vec3 vWorldPos;" "\n"; - - if (params.model.lighting || uvMapping) - source += '\n'; - - /********************Uniformes********************/ - if (params.flags & nzShaderFlags_Instancing) - source += "uniform mat4 ViewProjMatrix;" "\n"; - else - { - if (params.model.lighting) - source += "uniform mat4 WorldMatrix;" "\n"; - - source += "uniform mat4 WorldViewProjMatrix;" "\n"; - } - - source += '\n'; - - /********************Code********************/ - source += "void main()" "\n" - "{" "\n"; - - if (params.flags & nzShaderFlags_Instancing) - source += "\t" "gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);" "\n"; - else - source += "\t" "gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);" "\n"; - - if (params.model.lighting) - { - if (params.flags & nzShaderFlags_Instancing) - { - if (s_glsl140) - source += "\t" "mat3 rotationMatrix = mat3(InstanceData0);" "\n"; - else - source += "\t" "mat3 rotationMatrix = mat3(InstanceData0[0].xyz, InstanceData0[1].xyz, InstanceData0[2].xyz);" "\n"; - } - else - { - if (s_glsl140) - source += "\t" "mat3 rotationMatrix = mat3(WorldMatrix);" "\n"; - else - source += "\t" "mat3 rotationMatrix = mat3(WorldMatrix[0].xyz, WorldMatrix[1].xyz, WorldMatrix[2].xyz);" "\n"; - } - - if (params.model.normalMapping) - { - source += "\n" - "\t" "vec3 binormal = cross(VertexNormal, VertexTangent);" "\n" - "\t" "vLightToWorld[0] = normalize(rotationMatrix * VertexTangent);" "\n" - "\t" "vLightToWorld[1] = normalize(rotationMatrix * binormal);" "\n" - "\t" "vLightToWorld[2] = normalize(rotationMatrix * VertexNormal);" "\n\n"; - } - else - source += "\t" "vNormal = normalize(rotationMatrix * VertexNormal);" "\n"; - } - - if (uvMapping) - { - if (params.flags & nzShaderFlags_FlipUVs) - source += "\t" "vTexCoord = vec2(VertexTexCoord.x, 1.0 - VertexTexCoord.y);" "\n"; - else - source += "\t" "vTexCoord = VertexTexCoord;" "\n"; - } - - if (params.model.lighting) - { - if (params.flags & nzShaderFlags_Instancing) - source += "\t" "vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0));" "\n"; - else - source += "\t" "vWorldPos = vec3(WorldMatrix * vec4(VertexPosition, 1.0));" "\n"; - } - - source += "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } case nzShaderTarget_None: { - /********************Entrant********************/ - if (params.flags & nzShaderFlags_Instancing) - source += s_inKW + " mat4 InstanceData0;" "\n"; + char coreVertexShader[] = { + #include + }; - source += s_inKW + " vec3 VertexPosition;" "\n\n"; + char compatibilityVertexShader[] = { + #include + }; - /********************Uniformes********************/ - if (params.flags & nzShaderFlags_Instancing) - source += "uniform mat4 ViewProjMatrix;" "\n\n"; - else - source += "uniform mat4 WorldViewProjMatrix;" "\n\n"; + const char* shaderSource = (s_glsl140) ? coreVertexShader : compatibilityVertexShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreVertexShader) : sizeof(compatibilityVertexShader); - /********************Code********************/ - source += "void main()" "\n" - "{" "\n"; - - if (params.flags & nzShaderFlags_Instancing) - source += "\t" "gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);" "\n"; - else - source += "\t" "gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);" "\n"; - - source += "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } case nzShaderTarget_Sprite: { - bool uvMapping = (params.fullscreenQuad.alphaMapping || params.fullscreenQuad.diffuseMapping); + char coreVertexShader[] = { + #include + }; - /********************Entrant********************/ - if (params.flags & nzShaderFlags_Instancing) - source += s_inKW + " mat4 InstanceData0;" "\n"; + char compatibilityVertexShader[] = { + #include + }; - source += s_inKW + " vec3 VertexPosition;" "\n"; + const char* shaderSource = (s_glsl140) ? coreVertexShader : compatibilityVertexShader; + unsigned int shaderSourceSize = (s_glsl140) ? sizeof(coreVertexShader) : sizeof(compatibilityVertexShader); - if (uvMapping) - source += s_inKW + " vec2 VertexTexCoord;" "\n"; + source.Reserve(source.GetCapacity() + 24 + 21 + 26 + 1 + shaderSourceSize); + + source += "#define ALPHA_MAPPING "; + source += (params.fullscreenQuad.alphaMapping) ? '1' : '0'; + source += '\n'; + + source += "#define ALPHA_TEST "; + source += (params.fullscreenQuad.alphaTest) ? '1' : '0'; + source += '\n'; + + source += "#define DIFFUSE_MAPPING "; + source += (params.fullscreenQuad.diffuseMapping) ? '1' : '0'; + source += '\n'; source += '\n'; - /********************Sortant********************/ - if (uvMapping) - source += s_outKW + " vec2 vTexCoord;" "\n\n"; - - /********************Uniformes********************/ - if (params.flags & nzShaderFlags_Instancing) - source += "uniform mat4 ViewProjMatrix;" "\n"; - else - source += "uniform mat4 WorldViewProjMatrix;" "\n"; - - source += '\n'; - - /********************Code********************/ - source += "void main()" "\n" - "{" "\n"; - - if (params.flags & nzShaderFlags_Instancing) - source += "\t" "gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);" "\n"; - else - source += "\t" "gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);" "\n"; - - if (uvMapping) - { - if (params.flags & nzShaderFlags_FlipUVs) - source += "\t" "vTexCoord = vec2(VertexTexCoord.x, 1.0 - VertexTexCoord.y);" "\n"; - else - source += "\t" "vTexCoord = VertexTexCoord;" "\n"; - } - - source += "}" "\n"; + source.Append(shaderSource, shaderSourceSize); break; } } @@ -948,7 +543,6 @@ NzShaderProgram* NzShaderProgramManager::GenerateProgram(const NzShaderProgramMa } NzString fragmentSource = BuildFragmentCode(params); - NazaraDebug("Fragment shader source:\n" + fragmentSource); if (!program->LoadShader(nzShaderType_Fragment, fragmentSource)) { NazaraError("Failed to load fragment shader: " + program->GetLog()); @@ -957,7 +551,6 @@ NzShaderProgram* NzShaderProgramManager::GenerateProgram(const NzShaderProgramMa } NzString vertexSource = BuildVertexCode(params); - NazaraDebug("Vertex shader source:\n" + vertexSource); if (!program->LoadShader(nzShaderType_Vertex, vertexSource)) { NazaraError("Failed to load vertex shader: " + program->GetLog()); @@ -980,11 +573,6 @@ bool NzShaderProgramManager::Initialize() s_earlyFragmentTest = (s_glslVersion >= 420 || NzOpenGL::IsSupported(nzOpenGLExtension_Shader_ImageLoadStore)); s_glsl140 = (s_glslVersion >= 140); - s_fragmentColorKW = (s_glsl140) ? "RenderTarget0" : "gl_FragColor"; - s_inKW = (s_glsl140) ? "in" : "varying"; - s_outKW = (s_glsl140) ? "out" : "varying"; - s_textureLookupKW = (s_glsl140) ? "texture" : "texture2D"; - NzShaderProgramManagerParams params; params.target = nzShaderTarget_None; for (unsigned int i = 0; i <= nzShaderFlags_Max; ++i) @@ -1056,8 +644,4 @@ bool NzShaderProgramManager::Initialize() void NzShaderProgramManager::Uninitialize() { s_programs.clear(); - s_fragmentColorKW.Clear(false); - s_inKW.Clear(false); - s_outKW.Clear(false); - s_textureLookupKW.Clear(false); } diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.frag b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.frag new file mode 100644 index 000000000..669caee77 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.frag @@ -0,0 +1,32 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +varying vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + vec4 fragmentColor = MaterialDiffuse; +#if DIFFUSE_MAPPING + fragmentColor *= texture2D(MaterialDiffuseMap, vTexCoord); +#endif + +#if ALPHA_MAPPING + fragmentColor.a *= texture2D(MaterialAlphaMap, vTexCoord).r; +#endif + +#if ALPHA_TEST + if (fragmentColor.a < MaterialAlphaThreshold) + discard; +#endif + + gl_FragColor = fragmentColor; +} \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.frag.h b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.frag.h new file mode 100644 index 000000000..abcf53df6 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.frag.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,35,101,110,100,105,102,10,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.vert b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.vert new file mode 100644 index 000000000..1ebe209a4 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.vert @@ -0,0 +1,29 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +varying vec2 VertexPosition; + +/********************Sortant********************/ +varying vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + gl_Position = vec4(VertexPosition, 0.0, 1.0); + +#if ALPHA_MAPPING || DIFFUSE_MAPPING + #if FLAG_FLIP_UVS + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, 0.5 - VertexPosition.y*0.5; + #else + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, (VertexPosition.y + 1.0)*0.5); + #endif // FLAG_FLIP_UVS +#endif +} diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.vert.h b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.vert.h new file mode 100644 index 000000000..183242f5e --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/compatibility.vert.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,48,46,48,44,32,49,46,48,41,59,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,124,124,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,35,105,102,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,48,46,53,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,48,46,53,59,10,9,35,101,108,115,101,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,32,43,32,49,46,48,41,42,48,46,53,41,59,10,9,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/core.frag b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.frag new file mode 100644 index 000000000..7d959c916 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.frag @@ -0,0 +1,35 @@ +/********************Entrant********************/ +in vec2 vTexCoord; + +/********************Sortant********************/ +out vec4 RenderTarget0; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + vec4 fragmentColor = MaterialDiffuse; +#if DIFFUSE_MAPPING + fragmentColor *= texture(MaterialDiffuseMap, vTexCoord); +#endif + +#if ALPHA_MAPPING + fragmentColor.a *= texture(MaterialAlphaMap, vTexCoord).r; +#endif + +#if ALPHA_TEST + if (fragmentColor.a < MaterialAlphaThreshold) + discard; +#endif + +#if FLAG_DEFERRED + RenderTarget0 = vec4(fragmentColor.rgb, 0.0); +#else + RenderTarget0 = fragmentColor; +#endif +} \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/core.frag.h b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.frag.h new file mode 100644 index 000000000..57f545d84 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.frag.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,10,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,35,101,110,100,105,102,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/core.vert b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.vert new file mode 100644 index 000000000..b86136ef2 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.vert @@ -0,0 +1,29 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +in vec2 VertexPosition; + +/********************Sortant********************/ +out vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + gl_Position = vec4(VertexPosition, 0.0, 1.0); + +#if ALPHA_MAPPING || DIFFUSE_MAPPING + #if FLAG_FLIP_UVS + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, 0.5 - VertexPosition.y*0.5; + #else + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, (VertexPosition.y + 1.0)*0.5); + #endif // FLAG_FLIP_UVS +#endif +} diff --git a/src/Nazara/Renderer/Shaders/FullscreenQuad/core.vert.h b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.vert.h new file mode 100644 index 000000000..764b9629b --- /dev/null +++ b/src/Nazara/Renderer/Shaders/FullscreenQuad/core.vert.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,48,46,48,44,32,49,46,48,41,59,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,124,124,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,35,105,102,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,48,46,53,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,48,46,53,59,10,9,35,101,108,115,101,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,32,43,32,49,46,48,41,42,48,46,53,41,59,10,9,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Model/compatibility.frag b/src/Nazara/Renderer/Shaders/Model/compatibility.frag new file mode 100644 index 000000000..f88818fdb --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/compatibility.frag @@ -0,0 +1,225 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +#define LIGHT_DIRECTIONAL 0 +#define LIGHT_POINT 1 +#define LIGHT_SPOT 2 + +/********************Entrant********************/ +varying mat3 vLightToWorld; +varying vec3 vNormal; +varying vec2 vTexCoord; +varying vec3 vWorldPos; + +/********************Uniformes********************/ +struct Light +{ + int type; + vec4 ambient; + vec4 diffuse; + vec4 specular; + + vec4 parameters1; + vec4 parameters2; + vec2 parameters3; +}; + +uniform vec3 EyePosition; +uniform Light Lights[3]; + +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialAmbient; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; +uniform sampler2D MaterialEmissiveMap; +uniform sampler2D MaterialNormalMap; +uniform float MaterialShininess; +uniform vec4 MaterialSpecular; +uniform sampler2D MaterialSpecularMap; + +uniform vec4 SceneAmbient; + +/********************Fonctions********************/ +void main() +{ + vec4 fragmentColor = MaterialDiffuse; +#if DIFFUSE_MAPPING + fragmentColor *= texture2D(MaterialDiffuseMap, vTexCoord); +#endif + +#if ALPHA_MAPPING + fragmentColor.a *= texture2D(MaterialAlphaMap, vTexCoord).r; +#endif + +#if ALPHA_TEST + if (fragmentColor.a < MaterialAlphaThreshold) + discard; +#endif + +#if LIGHTING + vec3 lightColor = vec3(0.0); + + #if SPECULAR_MAPPING + vec3 specularColor = vec3(0.0); + #endif + + #if NORMAL_MAPPING + vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture2D(MaterialNormalMap, vTexCoord)) - 1.0)); + #else + vec3 normal = normalize(vNormal); + #endif + + if (MaterialShininess > 0.0) + { + vec3 eyeVec = normalize(EyePosition - vWorldPos); + + for (int i = 0; i < 3; ++i) + { + if (Lights[i].type == LIGHT_DIRECTIONAL) + { + vec3 lightDir = normalize(-Lights[i].parameters1.xyz); + + // Ambient + lightColor += Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + + // Specular + vec3 reflection = reflect(-lightDir, normal); + float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess); + + #if SPECULAR_MAPPING + specularColor += specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #else + lightColor += specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #endif + } + else if (Lights[i].type == LIGHT_POINT) + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + + // Specular + vec3 reflection = reflect(-lightDir, normal); + float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess); + + #if SPECULAR_MAPPING + specularColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #else + lightColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #endif + } + else if (Lights[i].type == LIGHT_SPOT) + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Modification de l'atténuation + float curAngle = dot(Lights[i].parameters2.xyz, -lightDir); + float outerAngle = Lights[i].parameters3.y; + float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle; + float lambert = max(dot(normal, lightDir), 0.0); + att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0); + + // Diffuse + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + + // Specular + vec3 reflection = reflect(-lightDir, normal); + float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess); + + #if SPECULAR_MAPPING + specularColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #else + lightColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #endif + } + } + } + else + { + for (int i = 0; i < 3; ++i) + { + if (Lights[i].type == LIGHT_DIRECTIONAL) + { + vec3 lightDir = normalize(-Lights[i].parameters1.xyz); + + // Ambient + lightColor += Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + } + else if (Lights[i].type == LIGHT_POINT) + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + } + else if (Lights[i].type == LIGHT_SPOT) + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Modification de l'atténuation + float curAngle = dot(Lights[i].parameters2.xyz, -lightDir); + float outerAngle = Lights[i].parameters3.y; + float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle; + float lambert = max(dot(normal, lightDir), 0.0); + att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0); + + // Diffuse + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + } + } + } + + fragmentColor *= vec4(lightColor, 1.0); + #if SPECULAR_MAPPING + fragmentColor *= vec4(specularColor * texture2D(MaterialSpecularMap, vTexCoord).rgb, 1.0); // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens + #endif + + #if EMISSIVE_MAPPING + #if SPECULAR_MAPPING + float lightIntensity = dot(lightColor + specularColor, vec3(0.3, 0.59, 0.11)); + #else + float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11)); + #endif // SPECULAR_MAPPING + + vec3 emissionColor = MaterialDiffuse.rgb * texture2D(MaterialEmissiveMap, vTexCoord).rgb; + gl_FragColor = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a); + #else + gl_FragColor = fragmentColor; + #endif // EMISSIVE_MAPPING +#else + gl_FragColor = fragmentColor; +#endif // LIGHTING +} diff --git a/src/Nazara/Renderer/Shaders/Model/compatibility.frag.h b/src/Nazara/Renderer/Shaders/Model/compatibility.frag.h new file mode 100644 index 000000000..587e3657c --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/compatibility.frag.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,118,97,114,121,105,110,103,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,118,97,114,121,105,110,103,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,97,109,98,105,101,110,116,59,10,9,118,101,99,52,32,100,105,102,102,117,115,101,59,10,9,118,101,99,52,32,115,112,101,99,117,108,97,114,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,125,59,10,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,32,61,61,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,41,10,9,9,9,123,10,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,41,59,10,9,9,9,9,10,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,10,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,32,61,32,112,111,119,40,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,9,9,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,43,61,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,101,108,115,101,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,101,110,100,105,102,10,9,9,9,125,10,9,9,9,101,108,115,101,32,105,102,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,32,61,61,32,76,73,71,72,84,95,80,79,73,78,84,41,10,9,9,9,123,10,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,10,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,32,61,32,112,111,119,40,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,9,9,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,101,108,115,101,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,101,110,100,105,102,10,9,9,9,125,10,9,9,9,101,108,115,101,32,105,102,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,32,61,61,32,76,73,71,72,84,95,83,80,79,84,41,10,9,9,9,123,10,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,-61,-87,110,117,97,116,105,111,110,10,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,10,9,9,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,10,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,32,61,32,112,111,119,40,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,9,9,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,101,108,115,101,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,101,110,100,105,102,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,32,61,61,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,41,10,9,9,9,123,10,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,41,59,10,9,9,9,9,10,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,9,9,9,125,10,9,9,9,101,108,115,101,32,105,102,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,32,61,61,32,76,73,71,72,84,95,80,79,73,78,84,41,10,9,9,9,123,10,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,9,9,9,125,10,9,9,9,101,108,115,101,32,105,102,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,32,61,61,32,76,73,71,72,84,95,83,80,79,84,41,10,9,9,9,123,10,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,-61,-87,110,117,97,116,105,111,110,10,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,10,9,9,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,9,9,9,125,10,9,9,125,10,9,125,10,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,118,101,99,52,40,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,103,98,44,32,49,46,48,41,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,32,43,32,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,9,9,35,101,108,115,101,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,9,9,35,101,110,100,105,102,32,47,47,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,35,101,108,115,101,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,35,101,108,115,101,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Model/compatibility.vert b/src/Nazara/Renderer/Shaders/Model/compatibility.vert new file mode 100644 index 000000000..930ca3f7b --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/compatibility.vert @@ -0,0 +1,60 @@ +/********************Entrant********************/ +varying mat4 InstanceData0; +varying vec3 VertexPosition; +varying vec3 VertexNormal; +varying vec3 VertexTangent; +varying vec2 VertexTexCoord; + +/********************Sortant********************/ +varying mat3 vLightToWorld; +varying vec3 vNormal; +varying vec2 vTexCoord; +varying vec3 vWorldPos; + +/********************Uniformes********************/ +uniform mat4 ViewProjMatrix; +uniform mat4 WorldMatrix; +uniform mat4 WorldViewProjMatrix; + +/********************Fonctions********************/ +void main() +{ +#if FLAG_INSTANCING + gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0); +#else + gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0); +#endif + +#if LIGHTING + #if FLAG_INSTANCING + mat3 rotationMatrix = mat3(InstanceData0[0].xyz, InstanceData0[1].xyz, InstanceData0[2].xyz); + #else + mat3 rotationMatrix = mat3(WorldMatrix[0].xyz, WorldMatrix[1].xyz, WorldMatrix[2].xyz); + #endif + + #if NORMAL_MAPPING + vec3 binormal = cross(VertexNormal, VertexTangent); + vLightToWorld[0] = normalize(rotationMatrix * VertexTangent); + vLightToWorld[1] = normalize(rotationMatrix * binormal); + vLightToWorld[2] = normalize(rotationMatrix * VertexNormal); + #else + vNormal = normalize(rotationMatrix * VertexNormal); + #endif +#endif + +#if ALPHA_MAPPING || DIFFUSE_MAPPING || EMISSIVE_MAPPING || NORMAL_MAPPING || PARALLAX_MAPPING || SPECULAR_MAPPING + #if FLAG_FLIP_UVS + vTexCoord = vec2(VertexTexCoord.x, 1.0 - VertexTexCoord.y); + #else + vTexCoord = VertexTexCoord; + #endif +#endif + +#if LIGHTING + #if FLAG_INSTANCING + vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0)); + #else + vWorldPos = vec3(WorldMatrix * vec4(VertexPosition, 1.0)); + #endif +#endif +} diff --git a/src/Nazara/Renderer/Shaders/Model/compatibility.vert.h b/src/Nazara/Renderer/Shaders/Model/compatibility.vert.h new file mode 100644 index 000000000..30cfe8aa2 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/compatibility.vert.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,97,114,121,105,110,103,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,118,97,114,121,105,110,103,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,118,97,114,121,105,110,103,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,118,97,114,121,105,110,103,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,118,97,114,121,105,110,103,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,97,114,121,105,110,103,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,118,97,114,121,105,110,103,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,118,97,114,121,105,110,103,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,91,48,93,46,120,121,122,44,32,73,110,115,116,97,110,99,101,68,97,116,97,48,91,49,93,46,120,121,122,44,32,73,110,115,116,97,110,99,101,68,97,116,97,48,91,50,93,46,120,121,122,41,59,13,10,9,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,91,48,93,46,120,121,122,44,32,87,111,114,108,100,77,97,116,114,105,120,91,49,93,46,120,121,122,44,32,87,111,114,108,100,77,97,116,114,105,120,91,50,93,46,120,121,122,41,59,13,10,9,35,101,110,100,105,102,13,10,9,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,124,124,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,32,124,124,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,32,124,124,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,32,124,124,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,32,124,124,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,70,76,73,80,95,85,86,83,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,86,101,114,116,101,120,84,101,120,67,111,111,114,100,46,120,44,32,49,46,48,32,45,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,46,121,41,59,13,10,9,35,101,108,115,101,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Model/core.frag b/src/Nazara/Renderer/Shaders/Model/core.frag new file mode 100644 index 000000000..a445d8ebb --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/core.frag @@ -0,0 +1,284 @@ +#define LIGHT_DIRECTIONAL 0 +#define LIGHT_POINT 1 +#define LIGHT_SPOT 2 + +/********************Entrant********************/ +in mat3 vLightToWorld; +in vec3 vNormal; +in vec2 vTexCoord; +in vec3 vWorldPos; + +/********************Sortant********************/ +out vec4 RenderTarget0; +out vec4 RenderTarget1; +out vec4 RenderTarget2; + +/********************Uniformes********************/ +struct Light +{ + int type; + vec4 ambient; + vec4 diffuse; + vec4 specular; + + vec4 parameters1; + vec4 parameters2; + vec2 parameters3; +}; + +uniform vec3 EyePosition; +uniform Light Lights[3]; + +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialAmbient; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; +uniform sampler2D MaterialEmissiveMap; +uniform sampler2D MaterialNormalMap; +uniform float MaterialShininess; +uniform vec4 MaterialSpecular; +uniform sampler2D MaterialSpecularMap; + +uniform vec4 SceneAmbient; + +/********************Fonctions********************/ +void main() +{ + vec4 fragmentColor = MaterialDiffuse; +#if DIFFUSE_MAPPING + fragmentColor *= texture(MaterialDiffuseMap, vTexCoord); +#endif + +#if FLAG_DEFERRED + #if ALPHA_TEST + #if ALPHA_MAPPING // Inutile de faire de l'alpha-mapping sans alpha-test en Deferred (l'alpha n'est pas sauvegardé) + fragmentColor.a *= texture(MaterialAlphaMap, vTexCoord).r; + #endif + + if (fragmentColor.a < MaterialAlphaThreshold) + discard; + #endif // ALPHA_TEST + + #if LIGHTING + #if NORMAL_MAPPING + vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, vTexCoord)) - 1.0)); + #else + vec3 normal = normalize(vNormal); + #endif // NORMAL_MAPPING + + vec3 specular = MaterialSpecular.rgb; + #if SPECULAR_MAPPING + specular *= texture(MaterialSpecularMap, vTexCoord).rgb; + #endif + + /* + Texture0: Diffuse Color + Flags + Texture1: Normal map + Empty + Texture2: Specular value + Shininess + Texture3: Depth texture + */ + RenderTarget0 = vec4(fragmentColor.rgb, 1.0); + RenderTarget1 = vec4(normal, 0.0); + RenderTarget2 = vec4(specular, MaterialShininess); + #else // LIGHTING + RenderTarget0 = vec4(fragmentColor.rgb, 0.0); + #endif +#else // FLAG_DEFERRED + #if ALPHA_MAPPING + fragmentColor.a *= texture(MaterialAlphaMap, vTexCoord).r; + #endif + + #if ALPHA_TEST + if (fragmentColor.a < MaterialAlphaThreshold) + discard; + #endif + + #if LIGHTING + vec3 lightColor = vec3(0.0); + + #if SPECULAR_MAPPING + vec3 specularColor = vec3(0.0); + #endif + + #if NORMAL_MAPPING + vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, vTexCoord)) - 1.0)); + #else + vec3 normal = normalize(vNormal); + #endif + + if (MaterialShininess > 0.0) + { + vec3 eyeVec = normalize(EyePosition - vWorldPos); + + for (int i = 0; i < 3; ++i) + { + switch (Lights[i].type) + { + case LIGHT_DIRECTIONAL: + { + vec3 lightDir = normalize(-Lights[i].parameters1.xyz); + + // Ambient + lightColor += Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + + // Specular + vec3 reflection = reflect(-lightDir, normal); + float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess); + + #if SPECULAR_MAPPING + specularColor += specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #else + lightColor += specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #endif + break; + } + + case LIGHT_POINT: + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + + // Specular + vec3 reflection = reflect(-lightDir, normal); + float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess); + + #if SPECULAR_MAPPING + specularColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #else + lightColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #endif + break; + } + + case LIGHT_SPOT: + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Modification de l'atténuation + float curAngle = dot(Lights[i].parameters2.xyz, -lightDir); + float outerAngle = Lights[i].parameters3.y; + float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle; + float lambert = max(dot(normal, lightDir), 0.0); + att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0); + + // Diffuse + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + + // Specular + vec3 reflection = reflect(-lightDir, normal); + float specular = pow(max(dot(reflection, eyeVec), 0.0), MaterialShininess); + + #if SPECULAR_MAPPING + specularColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #else + lightColor += att * specular * Lights[i].specular.rgb * MaterialSpecular.rgb; + #endif + break; + } + + default: + break; + } + } + } + else + { + for (int i = 0; i < 3; ++i) + { + switch (Lights[i].type) + { + case LIGHT_DIRECTIONAL: + { + vec3 lightDir = normalize(-Lights[i].parameters1.xyz); + + // Ambient + lightColor += Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + break; + } + + case LIGHT_POINT: + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Diffuse + float lambert = max(dot(normal, lightDir), 0.0); + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + break; + } + + case LIGHT_SPOT: + { + vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos; + float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*length(lightDir), 0.0); + lightDir = normalize(lightDir); + + // Ambient + lightColor += att * Lights[i].ambient.rgb * (MaterialAmbient.rgb + SceneAmbient.rgb); + + // Modification de l'atténuation + float curAngle = dot(Lights[i].parameters2.xyz, -lightDir); + float outerAngle = Lights[i].parameters3.y; + float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle; + float lambert = max(dot(normal, lightDir), 0.0); + att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0); + + // Diffuse + lightColor += att * lambert * Lights[i].diffuse.rgb * MaterialDiffuse.rgb; + break; + } + + default: + break; + } + } + } + + fragmentColor *= vec4(lightColor, 1.0); + #if SPECULAR_MAPPING + fragmentColor *= vec4(specularColor * texture(MaterialSpecularMap, vTexCoord).rgb, 1.0); // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens + #endif + + #if EMISSIVE_MAPPING + #if SPECULAR_MAPPING + float lightIntensity = dot(lightColor + specularColor, vec3(0.3, 0.59, 0.11)); + #else + float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11)); + #endif // SPECULAR_MAPPING + + vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, vTexCoord).rgb; + RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a); + #else + RenderTarget0 = fragmentColor; + #endif // EMISSIVE_MAPPING + #else + RenderTarget0 = fragmentColor; + #endif // LIGHTING +#endif // FLAG_DEFERRED +} diff --git a/src/Nazara/Renderer/Shaders/Model/core.frag.h b/src/Nazara/Renderer/Shaders/Model/core.frag.h new file mode 100644 index 000000000..5373beaaf --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/core.frag.h @@ -0,0 +1 @@ +35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,97,109,98,105,101,110,116,59,10,9,118,101,99,52,32,100,105,102,102,117,115,101,59,10,9,118,101,99,52,32,115,112,101,99,117,108,97,114,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,125,59,10,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,-61,-87,41,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,76,73,71,72,84,73,78,71,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,70,108,97,103,115,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,109,97,112,32,43,32,69,109,112,116,121,10,9,84,101,120,116,117,114,101,50,58,32,83,112,101,99,117,108,97,114,32,118,97,108,117,101,32,43,32,83,104,105,110,105,110,101,115,115,10,9,84,101,120,116,117,114,101,51,58,32,68,101,112,116,104,32,116,101,120,116,117,114,101,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,49,46,48,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,110,111,114,109,97,108,44,32,48,46,48,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,115,112,101,99,117,108,97,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,10,9,35,101,110,100,105,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,76,73,71,72,84,73,78,71,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,9,35,101,110,100,105,102,10,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,41,59,10,9,9,9,9,9,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,32,61,32,112,111,119,40,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,9,9,9,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,43,61,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,101,108,115,101,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,101,110,100,105,102,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,32,61,32,112,111,119,40,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,9,9,9,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,101,108,115,101,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,101,110,100,105,102,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,-61,-87,110,117,97,116,105,111,110,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,10,9,9,9,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,32,61,32,112,111,119,40,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,9,9,9,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,101,108,115,101,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,32,42,32,76,105,103,104,116,115,91,105,93,46,115,112,101,99,117,108,97,114,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,101,110,100,105,102,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,41,59,10,9,9,9,9,9,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,42,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,108,105,103,104,116,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,108,105,103,104,116,68,105,114,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,76,105,103,104,116,115,91,105,93,46,97,109,98,105,101,110,116,46,114,103,98,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,-61,-87,110,117,97,116,105,111,110,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,10,9,9,9,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,108,105,103,104,116,67,111,108,111,114,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,115,91,105,93,46,100,105,102,102,117,115,101,46,114,103,98,32,42,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,59,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,118,101,99,52,40,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,103,98,44,32,49,46,48,41,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,9,35,101,110,100,105,102,10,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,32,43,32,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,9,9,9,35,101,108,115,101,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,9,9,9,35,101,110,100,105,102,32,47,47,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Model/core.vert b/src/Nazara/Renderer/Shaders/Model/core.vert new file mode 100644 index 000000000..eb42c183f --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/core.vert @@ -0,0 +1,60 @@ +/********************Entrant********************/ +in mat4 InstanceData0; +in vec3 VertexPosition; +in vec3 VertexNormal; +in vec3 VertexTangent; +in vec2 VertexTexCoord; + +/********************Sortant********************/ +out mat3 vLightToWorld; +out vec3 vNormal; +out vec2 vTexCoord; +out vec3 vWorldPos; + +/********************Uniformes********************/ +uniform mat4 ViewProjMatrix; +uniform mat4 WorldMatrix; +uniform mat4 WorldViewProjMatrix; + +/********************Fonctions********************/ +void main() +{ +#if FLAG_INSTANCING + gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0); +#else + gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0); +#endif + +#if LIGHTING + #if FLAG_INSTANCING + mat3 rotationMatrix = mat3(InstanceData0); + #else + mat3 rotationMatrix = mat3(WorldMatrix); + #endif + + #if NORMAL_MAPPING + vec3 binormal = cross(VertexNormal, VertexTangent); + vLightToWorld[0] = normalize(rotationMatrix * VertexTangent); + vLightToWorld[1] = normalize(rotationMatrix * binormal); + vLightToWorld[2] = normalize(rotationMatrix * VertexNormal); + #else + vNormal = normalize(rotationMatrix * VertexNormal); + #endif +#endif + +#if ALPHA_MAPPING || DIFFUSE_MAPPING || EMISSIVE_MAPPING || NORMAL_MAPPING || PARALLAX_MAPPING || SPECULAR_MAPPING + #if FLAG_FLIP_UVS + vTexCoord = vec2(VertexTexCoord.x, 1.0 - VertexTexCoord.y); + #else + vTexCoord = VertexTexCoord; + #endif +#endif + +#if LIGHTING + #if FLAG_INSTANCING + vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0)); + #else + vWorldPos = vec3(WorldMatrix * vec4(VertexPosition, 1.0)); + #endif +#endif +} diff --git a/src/Nazara/Renderer/Shaders/Model/core.vert.h b/src/Nazara/Renderer/Shaders/Model/core.vert.h new file mode 100644 index 000000000..5503f5474 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Model/core.vert.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,9,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,9,35,101,110,100,105,102,13,10,9,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,124,124,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,32,124,124,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,32,124,124,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,32,124,124,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,32,124,124,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,70,76,73,80,95,85,86,83,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,86,101,114,116,101,120,84,101,120,67,111,111,114,100,46,120,44,32,49,46,48,32,45,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,46,121,41,59,13,10,9,35,101,108,115,101,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/None/compatibility.frag b/src/Nazara/Renderer/Shaders/None/compatibility.frag new file mode 100644 index 000000000..e3fd29687 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/compatibility.frag @@ -0,0 +1,18 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +varying vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + gl_FragColor = MaterialDiffuse; +} \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/None/compatibility.frag.h b/src/Nazara/Renderer/Shaders/None/compatibility.frag.h new file mode 100644 index 000000000..f9ff3af56 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/compatibility.frag.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/None/compatibility.vert b/src/Nazara/Renderer/Shaders/None/compatibility.vert new file mode 100644 index 000000000..eedf69595 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/compatibility.vert @@ -0,0 +1,17 @@ +/********************Entrant********************/ +varying mat4 InstanceData0; +varying vec3 VertexPosition; + +/********************Uniformes********************/ +uniform mat4 ViewProjMatrix; +uniform mat4 WorldViewProjMatrix; + +/********************Fonctions********************/ +void main() +{ +#if FLAG_INSTANCING + gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0); +#else + gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0); +#endif +} diff --git a/src/Nazara/Renderer/Shaders/None/compatibility.vert.h b/src/Nazara/Renderer/Shaders/None/compatibility.vert.h new file mode 100644 index 000000000..cd576a144 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/compatibility.vert.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,118,97,114,121,105,110,103,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/None/core.frag b/src/Nazara/Renderer/Shaders/None/core.frag new file mode 100644 index 000000000..f8e5e5144 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/core.frag @@ -0,0 +1,21 @@ +/********************Entrant********************/ +in vec2 vTexCoord; + +/********************Sortant********************/ +out vec4 RenderTarget0; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ +#if FLAG_DEFERRED + RenderTarget0 = vec4(MaterialDiffuse.rgb, 0.0); +#else + RenderTarget0 = MaterialDiffuse; +#endif +} \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/None/core.frag.h b/src/Nazara/Renderer/Shaders/None/core.frag.h new file mode 100644 index 000000000..fd115b435 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/core.frag.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,44,32,48,46,48,41,59,10,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,101,110,100,105,102,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/None/core.vert b/src/Nazara/Renderer/Shaders/None/core.vert new file mode 100644 index 000000000..d4b86b187 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/core.vert @@ -0,0 +1,17 @@ +/********************Entrant********************/ +in mat4 InstanceData0; +in vec3 VertexPosition; + +/********************Uniformes********************/ +uniform mat4 ViewProjMatrix; +uniform mat4 WorldViewProjMatrix; + +/********************Fonctions********************/ +void main() +{ +#if FLAG_INSTANCING + gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0); +#else + gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0); +#endif +} diff --git a/src/Nazara/Renderer/Shaders/None/core.vert.h b/src/Nazara/Renderer/Shaders/None/core.vert.h new file mode 100644 index 000000000..bc0c58140 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/None/core.vert.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Sprite/compatibility.frag b/src/Nazara/Renderer/Shaders/Sprite/compatibility.frag new file mode 100644 index 000000000..669caee77 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/compatibility.frag @@ -0,0 +1,32 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +varying vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + vec4 fragmentColor = MaterialDiffuse; +#if DIFFUSE_MAPPING + fragmentColor *= texture2D(MaterialDiffuseMap, vTexCoord); +#endif + +#if ALPHA_MAPPING + fragmentColor.a *= texture2D(MaterialAlphaMap, vTexCoord).r; +#endif + +#if ALPHA_TEST + if (fragmentColor.a < MaterialAlphaThreshold) + discard; +#endif + + gl_FragColor = fragmentColor; +} \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Sprite/compatibility.frag.h b/src/Nazara/Renderer/Shaders/Sprite/compatibility.frag.h new file mode 100644 index 000000000..abcf53df6 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/compatibility.frag.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,35,101,110,100,105,102,10,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Sprite/compatibility.vert b/src/Nazara/Renderer/Shaders/Sprite/compatibility.vert new file mode 100644 index 000000000..1ebe209a4 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/compatibility.vert @@ -0,0 +1,29 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +varying vec2 VertexPosition; + +/********************Sortant********************/ +varying vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + gl_Position = vec4(VertexPosition, 0.0, 1.0); + +#if ALPHA_MAPPING || DIFFUSE_MAPPING + #if FLAG_FLIP_UVS + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, 0.5 - VertexPosition.y*0.5; + #else + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, (VertexPosition.y + 1.0)*0.5); + #endif // FLAG_FLIP_UVS +#endif +} diff --git a/src/Nazara/Renderer/Shaders/Sprite/compatibility.vert.h b/src/Nazara/Renderer/Shaders/Sprite/compatibility.vert.h new file mode 100644 index 000000000..183242f5e --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/compatibility.vert.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,48,46,48,44,32,49,46,48,41,59,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,124,124,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,35,105,102,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,48,46,53,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,48,46,53,59,10,9,35,101,108,115,101,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,32,43,32,49,46,48,41,42,48,46,53,41,59,10,9,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Sprite/core.frag b/src/Nazara/Renderer/Shaders/Sprite/core.frag new file mode 100644 index 000000000..7d959c916 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/core.frag @@ -0,0 +1,35 @@ +/********************Entrant********************/ +in vec2 vTexCoord; + +/********************Sortant********************/ +out vec4 RenderTarget0; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + vec4 fragmentColor = MaterialDiffuse; +#if DIFFUSE_MAPPING + fragmentColor *= texture(MaterialDiffuseMap, vTexCoord); +#endif + +#if ALPHA_MAPPING + fragmentColor.a *= texture(MaterialAlphaMap, vTexCoord).r; +#endif + +#if ALPHA_TEST + if (fragmentColor.a < MaterialAlphaThreshold) + discard; +#endif + +#if FLAG_DEFERRED + RenderTarget0 = vec4(fragmentColor.rgb, 0.0); +#else + RenderTarget0 = fragmentColor; +#endif +} \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Sprite/core.frag.h b/src/Nazara/Renderer/Shaders/Sprite/core.frag.h new file mode 100644 index 000000000..57f545d84 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/core.frag.h @@ -0,0 +1 @@ +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,118,84,101,120,67,111,111,114,100,41,46,114,59,10,35,101,110,100,105,102,10,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,10,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,35,101,110,100,105,102,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shaders/Sprite/core.vert b/src/Nazara/Renderer/Shaders/Sprite/core.vert new file mode 100644 index 000000000..b86136ef2 --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/core.vert @@ -0,0 +1,29 @@ +#if FLAG_DEFERRED + #error Deferred Shading needs core profile +#endif + +/********************Entrant********************/ +in vec2 VertexPosition; + +/********************Sortant********************/ +out vec2 vTexCoord; + +/********************Uniformes********************/ +uniform sampler2D MaterialAlphaMap; +uniform float MaterialAlphaThreshold; +uniform vec4 MaterialDiffuse; +uniform sampler2D MaterialDiffuseMap; + +/********************Fonctions********************/ +void main() +{ + gl_Position = vec4(VertexPosition, 0.0, 1.0); + +#if ALPHA_MAPPING || DIFFUSE_MAPPING + #if FLAG_FLIP_UVS + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, 0.5 - VertexPosition.y*0.5; + #else + vTexCoord = vec2((VertexPosition.x + 1.0)*0.5, (VertexPosition.y + 1.0)*0.5); + #endif // FLAG_FLIP_UVS +#endif +} diff --git a/src/Nazara/Renderer/Shaders/Sprite/core.vert.h b/src/Nazara/Renderer/Shaders/Sprite/core.vert.h new file mode 100644 index 000000000..764b9629b --- /dev/null +++ b/src/Nazara/Renderer/Shaders/Sprite/core.vert.h @@ -0,0 +1 @@ +35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,101,114,114,111,114,32,68,101,102,101,114,114,101,100,32,83,104,97,100,105,110,103,32,110,101,101,100,115,32,99,111,114,101,32,112,114,111,102,105,108,101,10,35,101,110,100,105,102,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,48,46,48,44,32,49,46,48,41,59,10,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,32,124,124,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,35,105,102,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,48,46,53,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,48,46,53,59,10,9,35,101,108,115,101,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,32,43,32,49,46,48,41,42,48,46,53,44,32,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,32,43,32,49,46,48,41,42,48,46,53,41,59,10,9,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,70,76,73,80,95,85,86,83,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file