Search Unity

Question Build rendering differently to editor. Objects invisible and dissapearing.

Discussion in 'Editor & General Support' started by Gazzzah, Mar 16, 2023.

  1. Gazzzah

    Gazzzah

    Joined:
    Jul 18, 2018
    Posts:
    16
    I need help. I tried to build my game last night and noticed that my character was completely invisible. You could see the shadow but not the character.

    I thought this was weird but I noticed it's also happening to one of his weapons that uses the same Shadergraph URP shader. So I assumed I must have done something wrong with it.

    It's a shader that takes a collection of textures, multiplies them by a color and then adds them together do make a color grid for the UVs to sample.

    I noticed an error occured during build, I did some googling and this forum post led me to understand that I have too many sampler states on my shader. So I optimized it a little and got it to build without the error. However there is still a warning coming up (I'll paste it below) and more importantly it's still not rendering my character.

    Ok so perhaps it's a bug. I try updating unity from 2021.3.13f to 2021.3.21f. Now I'm still getting the warning and my builds have descended into chaos. Other objects are now invisible too, or coming in and out of visibility, including chunks of terrain, different shaders being affected, some of which are standard URP lit shader with a texture slapped onto it. Seems like there are some "sweet spot" camera angles where these objects are visible but it's all over the place and they are all Character is still completely invisible.

    I uploaded this video to reddit where you can see what's going on.

    I tried starting a brand new project and importing all my assets (just to see if that makes a difference) and then when I build that I get a black silhouette for the character.

    This seems completely insane. The editor looks fine and normal. I don't know what I've done.

    A helpful reddit user pointed me towards renderdoc which I've installed and captured some frames but I'm still trying to wrap my head around what I'm reading (outcome pending).

    I'm not very fluent in rendering. The only real changes I've made to URP as I can recall is set it to use differed rendering and added a couple of post processing effects. But even then, why is it still broken on a new project?
    I also tried building on a different computer incase that was somehow related and the results were the same.

    If anyone has any other tips about how I can troubleshoot this I would greatly appreciate any advise.

    Here is a paste of the two warnings I'm getting when I output a build:
    ____________________________________________________________________

    Shader warning in 'Hidden/Universal Render Pipeline/StencilDeferred': implicit truncation of vector type at line 187 (on d3d11)

    Compiling Subshader: 0, Pass: Deferred Directional Light (Lit), Fragment program with _DEFERRED_MAIN_LIGHT _DEFERRED_STENCIL _DIRECTIONAL _LIGHT_COOKIES _LIT

    Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS

    Disabled keywords: LIGHTMAP_SHADOW_MIXING SHADER_API_GLES30 SHADOWS_SHADOWMASK UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _ADDITIONAL_LIGHT_SHADOWS _DEFERRED_FIRST_LIGHT _DEFERRED_MIXED_LIGHTING _GBUFFER_NORMALS_OCT _LIGHT_LAYERS _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN _RENDER_PASS_ENABLED _SCREEN_SPACE_OCCLUSION _SHADOWS_SOFT

    _____________________________________________________________________________
    Number 2
    _____________________________________________________________________________

    Shader warning in 'Hidden/Universal Render Pipeline/StencilDeferred': implicit truncation of vector type at line 232 (on d3d11)

    Compiling Subshader: 0, Pass: Deferred Punctual Light (Lit), Fragment program with _DEFERRED_MIXED_LIGHTING _DEFERRED_STENCIL _LIGHT_COOKIES _LIT _SPOT

    Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS

    Disabled keywords: LIGHTMAP_SHADOW_MIXING SHADER_API_GLES30 SHADOWS_SHADOWMASK UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _ADDITIONAL_LIGHT_SHADOWS _GBUFFER_NORMALS_OCT _LIGHT_LAYERS _POINT _RENDER_PASS_ENABLED _SCREEN_SPACE_OCCLUSION _SHADOWS_SOFT
     
  2. Gazzzah

    Gazzzah

    Joined:
    Jul 18, 2018
    Posts:
    16
    This problem is solved. On the off chance someone finds this looking for a solutions here’s what happened:

    Turns out it was, I guess, some corrupt materials. I had fixed an error with my character shader but I guess the materials still had bad data saved in them.

    When I deleted those 4 materials and rebuilt them. Everything just about went back to normal.