Search Unity

[Official] Removing some fixed function shader functions for 5.0?

Discussion in 'Shaders' started by Aras, Jun 5, 2014.

?

What say you?

  1. Yes please

    114 vote(s)
    77.0%
  2. Noooo! I needs them!

    14 vote(s)
    9.5%
  3. What is this I don't even

    20 vote(s)
    13.5%
  1. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Aras, what's the best avenue to suggest/report Cg/ShaderLab-related requests and suggestions.. I don't think the Unity Bug Reporter is the way to go here, is it? I mean for some info to actually reach the actual group of people taking care of Cg/ShaderLab in the Unity core team, rather than the people receiving and analysing crash-logs etc. and ending up in an issue-database of lowest-prio "look at this much much later, it's just some crazy dude's shading antics, not a crash or bug really breaking the overall Unity experience" inside your bug-tracker, if you get my drift?

    For example if "someone" was to say "SM3 array-textures support and 10_10_10_2 RtFormat are really crucially necessary in the next minor version I think", who exactly could this someone pester effectively. He might get rejected, but at least he gets to make his case.. :D
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    I don't think that's how bug processing works. QA is trying to weed through all incoming bugs, but bugs with higher "rating" (more recent unity version, more details entered, something attached etc.) are processed first.

    Probably best is to report a bug, and then poke people (on twitter :)) with case numbers.

    10.10.10.2 render texture format is coming in 5.0 by the way. Texture arrays, probably not. What is "SM3 array-textures", I don't know (since regular "texture arrays" are SM4+).
     
  3. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Ah, I guess in DX parlance that's the case. In GL, we had them since OpenGL 3.0 and GL-ES 3 so for me I lazily call this "SM 3" (my bad) and it's really fairly old, I mean, mature stuff.

    What's the problem with array-textures though? They enable all kinds of cool shaderificalities or allow for better ways of doing normal stuff with fewer sampler-bindings / acrobatics / passes. Tiled-atlasing, solved. Single-pass terrain shading, awesome additional possibilities (for 3rd party terrain shading package authors and hobbyist shader coders). Broader batching/mesh-combining possibilities (3rd party can script this for Asset Store)...

    Look, most of the onus would be on shader authors choosing to utilize them at their own risk via #pragma target 4 (no necessityy for UT to utilize them in the out-of-box shaders if you don't want to) if only there were a "dumb and simple" but indeed simply existing Shader.SetGlobalArrayTexture(..) method in Unity's API... ;)

    Insanely glad to hear about 10_10_10_2 support coming up. U 4.6 would be a dream come true, but U 5 I can also live with I guess ^_^
     
    Last edited: Jun 12, 2014
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    No problems with them at all. Just... they don't magically happen, without someone implementing support for them ;)
     
  5. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Sure, I mean we all here code software in some form or shape so the utter lack of magic involved is pretty much a given.. but now you make it sound like UT is a little understaffed! :D
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    A very long time ago.
    But it of limited use for quite a bit of pain in Unity due to it being one of the most undocumented combiners that was made partially due to how other parts of Unity worked that never were envisioned to work with 'dinosaur' tech ;)
    My point was more in the context of its importance in general, not in the context of Unity where relevant related FFP fuctionality never got implemented during FFP days :)

    I used it (better DirectX7s Dot3) quite regularly though in Blitz3D and my own DX7 renderer to fight high poly performance hits through baking a normal map in NVIDIAs PS6 plugin back in the days.

    Nowadays I obviously don't give a damn about it anymore as it is of not use, hardware that can't do SM2 reasonably will even more likely fail to properly execute the dot3 related functionality.
     
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, if you are going to remove fixed-function pipeline... at least add a way of setting up something like, "basic materials" where you use texture combiner functions there. that way, no messy shaderlab! :)

    And there is still some iPhone models that are FFP only, i think.
     
  8. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    I'm not talking about removing fixed function pipeline (or "not yet", anyway). This thread is "can we remove some fixed function pipeline features that are rarely used, but complicate our own internal code quite a lot". Anyway, all what I wrote in the original post is done for Unity 5.0 now, so basically, fixed function TexGen/TextureMatrices are gone; exotic SetTexture modes are gone. Everything else stays.
     
  9. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    @Aras not relevant to this forum post but while you are here; Would it be possible to add a feature to the replacement shaders like an option for selecting whether to overwrite the original shader or add as new pass to it with a defined blend option?
     
  10. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    So basically, dot3 product is gone... :(

    But then again, it wasn't documented, so no one knew about it, at least I can stay on 4.5 (or 4.6 when it comes out) for now t use it. But if the TexGen modes are gone... How come it's so complex in code? in GL, it's just a binder in a function call as far as I know. (but then again DX9/11 always made things hard for fixed-function pipelines... ;))

    Either way, nice to hear it hasn't been completely killed off yet. Means I can make some N64-syle Unity games still! :D And I guess it also means for custom texture coords, like cubemap or normal, we use vertex programs for that... :)

    @aubergine: Are you talking about shader replacement for cameras? if so, that's a nice idea! :) Would be nice to be able to blend two cams together. if not though, I will shut up promptly... :D
     
  11. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    As I understand it, the complexity comes from the fact that on most platforms, Unity doesn't even use the fixed function pipeline. It instead re-implements the fixed function pipeline in the programmable one, allowing you to mix shader writing styles without running into mixed precision issues.
     
  12. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Yeah, what Daniel said. Also, on a lot of other platforms fixed function simply does not exist (all mobile, d3d11, all consoles).
     
  13. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, we all know DX11 ditched FFP, consoles are a bit of a mixed bag, and as for mobiles... that depends on what the hardware gurus put into the phone (or tablet) themselves. In that case, go ahead and ditch it: I will find some sort of old-school love somewhere in the new version... :)
     
  14. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    It does not "depend"... OpenGL ES 2.0 (and later) does not have fixed function.
     
  15. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Oh! thanks for clearing that up with me. :D I was more talking about what the hardware supports, not the actual GLES version! :)
     
  16. jamesflowerdew

    jamesflowerdew

    Joined:
    Apr 29, 2009
    Posts:
    10
    I don't know what unity 5's shader support will be like, but I have a huge preference for fixed function shaders currently, despite having more than dipped my fingers in both surface and vertex/fragment shaders.

    -The code is smaller an easier to read.
    -you made it, we bought it, we've spent hours with it, please maintain it.
    -In my limited experience they are frequently faster (comedy faster), even on machines that rock, despite whatever recompiling does to them.
    -third party shader editors are a drag imho(platform compatibility/performance/upgrading/more learning/etc), and encourage sloppy un-optimised code, and should not be seen as alternatives to coding direct in any language.

    Why not add to them, instead of losing functionality? Many games that pre-date direct x 9 have effects that I'd struggle to implement now using just shaderlab.
     
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Fixed function shaders aren't very good at all, and surface shaders or vert/frag are almost the same but give you so much more power (and speed).

    All your effects you struggle with, the forum will help you replicate. Please post a thread about converting your fixed function shaders to shaderlab, you will be helped and the Unity code base will run faster, more efficiently and everyone wins, including you. Better than holding unity back with outdated techniques for hardware it no longer supports or even runs on.

    A shaderlab shader will often run tonnes faster than an internally converted fixed function shader, which will use floats or half for everything.
     
  18. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Agreed.
    That should never be the case. If you see it, file a bug and let us know!

    Because some of the ways we had them implemented were slowing everything down. More parameters & data passed around in functions, more state being tracked, more decisions deferred "until draw time" - it's a lot of stuff that has overhead even when you don't use fixed function.[/QUOTE]
     
  19. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, one obvious thing is that DX11 isn't fixed-function, but DX9 is. And OpenGL has had a fixed-function pipeline for years.

    In either case, just remove it from DX11 pipeline, as it would require shader emulation.

    For what I would do, I would have a read-once shader parser that passes in the fixed-function shader, and builds a struct that would call the relevant FFP methods when the object's being drawn (SetTexture, Dot3, etc...)

    But if DX11 is being used, such thing would acknowledge the lack of FFP, and would build an actual shader that emulates such stuff. maybe a way to do it would be inserting lines of pre-typed optimized CG code that does this into a single file, then run it like that? That way, problems with coordinating such code would be gone.

    Note this is judged on my knowledge of DX9 in C++, of which I am still learning, so correct me if I'm wrong! :D
     
  20. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    That's a good idea, but Unity has already been doing this for some time. Removing the discussed features reduces the complexity of the translation process.
     
  21. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hmm... I can see how complex that is, but shader assembly?! Sounds like something John Carmack would do... :D
    Anyway, if it's that problematic, then go ahead and wipe it! Simple... :)
     
  22. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    If you think shader assembly is hard, try generating shaders in undocumented shader bytecode (DX11!)...

    Aaaanyway. We aren't removing "fixed function shaders". Just removing some of the more exotic & rarely used features from them (see original post).
     
    FuzzyQuills and shkar-noori like this.
  23. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Yes, some people didn't get that, did they? :D

    And I know dot3 and texgen is probably going to disappear... but what else was going to vanish? o_O

    Love this one... I have actually seen one of my simple lighting shaders in assembly, and it is definitely not that complex! Still, better to write using HLSL (or CG)
     
  24. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    What is written in 5.0 release notes near "Shaders: Removed some fixed-function shader features" section http://unity3d.com/unity/beta/5.0/release-notes
     
    shkar-noori likes this.
  25. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hmm... can't find it anywhere in that huge list!

    But I did find something on better shadow filtering, and I am definitely interested! :) 5x5 PCF would definitely suit Unity 5's new renderer... :D
     
  26. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    It's in the beta 9 section:
     
  27. Alexey2005

    Alexey2005

    Joined:
    Nov 12, 2014
    Posts:
    1
    Aras, could you tell me how MirrorReflection.shader from "Character Customization" live demo should be now?
    http://unity3d.com/showcase/live-demos#character-customization

    The previous version of it was this:

    Shader "FX/Mirror Reflection" {
    Properties {
    _MainTex ("Base (RGB)", 2D) = "white" {}
    _ReflectionTex ("Reflection", 2D) = "white" { TexGen ObjectLinear }
    }

    // two texture cards: full thing
    Subshader {
    Pass {
    SetTexture[_MainTex] { combine texture }
    SetTexture[_ReflectionTex] { matrix [_ProjMatrix] combine texture * previous }
    }
    }

    // fallback: just main texture
    Subshader {
    Pass {
    SetTexture [_MainTex] { combine texture }
    }
    }

    }
     

    Attached Files:

  28. hashashin

    hashashin

    Joined:
    Mar 31, 2014
    Posts:
    22
    now that TexGen is gone, how does one rewrite a shader that uses it? Specially when the shader wasn't written by us, and we can't understand a thing on how this works?
     
  29. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521