Search Issue Tracker

Fixed

Votes

0

Found in

5.2.1f1

Issue ID

740219

Regression

No

[Shaders] hlsl2glsl resolves some function overloads differently from HLSL, mostly with mixed vector types

WebGL

-

User wrote a custom shader for particles. I use distance() to measure a pixel's UV distance with the particle center. This works fine in editor, and on PC and webplayer builds. However, it does not work in WebGL (Firefox 41.0.2). Replacing the calculation with length() works.

Repro:
--Open the Main.unity scene and play it in the editor
--you should see the white particles
--Make a WebGL build
--play it in browser
--NOTICE that the particles are not rendering and no error or warning is thrown

The problem seems to be in shader code that does "distance(uv, float2(0.5,0.5))", with uv being a float4 - hlsl2glsl shader translator picks a float4 overload, whereas actual HLSL compiler picks a float2 overload. Changing code to "distance(uv.xy, float2(0.5,0.5))" fixes the issue.

Comments (1)

  1. shubhamswaraj2021

    Aug 21, 2020 05:51

    good one <a href="https://www.lyricsauto.com">lyricsauto</a>

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.