Unity Community


Page 2 of 6 FirstFirst 1234 ... LastLast
Results 21 to 40 of 108

  1. Posts
    59
    Quote Originally Posted by hippocoder View Post
    • Soon on Asset Store!

    Will this be out soon on asset store?
    It says so doesn't it? I know it's hard to be patient with all the shiny new stuff going on here. Relax a little bit and go explore all the other new features you just got. Whenever they're ready for it, it will come out.

  2. Code Maker

    Location
    Canberra
    Posts
    849
    I have no more information then you guys on this, but I would assume that it will not be on the asset store till 3.5 final is released. We wouldn't want 3.4 users to download something that would not work for them.
    Have you tried the Strumpy Shader Editor?


  3. Location
    Trondheim, Norway
    Posts
    900
    Is there any good light probe examples around?

    I've been messing about with them, but I'm not really getting the results I want. And the workflow is a bit odd.

    Also, the "needs to form a volume" part confuses me. I'm testing with a room divided into 4 sections with a flat floor so I place all my probes at the same height where my character will walk. But it refuses to bake until I position one of them above the other. Why must I do that? I'm looking at the example images in the documentation and if there character wouldn't have been able to walk up onto those cubes every probe would be at the same height there as well.

    Also, why do you add probes as a component on objects? Currently I'm just selecting a random object in my scene and then adding every single probe to that one. Is that wrong? Should probes be put on the objects closest to it?

    I was expecting light probes to be separate game objects so I could easily manage them in my scene hiearchy.


  4. Location
    Trondheim, Norway
    Posts
    900
    Attached is what I'm currently fiddling with.

    I keep getting a green tint in the red room and both a red and yellow tint behind the wall where there should be no light. Also the transition between the red and green room doesn't work at all, but between the green and blue room it works perfectly.

    Not really sure why and how to fix it. I'm guessing it has to do with the lines going between the probes?
    Attached Images  


  5. Location
    England
    Posts
    257
    I'm adding all my probes to an empty object that I created to hold them.

    Dunno if that's what you're meant to do or what.

  6. Unity Developer

    Location
    Copenhagen
    Posts
    185
    Quote Originally Posted by TwiiK View Post
    Also, the "needs to form a volume" part confuses me. I'm testing with a room divided into 4 sections with a flat floor so I place all my probes at the same height where my character will walk. But it refuses to bake until I position one of them above the other. Why must I do that?
    The reason is that the volume formed by the probes is tetrahedralized (divided into tetrahedra). This process cannot be done when all the probes are coplanar.

    Unfortunately a 2D mode (with triangulation instead of tethrahedralization) will not make it into 3.5 because of the time constraints.

    To handle cases like yours one can vary the height at which the probes are positioned. If it's important to capture lighting at a very specific height it might be better to duplicate the probes vertically. Don't worry about performance, place probes in a way that makes the interesting changes in lighting be captured and the tetrahedra to be shaped nicely (e.g. no looong tetrahedra).

    Quote Originally Posted by TwiiK View Post
    I'm looking at the example images in the documentation and if there character wouldn't have been able to walk up onto those cubes every probe would be at the same height there as well.
    They would not be able to be at the same height because of the reason mentioned above.

    Quote Originally Posted by TwiiK View Post
    Also, why do you add probes as a component on objects? Currently I'm just selecting a random object in my scene and then adding every single probe to that one. Is that wrong? Should probes be put on the objects closest to it?

    I was expecting light probes to be separate game objects so I could easily manage them in my scene hiearchy.
    Light Probe Group can be added to an empty game object and all the probes can be created in that one group.

    One can also add Light Probe Groups to game objects that are parts of prefabs (like a building, room, etc.). The light probe positions are stored relatively to the game object having the Light Probe Group component, so that when you instantiate the prefab with such a game object the light probe positions are affected by the object's position and rotation.

    This helps a lot when placing the probes, but only then, Light Probe Groups do not exist at runtime.
    At bake time all the probes within the scene are used as one cloud of points anyways.


  7. Location
    Trondheim, Norway
    Posts
    900
    Thanks for the reply, clears it up quite a bit.

    Having them as part of prefabs makes sense.

    As for the weird lighting I'm experiencing, I'm gradually improving it so I guess it's just about learning where to place the probes.


  8. Location
    England
    Posts
    257
    I've got normal mapped light-probe light working on my characters, by adding the following line of code to the end of the .shader file

    Code:  
    1. .Emission = o.Albedo * ShadeSH9 (float4(o.Normal,0.0));

    Just after the "o.Normal = normalize(o.Normal);" line.

    This gives me albedo lighting but no specularity, which is good enough for me.

  9. rea rea is offline

    Posts
    716
    Quote Originally Posted by Zomby138 View Post
    I've got normal mapped light-probe light working on my characters, by adding the following line of code to the end of the .shader file

    Code:  
    1. .Emission = o.Albedo * ShadeSH9 (float4(o.Normal,0.0));

    Just after the "o.Normal = normalize(o.Normal);" line.

    This gives me albedo lighting but no specularity, which is good enough for me.
    So now we need to adding those line to every built in shader?(Depend on what do you need) O.o


  10. Location
    England
    Posts
    257
    That's what I'll be doing till we get a more automated solution.


  11. Posts
    42
    thanks zomby, here's my custom shader :

    Code:  
    1. Shader "Custom Bumped Diffuse" {
    2. Properties {
    3.     _Color ("Main Color", Color) = (1,1,1,1)
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5.     _BumpMap ("Normalmap", 2D) = "bump" {}
    6. }
    7.  
    8. SubShader {
    9.     Tags { "RenderType"="Opaque" }
    10.     LOD 300
    11.  
    12. CGPROGRAM
    13. #pragma surface cussurf Wrap
    14.  
    15. sampler2D _MainTex;
    16. sampler2D _BumpMap;
    17. fixed4 _Color;
    18.  
    19.  
    20. struct Input {
    21.     float2 uv_MainTex;
    22.     float2 uv_BumpMap;
    23. };
    24.  
    25. half4 LightingWrap (SurfaceOutput s, half3 dir, half atten ) {
    26.       dir = normalize(dir);
    27.       half diff = dot (s.Normal, dir)*.8+.2;
    28.       half4 c;
    29.       half3 sh= ShadeSH9 (float4(s.Normal,1.0));
    30.       c.rgb = (s.Albedo * sh * diff) * atten *2 ;
    31.       c.a = s.Alpha;
    32.       return c;
    33. }
    34.  
    35. void cussurf (Input IN, inout SurfaceOutput o) {
    36.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    37.     o.Alpha = c.a;
    38.     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    39.     o.Albedo = c.rgb;
    40. }
    41. ENDCG  
    42. }
    43.  
    44. FallBack "Diffuse"
    45. }

    Not perfect, but good enough for testing until a better shader comes out.

  12. Unity Developer

    Location
    Copenhagen
    Posts
    185
    Zomby138, rea, pixoloco: guys, srsly? :> I said world space normal...

    Quote Originally Posted by Kuba View Post
    SH can of course be decoded per pixel. You will need to transform the normal from the normal map from tangent space into world space and pass into ShadeSH9.

  13. rea rea is offline

    Posts
    716
    Quote Originally Posted by Kuba View Post
    Zomby138, rea, pixoloco: guys, srsly? :> I said world space normal...
    Uhhh???? sorry kinda confused here @_@


  14. Posts
    42
    With my understanding of shader programming, you could have said Atomic spaced normal maps , the result would have been the same
    If you have a better shader, feel free to share. We won't tell anybody, promise

  15. Super Moderator
    Location
    Unity Technologies HQ, Copenhagen
    Posts
    238
    As Kuba said, it has to be the world space normal that is used to sample SH. But that's just common sense. After all the SH data is set in the uniforms, so it's the same values for all the pixels of the object. If you sample SH with normals say perpendicular to the surface, in tangent space they have the same coordinates across the mesh, so they will (incorrectly) return the same values. There's a comparison in the attached image.

    Here's the Bumped Diffuse shader, patched to use light probes per pixel, to get what you see on the sphere in the middle.

    Code:  
    1. Shader "Bumped Diffuse, Per Pixel Probes" {
    2. Properties {
    3.     _Color ("Main Color", Color) = (1,1,1,1)
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5.     _BumpMap ("Normalmap", 2D) = "bump" {}
    6. }
    7.  
    8. SubShader {
    9.     Tags { "RenderType"="Opaque" }
    10.     LOD 300
    11.  
    12. CGPROGRAM
    13. #pragma surface surf Lambert novertexlights
    14. #pragma exclude_renderers flash
    15.  
    16. sampler2D _MainTex;
    17. sampler2D _BumpMap;
    18. fixed4 _Color;
    19.  
    20. struct Input {
    21.     float2 uv_MainTex;
    22.     float2 uv_BumpMap;
    23.     fixed3 worldNormal;
    24.     INTERNAL_DATA
    25. };
    26.  
    27. void surf (Input IN, inout SurfaceOutput o) {
    28.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    29.     o.Albedo = c.rgb;
    30.     o.Alpha = c.a;
    31.     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    32.     fixed3 worldN = WorldNormalVector (IN, o.Normal);
    33.     o.Emission = ShadeSH9 (fixed4(worldN,1.0));
    34. }
    35. ENDCG  
    36. }
    37.  
    38. FallBack "Diffuse"
    39. }

    It's just using the world space normal as described in the docs, so the added stuff is two last lines in the Input struct and two last lines in the surface function. There's also the novertexlights keyword to disable the built-in sampling of SH to avoid double lighting (noambient could be used as well).
    Attached Images  

  16. Super Moderator
    Location
    Unity Technologies HQ, Copenhagen
    Posts
    238
    Quote Originally Posted by TwiiK View Post
    I keep getting a green tint in the red room and both a red and yellow tint behind the wall where there should be no light. Also the transition between the red and green room doesn't work at all, but between the green and blue room it works perfectly.

    Not really sure why and how to fix it. I'm guessing it has to do with the lines going between the probes?
    Again, as Kuba said your scene could really benefit from a 2D flat probe bake, but we had to postpone implementing handling of this special case for the next release. In the meantime it's possible to use light probes for flat scenes, but it requires some extra care: you have to make sure that the light probes really form a volume. Adding them flat and just lifting one a little bit won't cut it, as that will lead to long and thin tetrahedra, which connect one end of your scene with the other and you will get some weird interpolation.

    Instead you should add a couple of probes say 1-2 units higher. You will see that the connections no longer go from one end of the scene to the other and you should get the correct interpolation.

    To better see what's going on and which probes are being used, when the Scene View is in the Light Probes drawing mode (upper left corner drop down), select the renderer that is using the light probes (your character's skinned mesh renderer in this case). You will see a small probe drawn on top of it (that's the preview of the probe that will actually be used for rendering) and 4 or 3 blue lines connecting him to the probes that make up the averaged probe. Play around with the placement of the probes to see how it affects the tetrahedra structure showed by the yellow lines and which probes are then picked by the blue lines.

    You'll see that when the probes form a volume in your scene, things become nicely predictable.


  17. Posts
    42
    Thanks a lot for the shader and the explanation !

  18. Super Moderator
    Location
    Unity Technologies HQ, Copenhagen
    Posts
    238


  19. Location
    Brazil
    Posts
    1,503
    Robert got a fan here.
    Thank you very much for that.


  20. Posts
    1,579
    Is there some sort of Light probe tutorial (or documentation rather). I'm kind of just blindly trying to work the light probes. I would like to know the whole baking/placement/proper lighting process. I know there probably isn't, since it's such a new feature :/
    Last edited by TehWut; 12-27-2011 at 10:09 AM.
    Completely new to game development and Unity? don't know where to start? You don't have to be a n00b, click here and you'll be a pro in no time! The complete scripting series will bring you from zero to hero!

    Really guys, get over it. Everyone these days wants a MMO not single player. I know we should start out small but times have changed. Anymore in the game industry no matter how small or large you have to go big or go home!

Page 2 of 6 FirstFirst 1234 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •