Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

self illuminated, alpha shader

Discussion in 'Shaders' started by phoen, Jan 27, 2006.

  1. phoen

    phoen

    Joined:
    Oct 25, 2005
    Posts:
    94
    A combination of the self illuminated shader and one that uses an alpha channel for transparency would be great. I plan using painted highlights and shadows on textures exclusively for "lightning" the environment. I tried for some hours but didnt get anything usable. help greatly appreciated. p.
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    The self illuminated shader is great right now for creating "lightmaps" in the alpha channel, I use it a lot for manual control of light intensity gradations. But it's expensive cpu wise (as all 32 bit textures are) and adding another 8 bit channel for transparency just seems loco (unless you're talking about using the same 8 bit channel for the illumination and the transparency, which would take a great level of ingenuity, and would never work for 100% of the situations).

    And so once again back to my plight of the Vertex Color shader that is 32 bit... this would partially solve the transparency/illumination problem and many others. I'm working on it tonight and am stuck on "DiffuseDot3"... this seems to be the input I need, but no such luck on getting it to multiply against the texture file. Have you guys updated the shader tuts since including Vertex Color import in 1.2? Total nightmare so far figuring this stuff out, I enjoy the challenge... but just one single pointer in the right direction would be most appreciated and would save me days of "knees and elbows".
     
  3. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    I'm feeling a little confused why vertex color support is getting the silent treatment here. About a half dozen questions have been asked about it (not just me) and zero replies from the OTEE crew in all those threads. I'm really just curious... is it just a really stupid feature? No benefits what so ever? Is it only supported by a few 3D programs so why waste the time? Too computationally expensive? Doesn't fit into the OpenGL specs on the Mac? FBX support of vertex data is unwieldy? Just use Diffuse shaders and shut the hell up?

    I could ask on this forum "why can't I use 20 sided polygons in my game", and I'd get a dozen replies explaining why I can't. If the vertex color question is so stupid, give me a stupid answer... "Silly rabbit, everyone knows vertex colors are for kids".

    Or just give me the syntax involving the input channel to vertex colors so I can try to figure this out on my own... Seriously, it's hard enough to even know if the data has been properly imported, let alone know if I'm writing the shader correctly. Too many unknown variables.
     
  4. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Sorry for not posting earlier. This thread has been sorta my bad conscience. there are 2 things that need to happen for vertex colors to behave as they should;

    1) I need to fix a really important bug for them to ACTUALLY work - it runs fine in the bleeding edge Unity, but not at all in the stable version.
    2) The shading systems all shaders should be modified to actually make use of vertex colors if available.

    I'm sorry for doing the wall of silence... Just having kept telling me 'I'll look at it tomorrow' for too long.

    Let me fix the bug for next release and put out a shader that shows how to use it. Modifying ALL shaders might get quite a big job, though...
     
  5. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    Sorry for wandering a bit off topic, but...

    I don't suppose there's a universal binary of the bleeding edge version for testing, is there? :roll:

    Tom
     
  6. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    No chance. That's where we do all the unstable dev and Intifada.... And trust me, you wouldn't want to ;)
     
  7. phoen

    phoen

    Joined:
    Oct 25, 2005
    Posts:
    94
    So can we expect vertex colors in 1.2.2? :D

    The alpa-vertexlit shader would work for me but it seems to have a problem with depth sorting when moving the camera. (other vertexlit shaders as well)
     

    Attached Files:

  8. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Hey Nicholas, thanks a lot for some feedback on the topic. Glad to know you at least believe it's a worthwhle shader to develop, and it sounds like a really big job if you have to tweak EVERY shader to incorporate this. And I've learned a little bit about writing shaders trying to figure this out so time well spent... a very little bit though (this is tough stuff). Hey, just a question about the "OpenGL Shader Builder.app" in the Apple Dev tools. Does this process have any correlation to shaders in Unity? I'm assuming no.
     
  9. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Another question slightly off topic, please excuse my lack of knowledge. ;)

    We can use CG in our shaders, but is there any restriction (besides hardware) with what CG commands, effects, etc that we can use? For example could we take sample shaders with CG code and modify them without much hassle into ShaderLab, or would it require a re-write?

    Could we for example write our own shadow shader?

    Thanks,
    -Jeremy
     
  10. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    In general, you basically embed the CG code in some state settings and its fine. Possibly you need minor tweaks to your Cg files.

    Shadows, however, cannot be done in a shader alone, as they work on object interaction.
     
  11. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Wonderful, thanks for the info nicholas.

    What is required to allow shadow shaders? Something to do with scene matrices or something (guessing here ;)) Any chance of getting access to whatever data we need for it through ShaderLab in the not-too-distant future releases?

    -Jeremy
     
  12. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    We include a bunch of matrices in shaderlab (we need them too ;-))

    Take a look at /Application/Unity/Unity.app/Contents/CGIncludes/UnityCG.cginc

    this declares all built-in matrices, values, etc...

    Also our built-in shaders contain a lot of stuff to get you started. http://forum.otee.dk/viewtopic.php?t=940
     
  13. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Ok, I will play around a bit.

    Does Unity indie in the current version provide access to all of the data, etc required to do shadowing? Or is more info required from the engine?

    Thanks,
    -Jeremy
     
  14. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Any answers? Do we have access in the current indie version to the data/functions we need to do proper shadowing of any kind? Or, even better, are you planning on adding shadows (besides the blob) soon? :wink:

    Thanks,
    -Jeremy
     
  15. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Sorry... Missed this one.

    At the moment, there is not enough info by a long shot to do shadows. The nasty thing about shadows is that it pretty much cuts across the whole rendering pipeline... Hence it is not something that's feasible before 2.0
     
  16. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Ok, that makes sense.

    Thanks nicholas,
    -Jeremy