diff --git a/src/gpu_formats/texture_optimize.nim b/src/gpu_formats/texture_optimize.nim index 5fb8766..dc4856a 100644 --- a/src/gpu_formats/texture_optimize.nim +++ b/src/gpu_formats/texture_optimize.nim @@ -79,7 +79,7 @@ template has_astc_support: bool = gl.GLAD_GL_OES_texture_compression_astc or const myouMinTextureChannels {.intdefine.} = 0 const myouEngineNumTextureThreads {.intdefine.} = 4 const myouBC7VerboseMode {.booldefine.} = false -const myouAllCacheFilesExist {.booldefine.} = defined(myouUseAndroidAssets) +const myouAllCacheFilesExist {.booldefine.} = false const myouLoadUncompressedTextures {.booldefine.} = false when defined(myouAllCacheFilesExist): import ../platform/platform diff --git a/src/graphics/render.nim b/src/graphics/render.nim index 33598b0..54ad811 100644 --- a/src/graphics/render.nim +++ b/src/graphics/render.nim @@ -281,9 +281,11 @@ proc draw_mesh*(self: RenderManager, mesh: Mesh, mesh2world: Mat4, cam_data: Ren continue var mat = if material_override == nil: - amesh.materials.get_or_default(submesh_idx, self.no_material) + amesh.materials.get_or_default(submesh_idx, nil) else: material_override + if mat.isNil: + mat = self.no_material let shader {.cursor.} = mat.get_shader(mesh) let program = shader.use() diff --git a/src/scene.nim b/src/scene.nim index dacce66..1b26b9c 100644 --- a/src/scene.nim +++ b/src/scene.nim @@ -601,7 +601,7 @@ proc get_lighting_code*(self: Scene): string = uniform samplerCube cube_maps[MAX_CUBE_MAPS]; #endif struct SH9 { - vec3 c[9]; + vec4 c[9]; }; #ifndef MAX_SPHERICAL_HARMONICS diff --git a/src/shaders/shader_library.glsl b/src/shaders/shader_library.glsl index 64a4b3c..ecf5eb5 100644 --- a/src/shaders/shader_library.glsl +++ b/src/shaders/shader_library.glsl @@ -286,7 +286,7 @@ vec4 principled_node(vec3 base, vec3 I, vec3 normal, vec3 pos, float metallic, f // these look good... vec3 env_specular = sample_environment(reflect(-I,N), pos, roughness) * (1.0 - roughness); #if MAX_SPHERICAL_HARMONICS - vec3 env_diffuse = get_sh9(N, SH9_coefficients[0]) * 0.3; + vec3 env_diffuse = get_sh9(N, 0) * 0.5; #else vec3 env_diffuse = sample_environment(N, pos, 1.0) * 0.1; #endif diff --git a/src/shaders/spherical_harmonics.glsl b/src/shaders/spherical_harmonics.glsl index 1d8478c..5dc27e5 100644 --- a/src/shaders/spherical_harmonics.glsl +++ b/src/shaders/spherical_harmonics.glsl @@ -3,18 +3,19 @@ #if MAX_SPHERICAL_HARMONICS -vec3 get_sh9(vec3 direction, SH9 sh) +vec3 get_sh9(vec3 direction, int sh_index) { vec3 dir = SH9_rotation * direction; - return sh.c[0] * 0.282095 - + sh.c[1] * 0.488603 * dir.y - + sh.c[2] * 0.488603 * dir.z - + sh.c[3] * 0.488603 * dir.x - + sh.c[4] * 1.092548 * dir.x * dir.y - + sh.c[5] * 1.092548 * dir.y * dir.z - + sh.c[6] * 0.315392 * (3.0 * dir.z * dir.z - 1.0) - + sh.c[7] * 1.092548 * dir.x * dir.z - + sh.c[8] * 0.546274 * (dir.x * dir.x - dir.y * dir.y) + SH9 sh = SH9_coefficients[0]; + return sh.c[0].rgb * 0.282095 + + sh.c[1].rgb * 0.488603 * dir.y + + sh.c[2].rgb * 0.488603 * dir.z + + sh.c[3].rgb * 0.488603 * dir.x + + sh.c[4].rgb * 1.092548 * dir.x * dir.y + + sh.c[5].rgb * 1.092548 * dir.y * dir.z + + sh.c[6].rgb * 0.315392 * (3.0 * dir.z * dir.z - 1.0) + + sh.c[7].rgb * 1.092548 * dir.x * dir.z + + sh.c[8].rgb * 0.546274 * (dir.x * dir.x - dir.y * dir.y) ; }