Forum rules - please read before posting.

Highlights not working for URP sprite-lit materials

2»

Comments

  • What are your AC and Unity versions? In the current release, AC should pick up on the use of URP and work with the Lit shader automatically.

    Though, that the materials are greyed out may be the issue here - as it suggests they're read-only and cannot be modified, which is how the default brightening effect works.

    If the materials are part of an imported model file, you'll need to extract them from the model's "Materials" tab - see the second answer in this thread for details.

  • Forgot about the version: Unity 2022.3.5f1. I watched the video and I managed to unlock the materials. But still no luck with the highlight. I tried to override the material in the Hotspot settings with "_BaseColor" but didn't do anything.

  • edited January 6

    I'm not seeing the Highlight component in your earlier screenshot - is it attached to a parent object, e.g. TapeRecorder? And are any related messages appearing in the Console?

    Assuming so, let's take a step back and check that the Hotspot/Highlight connection is correct - as this'll need to be working before any materials can be updated.

    In the "Hotspots" panel of the Settings Manager, set Display Hotspot icons to Only When Highlighting, Hotspot icon type to Texture, and assign a temporary Texture underneath.

    That should cause the assigned Texture to appear over your Hotspots at the same time the Highlight effect kicks in. Are they showing up correctly?

  • edited January 6

    I'm not seeing the Highlight component in your earlier screenshot - is it attached to a parent object, e.g. TapeRecorder? And are any related messages appearing in the Console?

    Yes, it's on the Tape parent.

    In the "Hotspots" panel of the Settings Manager, set Display Hotspot icons to Only When Highlighting, Hotspot icon type to Texture, and assign a temporary Texture underneath.

    That should cause the assigned Texture to appear over your Hotspots at the same time the Highlight effect kicks in. Are they showing up correctly?

    Yes, it shows up over the answering machine ("Contestador" in Spanish)

    "TapeRecorderParent" has the Highlight component and "Tape Recorder.Shape" is the gameObject with the textures components.



  • From all that I can see, it should work - I can't recreate such an issue with URP and the Lit material on my end.

    There may be another factor at play that can't be gleaned from screenshots. You're welcome to PM me your project with details on where to look.

  • Thanks for the files.

    The issue occurs because your materials do not use the standard URP Lit material, but instead one provided by Daz3D. Switching them to URP Lit will cause them to brighten.

  • I see. But then when I switch the materials to standard URP Lit my 3D object becomes white. Is there something I can add to the object in terms of materials that would play on top of the other textures to get the highlight effect? Or I would need to convert manually the Daz3D shaders to standard URP?

  • edited January 8

    @Alatriste does it work, when you try to reassign the Texture, not the Material?
    E.g. you click the Object and drop the Texture of it, on it.
    I've had that issue with HDRP, when i changed it from a "pink" material to a lit one, they turned white and i had to put the Texture on the object manually again, then it worked.

    I think you have to change them to URP, the Script looks for the render pipeline and it's basecolor and color properties. You'd either have to do some custom scripting, if daz3d does something different, or change them to URP (which would be easier i think)

  • Switching a Material's shader will need to also involve re-assigning textures for properties that don't transfer - the Daz3D shader uses its own properties.

    The default Highlight effect requires a property that it can control (either _Color or _BaseColor by default) - you can use Daz3D's _Diffuse if you wish, but currently you'd need to be consistent in your usage. I will look into providing a per-component property option, however.

    This is only for the default effect, however: regardless of which shader you use, you can always use a script that reads the Highlight component's GetHighlightIntensity function and applies it to a Float property in your shader, that can then be applied to your material in whatever means you like by editing its Shader Graph. Just uncheck Auto-brighten materials in its Inspector and attach a script that reads the Highlight component manually:

    using UnityEngine;
    using AC;
    
    public class CustomHighlight : MonoBehaviour
    {
        public string propertyName = "_Diffuse";
        public Renderer rend;
        public Highlight highlight;
    
        void Update ()
        {
            rend.material.SetFloat (propertyName, highlight.GetHighlightIntensity ());
        }
    }
    
  • Hi,
    I'm pretty noob with shaders, so bear with me here. :)
    I selected one of the materials of the object to check the shaders of that particular material and I checked that the "_Diffuse" property exists.

    Then I went to the gameObject in the hierarchy of the scene and I applied the changes @ChrisIceBox mentioned.

    However, when I activate the Hotspot hovering with the mouse nothing happens. I have some other objects in the scene (not from Daz3D) that are highlighting correctly so my general setup should be fine.

  • edited January 12

    Sorry - I was mixing up my property types.

    _Diffuse is a Color property, while the above script affects a Float property.

    You could use it to affect a new Float variable you add to the Shader, and then use that to affect the shader, but this modified script should control the Color property:

    using UnityEngine;
    using AC;
    
    public class CustomHighlight : MonoBehaviour
    {
        public string propertyName = "_Diffuse";
        public Renderer rend;
        public Highlight highlight;
        private Color normalColor;
    
        void Awake ()
        {
            normalColor = rend.material.GetColor (propertyName);
        }
    
        void Update ()
        {
            Color currentColor = rend.material.GetColor (propertyName);
            Color newColor = normalColor * (1f + highlight.GetHighlightIntensity ());
            newColor.a = currentColor.a;
            rend.material.SetColor (propertyName, newColor);
        }
    }
    
  • edited January 11

    Unity is throwing this error while compiling the script:
    ...\Custom Scripts\CustomHighlight.cs(19,26): error CS0019: Operator '*' cannot be applied to operands of type 'Color' and 'Highlight'

  • My apologies once more. I've corrected the above script.

  • edited January 12

    Hi Chris, now it works in most of the props I tried but there are a few are giving me this error:

        Material 'black (Instance)' with Shader 'Universal Render Pipeline/Lit' doesn't have a color property '_Diffuse'
    UnityEngine.Material:GetColor (string)
    CustomHighlight:Awake () (at .../Custom Scripts/CustomHighlight.cs:13)
    

    I think I should edit the black material shader of that prop and add the property of Diffuse, but where to connect it?

  • edited January 13

    It depends on what shader each prop's material uses. The script's default values are intended for the DAZ shader used by your provided example - it may need to be changed / removed for objects that use a different shader.

    For URP Lit materials, the default Highlight effect should kick in. Or, you can add the script but set "Property Name" to "_BaseColor".

  • I'll try. Let see how it goes. Thanks Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.