Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RID Spam and Broken Temp Normal Map Generation #111

Closed
outobugi opened this issue Jul 14, 2023 · 1 comment
Closed

RID Spam and Broken Temp Normal Map Generation #111

outobugi opened this issue Jul 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@outobugi
Copy link
Collaborator

Recreate issue:

  1. Add albedo and normal map for it
  2. Add a second surface without a normal map
@outobugi outobugi added the bug Something isn't working label Jul 14, 2023
@TokisanGames TokisanGames added this to the Stable milestone Jul 17, 2023
@TokisanGames TokisanGames self-assigned this Jul 22, 2023
@TokisanGames TokisanGames changed the title Temp normal map generation broken Temp normal map generation broken & RID errors Jul 22, 2023
@TokisanGames TokisanGames changed the title Temp normal map generation broken & RID errors RID Spam and Broken Temp Normal Map Generation Jul 22, 2023
@TokisanGames TokisanGames modified the milestones: Stable, Beta Jul 22, 2023
@TokisanGames
Copy link
Owner

When creating a new blank surfarce the terrain in the viewport suddenly shifts and gains more contrast. Also there are many RID errors in the console. Both are visible in GamesFromScratch's video and people noted "bruh 29,000 errors".

Through debugging I found that the invalid RID is in the generated normal texture. This error persists anytime you do anything with that map all the way to complaints while freeing.

The cause is here:

https://github.com/outobugi/Terrain3D/blob/2e2457f2c0e489cbbc86d59265b56cc275dcc5dd/src/terrain_3d_storage.cpp#L165-L167

20 lines above, the albedo generation is nearly identical. The albedo image is Color(1.0f, 0.0f, 1.0f, 1.0f). After compression the resulting image is format 19: DXT5.

The only different to the code here is the image, which is filled with Color(0.5f, 0.5f, 1.0f, 1.0f). After compression the resulting image is format 17: DXT1!!??

Then the rendering server complains about the different formats, the normal map RID is invalid, and we get error spam.

Terrain3D::create: 0: <Image#-9223370263553314751>, empty: false, size: (1024, 1024), format: 19
Terrain3D::create: 1: <Image#-9223370263536537530>, empty: false, size: (1024, 1024), format: 19
Terrain3D::create: 2: <Image#-9223370263519760315>, empty: false, size: (1024, 1024), format: 17
Terrain3D::create: RenderingServer texture_2d_layered_create
ERROR: Condition "p_layers[i]->get_format() != valid_format" is true.
   at: texture_2d_layered_initialize (servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:884)

The solution is to change the line to this, which forces it to use alpha.

img->compress_from_channels(Image::COMPRESS_S3TC, Image::USED_CHANNELS_RGBA);

Just in case, I changed it for both albedo and normal. Now we can add a blank surface and there are no errors, no visual change to the terrain, and we can paint with a null texture, which comes out as fuscia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants