diff --git a/tutorial/src/main/assets/shaders/basic_lighting/6.multiple_lights.frag b/tutorial/src/main/assets/shaders/basic_lighting/6.multiple_lights.frag deleted file mode 100644 index bd1af29d..00000000 --- a/tutorial/src/main/assets/shaders/basic_lighting/6.multiple_lights.frag +++ /dev/null @@ -1,148 +0,0 @@ -#version 320 es -precision mediump float; -out vec4 FragColor; - -struct Material { - sampler2D diffuse; - sampler2D specular; - float shininess; -}; - -struct DirLight { - vec3 direction; - - vec3 ambient; - vec3 diffuse; - vec3 specular; -}; - -struct PointLight { - vec3 position; - - float constant; - float linear; - float quadratic; - - vec3 ambient; - vec3 diffuse; - vec3 specular; -}; - -struct SpotLight { - vec3 position; - vec3 direction; - float cutOff; - float outerCutOff; - - float constant; - float linear; - float quadratic; - - vec3 ambient; - vec3 diffuse; - vec3 specular; -}; - -#define NR_POINT_LIGHTS 4 - -in vec3 FragPos; -in vec3 Normal; -in vec2 TexCoords; - -uniform vec3 viewPos; -uniform DirLight dirLight; -uniform PointLight pointLights[NR_POINT_LIGHTS]; -uniform SpotLight spotLight; -uniform Material material; - -// function prototypes -vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir); -vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir); -vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir); - -void main() -{ - // properties - vec3 norm = normalize(Normal); - vec3 viewDir = normalize(viewPos - FragPos); - - // == ===================================================== - // Our lighting is set up in 3 phases: directional, point lights and an optional flashlight - // For each phase, a calculate function is defined that calculates the corresponding color - // per lamp. In the main() function we take all the calculated colors and sum them up for - // this fragment's final color. - // == ===================================================== - // phase 1: directional lighting - vec3 result = CalcDirLight(dirLight, norm, viewDir); - // phase 2: point lights - for(int i = 0; i < NR_POINT_LIGHTS; i++) - result += CalcPointLight(pointLights[i], norm, FragPos, viewDir); - // phase 3: spot light - result += CalcSpotLight(spotLight, norm, FragPos, viewDir); - - FragColor = vec4(result, 1.0); -} - -// calculates the color when using a directional light. -vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir) -{ - vec3 lightDir = normalize(-light.direction); - // diffuse shading - float diff = max(dot(normal, lightDir), 0.0); - // specular shading - vec3 reflectDir = reflect(-lightDir, normal); - float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); - // combine results - vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); - vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); - vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords)); - return (ambient + diffuse + specular); -} - -// calculates the color when using a point light. -vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir) -{ - vec3 lightDir = normalize(light.position - fragPos); - // diffuse shading - float diff = max(dot(normal, lightDir), 0.0); - // specular shading - vec3 reflectDir = reflect(-lightDir, normal); - float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); - // attenuation - float distance = length(light.position - fragPos); - float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance)); - // combine results - vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); - vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); - vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords)); - ambient *= attenuation; - diffuse *= attenuation; - specular *= attenuation; - return (ambient + diffuse + specular); -} - -// calculates the color when using a spot light. -vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) -{ - vec3 lightDir = normalize(light.position - fragPos); - // diffuse shading - float diff = max(dot(normal, lightDir), 0.0); - // specular shading - vec3 reflectDir = reflect(-lightDir, normal); - float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); - // attenuation - float distance = length(light.position - fragPos); - float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance)); - // spotlight intensity - float theta = dot(lightDir, normalize(-light.direction)); - float epsilon = light.cutOff - light.outerCutOff; - float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0); - // combine results - vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); - vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); - vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords)); - ambient *= attenuation * intensity; - diffuse *= attenuation * intensity; - specular *= attenuation * intensity; - return (ambient + diffuse + specular); -} diff --git a/tutorial/src/main/assets/shaders/basic_lighting/6.light_cube.frag b/tutorial/src/main/assets/shaders/basic_lighting/light_cube.frag similarity index 98% rename from tutorial/src/main/assets/shaders/basic_lighting/6.light_cube.frag rename to tutorial/src/main/assets/shaders/basic_lighting/light_cube.frag index 2291f6fd..3707fa2a 100644 --- a/tutorial/src/main/assets/shaders/basic_lighting/6.light_cube.frag +++ b/tutorial/src/main/assets/shaders/basic_lighting/light_cube.frag @@ -5,4 +5,4 @@ out vec4 FragColor; void main() { FragColor = vec4(1.0); // set all 4 vector values to 1.0 -} +} \ No newline at end of file diff --git a/tutorial/src/main/assets/shaders/basic_lighting/6.light_cube.vert b/tutorial/src/main/assets/shaders/basic_lighting/light_cube.vert similarity index 98% rename from tutorial/src/main/assets/shaders/basic_lighting/6.light_cube.vert rename to tutorial/src/main/assets/shaders/basic_lighting/light_cube.vert index a349d935..54efa4cc 100644 --- a/tutorial/src/main/assets/shaders/basic_lighting/6.light_cube.vert +++ b/tutorial/src/main/assets/shaders/basic_lighting/light_cube.vert @@ -8,4 +8,4 @@ uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0); -} +} \ No newline at end of file diff --git a/tutorial/src/main/assets/shaders/basic_lighting/lighting_maps.frag b/tutorial/src/main/assets/shaders/basic_lighting/lighting_maps.frag new file mode 100644 index 00000000..eea1c870 --- /dev/null +++ b/tutorial/src/main/assets/shaders/basic_lighting/lighting_maps.frag @@ -0,0 +1,50 @@ +#version 320 es +precision mediump float; +out vec4 FragColor; + +struct Material { + sampler2D diffuse; + sampler2D specular; + sampler2D emission; + float shininess; +}; + +struct Light { + vec3 position; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +in vec3 FragPos; +in vec3 Normal; +in vec2 TexCoords; + +uniform vec3 viewPos; +uniform Material material; +uniform Light light; + +void main() +{ + // ambient + vec3 ambient = light.ambient * texture(material.diffuse, TexCoords).rgb; + + // diffuse + vec3 norm = normalize(Normal); + vec3 lightDir = normalize(light.position - FragPos); + float diff = max(dot(norm, lightDir), 0.0); + vec3 diffuse = light.diffuse * diff * texture(material.diffuse, TexCoords).rgb; + + // specular + vec3 viewDir = normalize(viewPos - FragPos); + vec3 reflectDir = reflect(-lightDir, norm); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + vec3 specular = light.specular * spec * texture(material.specular, TexCoords).rgb; + + // emission + vec3 emission = texture(material.emission, TexCoords).rgb; + + vec3 result = ambient + diffuse + specular + emission; + FragColor = vec4(result, 1.0); +} \ No newline at end of file diff --git a/tutorial/src/main/assets/shaders/basic_lighting/6.multiple_lights.vert b/tutorial/src/main/assets/shaders/basic_lighting/lighting_maps.vert similarity index 99% rename from tutorial/src/main/assets/shaders/basic_lighting/6.multiple_lights.vert rename to tutorial/src/main/assets/shaders/basic_lighting/lighting_maps.vert index 3fbae3a6..81d781f2 100644 --- a/tutorial/src/main/assets/shaders/basic_lighting/6.multiple_lights.vert +++ b/tutorial/src/main/assets/shaders/basic_lighting/lighting_maps.vert @@ -1,4 +1,5 @@ #version 320 es + layout (location = 0) in vec3 aPos; layout (location = 1) in vec3 aNormal; layout (location = 2) in vec2 aTexCoords; @@ -18,4 +19,4 @@ void main() TexCoords = aTexCoords; gl_Position = projection * view * vec4(FragPos, 1.0); -} +} \ No newline at end of file diff --git a/tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.frag b/tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.frag similarity index 100% rename from tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.frag rename to tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.frag diff --git a/tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.tesc b/tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.tesc similarity index 52% rename from tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.tesc rename to tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.tesc index 97672d4f..f7782357 100644 --- a/tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.tesc +++ b/tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.tesc @@ -15,8 +15,8 @@ void main() if(gl_InvocationID == 0) { - const int MIN_TESS_LEVEL = 4; - const int MAX_TESS_LEVEL = 64; + const float MIN_TESS_LEVEL = 4.; + const float MAX_TESS_LEVEL = 64.; const float MIN_DISTANCE = 20.; const float MAX_DISTANCE = 800.; @@ -26,15 +26,15 @@ void main() vec4 eyeSpacePos11 = view * model * gl_in[3].gl_Position; // "distance" from camera scaled between 0 and 1 - float distance00 = clamp( (abs(eyeSpacePos00.z) - MIN_DISTANCE) / (MAX_DISTANCE-MIN_DISTANCE), 0.0, 1.0 ); - float distance01 = clamp( (abs(eyeSpacePos01.z) - MIN_DISTANCE) / (MAX_DISTANCE-MIN_DISTANCE), 0.0, 1.0 ); - float distance10 = clamp( (abs(eyeSpacePos10.z) - MIN_DISTANCE) / (MAX_DISTANCE-MIN_DISTANCE), 0.0, 1.0 ); - float distance11 = clamp( (abs(eyeSpacePos11.z) - MIN_DISTANCE) / (MAX_DISTANCE-MIN_DISTANCE), 0.0, 1.0 ); - - float tessLevel0 = mix( MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance10, distance00) ); - float tessLevel1 = mix( MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance00, distance01) ); - float tessLevel2 = mix( MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance01, distance11) ); - float tessLevel3 = mix( MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance11, distance10) ); + float distance00 = clamp((abs(eyeSpacePos00.z) - MIN_DISTANCE) / (MAX_DISTANCE - MIN_DISTANCE), 0.0, 1.0); + float distance01 = clamp((abs(eyeSpacePos01.z) - MIN_DISTANCE) / (MAX_DISTANCE - MIN_DISTANCE), 0.0, 1.0); + float distance10 = clamp((abs(eyeSpacePos10.z) - MIN_DISTANCE) / (MAX_DISTANCE - MIN_DISTANCE), 0.0, 1.0); + float distance11 = clamp((abs(eyeSpacePos11.z) - MIN_DISTANCE) / (MAX_DISTANCE - MIN_DISTANCE), 0.0, 1.0); + + float tessLevel0 = mix(MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance10, distance00)); + float tessLevel1 = mix(MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance00, distance01)); + float tessLevel2 = mix(MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance01, distance11)); + float tessLevel3 = mix(MAX_TESS_LEVEL, MIN_TESS_LEVEL, min(distance11, distance10)); gl_TessLevelOuter[0] = tessLevel0; gl_TessLevelOuter[1] = tessLevel1; diff --git a/tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.tese b/tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.tese similarity index 88% rename from tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.tese rename to tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.tese index 03e23681..90fafaff 100644 --- a/tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.tese +++ b/tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.tese @@ -1,5 +1,5 @@ #version 320 es -layout(quads, fractional_odd_spacing, ccw) in; +layout (quads, fractional_odd_spacing, ccw) in; uniform sampler2D heightMap; uniform mat4 model; @@ -33,7 +33,7 @@ void main() vec4 uVec = p01 - p00; vec4 vVec = p10 - p00; - vec4 normal = normalize( vec4(cross(vVec.xyz, uVec.xyz), 0.) ); + vec4 normal = normalize(vec4(cross(vVec.xyz, uVec.xyz), 0.)); vec4 p0 = (p01 - p00) * u + p00; vec4 p1 = (p11 - p10) * u + p10; diff --git a/tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.vert b/tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.vert similarity index 100% rename from tutorial/src/main/assets/shaders/tesselation_shaders/8.3.gpuheight.vert rename to tutorial/src/main/assets/shaders/tesselation_shaders/gpuheight.vert diff --git a/tutorial/src/main/cpp/basic/AsteroidScene.cpp b/tutorial/src/main/cpp/basic/AsteroidScene.cpp index 9e43a0dc..84b1c467 100644 --- a/tutorial/src/main/cpp/basic/AsteroidScene.cpp +++ b/tutorial/src/main/cpp/basic/AsteroidScene.cpp @@ -22,8 +22,8 @@ void AsteroidScene::init() { // load models // ----------- - m_pRockModel = new Model("models/rock/rock.obj"); - m_pPlanetModel = new Model("models/planet/planet.obj"); + m_pRockModel = new Model("objects/rock/rock.obj"); + m_pPlanetModel = new Model("objects/planet/planet.obj"); // generate a large list of semi-random model transformation matrices // ------------------------------------------------------------------ diff --git a/tutorial/src/main/cpp/basic/ModelScene.cpp b/tutorial/src/main/cpp/basic/ModelScene.cpp index 1c776e06..2aa1cc42 100644 --- a/tutorial/src/main/cpp/basic/ModelScene.cpp +++ b/tutorial/src/main/cpp/basic/ModelScene.cpp @@ -12,6 +12,7 @@ void ModelScene::init() { m_camera = new TargetCamera; // configure global opengl state // ----------------------------- + glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); // build and compile our shader zprogram diff --git a/tutorial/src/main/cpp/basic/TesselationShaderScene.cpp b/tutorial/src/main/cpp/basic/TesselationShaderScene.cpp index b56aa22e..d3b9cf8e 100644 --- a/tutorial/src/main/cpp/basic/TesselationShaderScene.cpp +++ b/tutorial/src/main/cpp/basic/TesselationShaderScene.cpp @@ -24,15 +24,15 @@ void TesselationShaderScene::init() { // build and compile our shader program // ------------------------------------ - tessHeightMapShader = new Shader("shaders/tesselation_shaders/8.3.gpuheight.vert", - "shaders/tesselation_shaders/8.3.gpuheight.frag", + tessHeightMapShader = new Shader("shaders/tesselation_shaders/gpuheight.vert", + "shaders/tesselation_shaders/gpuheight.frag", nullptr, - "shaders/tesselation_shaders/8.3.gpuheight.tesc", - "shaders/tesselation_shaders/8.3.gpuheight.tese"); + "shaders/tesselation_shaders/gpuheight.tesc", + "shaders/tesselation_shaders/gpuheight.tese"); // load and create a texture // ------------------------- - texture = loadTexture("heightmaps/iceland_heightmap.png"); + texture = loadTexture("textures/heightmaps/iceland_heightmap.png"); tessHeightMapShader->use(); tessHeightMapShader->setInt("heightMap", 0); @@ -48,33 +48,31 @@ void TesselationShaderScene::resize(int width, int height) { // set up vertex data (and buffer(s)) and configure vertex attributes // ------------------------------------------------------------------ std::vector vertices; - for(unsigned i = 0; i <= rez-1; i++) - { - for(unsigned j = 0; j <= rez-1; j++) - { - vertices.push_back(-width/2.0f + width*i/(float)rez); // v.x + for (unsigned i = 0; i <= rez - 1; i++) { + for (unsigned j = 0; j <= rez - 1; j++) { + vertices.push_back(-width / 2.0f + width * i / (float) rez); // v.x vertices.push_back(0.0f); // v.y - vertices.push_back(-height/2.0f + height*j/(float)rez); // v.z - vertices.push_back(i / (float)rez); // u - vertices.push_back(j / (float)rez); // v + vertices.push_back(-height / 2.0f + height * j / (float) rez); // v.z + vertices.push_back(i / (float) rez); // u + vertices.push_back(j / (float) rez); // v - vertices.push_back(-width/2.0f + width*(i+1)/(float)rez); // v.x + vertices.push_back(-width / 2.0f + width * (i + 1) / (float) rez); // v.x vertices.push_back(0.0f); // v.y - vertices.push_back(-height/2.0f + height*j/(float)rez); // v.z - vertices.push_back((i+1) / (float)rez); // u - vertices.push_back(j / (float)rez); // v + vertices.push_back(-height / 2.0f + height * j / (float) rez); // v.z + vertices.push_back((i + 1) / (float) rez); // u + vertices.push_back(j / (float) rez); // v - vertices.push_back(-width/2.0f + width*i/(float)rez); // v.x + vertices.push_back(-width / 2.0f + width * i / (float) rez); // v.x vertices.push_back(0.0f); // v.y - vertices.push_back(-height/2.0f + height*(j+1)/(float)rez); // v.z - vertices.push_back(i / (float)rez); // u - vertices.push_back((j+1) / (float)rez); // v + vertices.push_back(-height / 2.0f + height * (j + 1) / (float) rez); // v.z + vertices.push_back(i / (float) rez); // u + vertices.push_back((j + 1) / (float) rez); // v - vertices.push_back(-width/2.0f + width*(i+1)/(float)rez); // v.x + vertices.push_back(-width / 2.0f + width * (i + 1) / (float) rez); // v.x vertices.push_back(0.0f); // v.y - vertices.push_back(-height/2.0f + height*(j+1)/(float)rez); // v.z - vertices.push_back((i+1) / (float)rez); // u - vertices.push_back((j+1) / (float)rez); // v + vertices.push_back(-height / 2.0f + height * (j + 1) / (float) rez); // v.z + vertices.push_back((i + 1) / (float) rez); // u + vertices.push_back((j + 1) / (float) rez); // v } } @@ -83,9 +81,9 @@ void TesselationShaderScene::resize(int width, int height) { glGenBuffers(1, &terrainVBO); glBindBuffer(GL_ARRAY_BUFFER, terrainVBO); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), &vertices[0], GL_STATIC_DRAW); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) 0); glEnableVertexAttribArray(0); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(sizeof(float) * 3)); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) (sizeof(float) * 3)); glEnableVertexAttribArray(1); glPatchParameteri(GL_PATCH_VERTICES, NUM_PATCH_PTS); @@ -93,7 +91,7 @@ void TesselationShaderScene::resize(int width, int height) { void TesselationShaderScene::draw() { m_camera->update(); - glClearColor(0.1f, 0.1f, 0.1f, 1.0f); + glClearColor(0.65f, 0.65f, 0.65f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (tessHeightMapShader) { @@ -104,7 +102,7 @@ void TesselationShaderScene::draw() { tessHeightMapShader->setMat4("view", view); glm::mat4 model = glm::mat4(1.0f); tessHeightMapShader->setMat4("model", model); - + tessHeightMapShader->setTexture("heightMap", texture, 0); glBindVertexArray(terrainVAO); glDrawArrays(GL_PATCHES, 0, NUM_PATCH_PTS * rez * rez); } @@ -134,12 +132,12 @@ std::map TesselationShaderScene::propertyEvent(std::map &event) { - auto* targetCamera = dynamic_cast(m_camera); + auto *targetCamera = dynamic_cast(m_camera); if (!targetCamera) return; if (auto it = event.find("single_touching"); it != event.end()) { if (it->second.type() == typeid(std::vector)) { - const auto& val = std::any_cast&>(it->second); + const auto &val = std::any_cast &>(it->second); if (val.size() >= 4) { targetCamera->onSingleTouching(glm::vec2(val[0], val[1]), glm::vec2(val[2], val[3])); } @@ -148,10 +146,10 @@ void TesselationShaderScene::parseTargetCameraEvent(std::mapsecond.type() == typeid(std::vector)) { - const auto& val = std::any_cast&>(it->second); + const auto &val = std::any_cast &>(it->second); if (val.size() >= 8) { targetCamera->onDoubleTouching(glm::vec2(val[0], val[1]), glm::vec2(val[2], val[3]), - glm::vec2(val[4], val[5]), glm::vec2(val[6], val[7])); + glm::vec2(val[4], val[5]), glm::vec2(val[6], val[7])); } } } diff --git a/tutorial/src/main/cpp/basic/TesselationShaderScene.h b/tutorial/src/main/cpp/basic/TesselationShaderScene.h index 163e460a..b04c7598 100644 --- a/tutorial/src/main/cpp/basic/TesselationShaderScene.h +++ b/tutorial/src/main/cpp/basic/TesselationShaderScene.h @@ -28,7 +28,7 @@ public : Shader* tessHeightMapShader = nullptr; unsigned int terrainVAO = 0u, terrainVBO = 0u; unsigned int texture = 0u; - unsigned int rez = 0u; + unsigned int rez = 20u; int m_width = 0; int m_height = 0; diff --git a/tutorial/src/main/cpp/lighting/BasicLightingScene.cpp b/tutorial/src/main/cpp/lighting/BasicLightingScene.cpp index 1c3b4f48..79733d9e 100644 --- a/tutorial/src/main/cpp/lighting/BasicLightingScene.cpp +++ b/tutorial/src/main/cpp/lighting/BasicLightingScene.cpp @@ -17,8 +17,10 @@ void BasicLightingScene::init() { // build and compile our shader zprogram // ------------------------------------ - m_pLightingShader = new Shader("shaders/basic_lighting/4.4.lighting_maps.vert", "shaders/basic_lighting/4.4.lighting_maps.frag"); - m_pLightCubeShader = new Shader("shaders/basic_lighting/4.4.light_cube.vert", "shaders/basic_lighting/4.4.light_cube.frag"); + m_pLightingShader = new Shader("shaders/basic_lighting/lighting_maps.vert", + "shaders/basic_lighting/lighting_maps.frag"); + m_pLightCubeShader = new Shader("shaders/basic_lighting/light_cube.vert", + "shaders/basic_lighting/light_cube.frag"); // set up vertex data (and buffer(s)) and configure vertex attributes // ------------------------------------------------------------------ diff --git a/tutorial/src/main/cpp/lighting/MultiLightsScene.cpp b/tutorial/src/main/cpp/lighting/MultiLightsScene.cpp index 05734813..4740fe98 100644 --- a/tutorial/src/main/cpp/lighting/MultiLightsScene.cpp +++ b/tutorial/src/main/cpp/lighting/MultiLightsScene.cpp @@ -30,8 +30,8 @@ void MultiLightsScene::init() { // build and compile our shader zprogram // ------------------------------------ - m_pLightingShader = new Shader("shaders/multiple_lights/6.multiple_lights.vert", "shaders/multiple_lights/6.multiple_lights.frag"); - m_pLightCubeShader = new Shader("shaders/multiple_lights/6.light_cube.vert", "shaders/multiple_lights/6.light_cube.frag"); + m_pLightingShader = new Shader("shaders/multiple_lights/multiple_lights.vert", "shaders/multiple_lights/multiple_lights.frag"); + m_pLightCubeShader = new Shader("shaders/multiple_lights/light_cube.vert", "shaders/multiple_lights/light_cube.frag"); // set up vertex data (and buffer(s)) and configure vertex attributes // ------------------------------------------------------------------ diff --git a/tutorial/src/main/cpp/model/Model.cpp b/tutorial/src/main/cpp/model/Model.cpp index 0bb4921a..740baaa7 100644 --- a/tutorial/src/main/cpp/model/Model.cpp +++ b/tutorial/src/main/cpp/model/Model.cpp @@ -12,7 +12,7 @@ using std::string; using std::vector; -extern char *g_internalPath; +extern std::string g_internalPath; extern AAssetManager* mgr; // constructor, expects a filepath to a 3D model. @@ -33,7 +33,7 @@ void Model::loadModel(string const &path) { // read file via ASSIMP Assimp::Importer importer; - Assimp::AndroidJNIIOSystem *ioSystem = new Assimp::AndroidJNIIOSystem (g_internalPath, mgr); + Assimp::AndroidJNIIOSystem *ioSystem = new Assimp::AndroidJNIIOSystem (g_internalPath.data(), mgr); importer.SetIOHandler(ioSystem); const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace); @@ -191,6 +191,7 @@ vector Model::loadMaterialTextures(aiMaterial *mat, aiTextureType type, unsigned int TextureFromFile(const char *path, const string &directory, bool gamma) { + stbi_set_flip_vertically_on_load(1); string filename = string(path); filename = directory + '/' + filename; diff --git a/tutorial/src/main/java/com/minininja/learngles/GLActivity.kt b/tutorial/src/main/java/com/minininja/learngles/GLActivity.kt index 808af31b..6bc2239c 100644 --- a/tutorial/src/main/java/com/minininja/learngles/GLActivity.kt +++ b/tutorial/src/main/java/com/minininja/learngles/GLActivity.kt @@ -58,7 +58,7 @@ open class GLActivity : ComponentActivity() { super.onCreate(savedInstanceState) enableEdgeToEdge() NativeHelper.setupNativeAsset(assets) - NativeHelper.setupInternalPath(getExternalFilesDir("files")?.path) + NativeHelper.setupInternalPath(filesDir.path) setContent { LearnGLESTheme { OpenGLContainer(