2
0
Эх сурвалжийг харах

Merge pull request #51258 from The-O-King/normal_compression_fix

Fix Bugs w/ Octahedral Compression Implementation
Rémi Verschelde 4 жил өмнө
parent
commit
856097d7bc

+ 1 - 1
drivers/gles3/rasterizer_scene_gles3.cpp

@@ -2154,7 +2154,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
 
 
 	glBindVertexArray(0);
 	glBindVertexArray(0);
 
 
-	state.scene_shader.remove_custom_define("#define ENABLE_OCTAHEDRAL_COMPRESSION\n");
+	state.scene_shader.set_conditional(SceneShaderGLES3::ENABLE_OCTAHEDRAL_COMPRESSION, false);
 	state.scene_shader.set_conditional(SceneShaderGLES3::USE_INSTANCING, false);
 	state.scene_shader.set_conditional(SceneShaderGLES3::USE_INSTANCING, false);
 	state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON, false);
 	state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON, false);
 	state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
 	state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);

+ 8 - 8
servers/visual_server.cpp

@@ -1496,11 +1496,11 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector<uint8_
 						for (int j = 0; j < p_vertex_len; j++) {
 						for (int j = 0; j < p_vertex_len; j++) {
 							const int8_t *t = (const int8_t *)&r[j * total_elem_size + offsets[i]];
 							const int8_t *t = (const int8_t *)&r[j * total_elem_size + offsets[i]];
 							Vector2 enc(t[0] / 127.0f, t[1] / 127.0f);
 							Vector2 enc(t[0] / 127.0f, t[1] / 127.0f);
-							Vector3 dec = oct_to_tangent(enc, &w[j * 3 + 2]);
+							Vector3 dec = oct_to_tangent(enc, &w[j * 4 + 3]);
 
 
-							w[j * 3 + 0] = dec.x;
-							w[j * 3 + 1] = dec.y;
-							w[j * 3 + 2] = dec.z;
+							w[j * 4 + 0] = dec.x;
+							w[j * 4 + 1] = dec.y;
+							w[j * 4 + 2] = dec.z;
 						}
 						}
 					} else {
 					} else {
 						PoolVector<float>::Write w = arr.write();
 						PoolVector<float>::Write w = arr.write();
@@ -1508,11 +1508,11 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector<uint8_
 						for (int j = 0; j < p_vertex_len; j++) {
 						for (int j = 0; j < p_vertex_len; j++) {
 							const int16_t *t = (const int16_t *)&r[j * total_elem_size + offsets[i]];
 							const int16_t *t = (const int16_t *)&r[j * total_elem_size + offsets[i]];
 							Vector2 enc(t[0] / 32767.0f, t[1] / 32767.0f);
 							Vector2 enc(t[0] / 32767.0f, t[1] / 32767.0f);
-							Vector3 dec = oct_to_tangent(enc, &w[j * 3 + 2]);
+							Vector3 dec = oct_to_tangent(enc, &w[j * 4 + 3]);
 
 
-							w[j * 3 + 0] = dec.x;
-							w[j * 3 + 1] = dec.y;
-							w[j * 3 + 2] = dec.z;
+							w[j * 4 + 0] = dec.x;
+							w[j * 4 + 1] = dec.y;
+							w[j * 4 + 2] = dec.z;
 						}
 						}
 					}
 					}
 				} else {
 				} else {