Search Unity

Shader documentation (WPOS definition)

Discussion in 'Shaders' started by Stephane-Imbert, Feb 25, 2015.

  1. Stephane-Imbert

    Stephane-Imbert

    Joined:
    Dec 30, 2014
    Posts:
    14
    I am running through the following shader documentation:
    http://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html

    If I try to straight up run some of the shaders provided I run into a few different issues, which makes me wonder if my project is set up differently than expected or if the documentation is outdated. Note that I am using Unity 4.6.3.

    1) Issue #1: Custom/WindowCoordinates/Base shader
    If I divide the WPOS parameter by _ScreenParams in the frag function, the entire poly turns black.
    To get the results shown in the screenshot, I need to use the WPOS parameter as is.

    return fixed4(sp.xy/_ScreenParams.xy,0.0,1.0); // ==> all black
    return fixed4(sp.xy,0.0,1.0); // ==> as shown on screenshot

    Same issue with other shaders dividing by _ScreenParams on that page.

    2) Issue #2: Custom/WindowCoordinates/Bars shader​

    Shader does not compile because of the following error:
    Shader error in 'Custom/Bkg Tint+Tile': 'vert': function return value missing semantics at line 15

    Thanks.
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    According to this post, WPOS is legacy function and Unity wants us to use VPOS instead:

    Hope it helps!