Announcement

Collapse
No announcement yet.

Soft & Normal Mapped Sprites

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Soft & Normal Mapped Sprites

    Hi there,
    need help to setup shading network for sprite particles using tangent space normal map to add real-time lighting effect and soft clipping at edge.


    Reference For Sprite Realtime Lighting
    Demo 3
    CryEngine
    VolumeNormal
    Sprite DLight

    Reference For Sprite Soft Edge clipping
    Soft Particles

  • #2
    Easy way to get tangent space normal.
    Nuke Gizmo
    Tangent Space Normals Utilities

    Comment


    • #3
      Here is my test using VectorProduct node (DotProduct,normalize) of NormalTexture and locator position (as light vector).

      On PolyPlane


      On Sprite

      Here is tutorial on how to do in UE, but it seems hard to implement in Maya.
      Advanced Particle Shading & Lighting in UE - 07
      Advanced Particle Shading & Lighting in UE - 08
      Advanced Particle Shading & Lighting in UE - 09
      Advanced Particle Shading & Lighting in UE - 10

      Comment


      • #4
        Found informative article on soft particles

        Soft Particles
        Nvidia Soft Particles
        GLSL Soft Particles

        is it possible to do using Vray ??

        Comment


        • #5
          Why below code is not working using Vray GLSL shader ??
          Code:
          uniform sampler2D colorMap;
          uniform sampler2D depthMap;
          
          varying float depth;
          
          void main() {
          	
          	vec2 coord = gl_FragCoord.xy / vec2(640,360);
          	vec4 depthMapDepth = -texture2D(depthMap, coord).z;
          	vec4 color = texture2D(colorMap, gl_TexCoord[0].st);
          	
          	float scale = 0.2f;
          	float fade = clamp((depthMapDepth.x-depth)*scale, 0.0, 1.0);
          	
          	gl_FragColor = vec4(vec3(color),color.a * fade);
          }

          Comment


          • #6
            one more thing..
            how to render Screen Space UV pass using GLSL ??




            Code for UV pass
            Code:
            #version 110
            void main() {
                // colour is RGBA: u, v, 0, 1
                vec2 uv = vec2(gl_TexCoord[0]);
                gl_FragColor = vec4(uv,0.0, 1.0 );
            }

            Comment


            • #7
              Hello Ruchit,

              V-Ray's GLSL implementation does not support arbitrary varying variables, so the problem with the code you posted is that the 'depth' variable, which is expected to be computed by some vertex shader, remains uninitialized. However, you can use the special built-in varying vr_Position (which represents the intersection point in camera space) in conjunction with gl_DepthRange to calculate the normalized fragment depth. In order for this to work, you need to use VRayPhysicalCamera with properly set 'near clipping plane' and 'far clipping plane' attributes (which correspond to gl_DepthRange.near and gl_DepthRange.far, respectively). Alternatively, if you don't want to deal with camera settings, you could pass the clipping values through plain uniform variables. In both cases you'll have to adjust the clipping values to suit your scene. Here is an example:

              Code:
              #version 110
              
              uniform sampler2D colorMap;
              uniform sampler2D depthMap;
              uniform bool cameraClipping = true;
              uniform float clipNear;
              uniform float clipFar;
              
              void main() {
              	vec2 coord = gl_FragCoord.xy / vec2(640, 360);
              	float depthMapDepth = texture2D(depthMap, coord).z;
              	vec4 color = texture2D(colorMap, gl_TexCoord[0].st);
              	float scale = 0.2;
              	float depth = 0.0;
              
              	if (cameraClipping)
              		depth = (-vr_Position.z - gl_DepthRange.near)/gl_DepthRange.diff;
              	else // manual clipping
              		depth = (-vr_Position.z - clipNear)/(clipFar - clipNear);
              
              	float fade = clamp((depthMapDepth - depth)*scale, 0.0, 1.0);
              	gl_FragColor = vec4(color.rgb, color.a*fade);
              }

              Comment


              • #8
                thnx for code will try that.

                Look at this
                GDC2016 | Realtime FX with Houdini


                It will be great if VRay gives this functionality for Maya sprites.
                My wishlist for next version.

                Comment

                Working...
                X