Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by warby · Mar 26, 2012 at 10:06 AM · shadershaderspost-process-effectdisplacementssao

vertex displacement shader and ssao

hi

we are using a bunch of vertex shaders in our game that applies sinus curves to vert positions so that all kinds of foliage can sway in the wind.

when i turn on the build in screen space ambient occlusion too the "darkend" areas remain static where the grass originally was before it started displacing.

what do i need to change on the shader (or ssao image effect) to make these 2 effects play along together nicely ?

http://warby.bitproll.de/misc/ssao_doesnt_get_displaced.jpg

... the ssao grabs what exactly from the frame buffer to perform its magic ? the normals ? also the depth right ? could it be that my displacement/wobble/shader doesnt update one of them in the framebuffer and needs some extra code to do it:

     Shader "ese_wobble_masked_pixellit"
 {
     Properties 
     {
 _MainTex("_MainTex", 2D) = "white" {}
 _frequency("_frequency", Float) = 1
 _speed("_speed", Float) = 1
 _scale_x("_scale_x", Float) = 0.1
 _scale_y("_scale_y", Float) = 0.1
 _scale_z("_scale_z", Float) = 1
 _alpha_threshold("_alpha_threshold", Range(0.01,0.99) ) = 0.5
 
     }
     
     SubShader 
     {
         Tags
         {
 "Queue"="Geometry"
 "IgnoreProjector"="True"
 "RenderType"="TransparentCutout"
 
         }
 
         
 Cull Off
 ZWrite On
 ZTest LEqual
 ColorMask RGBA
 Fog{
 }
 
 
         CGPROGRAM
 #pragma surface surf Lambert  addshadow vertex:vert nolightmap noforwardadd
 #pragma target 2.0
 
 
 sampler2D _MainTex;
 float _frequency;
 float _speed;
 float _scale_x;
 float _scale_y;
 float _scale_z;
 float _alpha_threshold;
 
             
             struct Input {
                 float2 uv_MainTex;
                 float4 color : COLOR;
 
             };
 
             void vert (inout appdata_full v, out Input o) {
                 float4 Splat2=v.texcoord1.y;
                 float4 Splat1=v.texcoord1.x;
                 float4 Multiply4=_Time * _speed.xxxx;
                 float4 Add2=v.vertex + Multiply4;
                 float4 Splat3=Add2.z;
                 float4 Multiply3=Splat3 * _frequency.xxxx;
                 float4 Add4=Splat1 + Multiply3;
                 float4 Sin1=sin(Add4);
                 float4 Multiply0=_scale_x.xxxx * Sin1;
                 float4 Multiply2=_scale_y.xxxx * Sin1;
                 float4 Multiply5=_scale_z.xxxx * Sin1;
                 float4 Assemble0=float4(Multiply0.x, Multiply2.y, Multiply5.z, 0);
                 float4 Multiply7=Splat2 * Assemble0;
                 float4 Add1=Multiply7 + v.vertex;
                 float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
                 float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
                 float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
                 v.vertex = Add1;
             }
             
 
             void surf (Input IN, inout SurfaceOutput o) {
                 o.Normal = float3(0.0,0.0,1.0);
                 o.Alpha = 1.0;
                 o.Albedo = 0.0;
                 o.Emission = 0.0;
                 o.Gloss = 0.0;
                 o.Specular = 0.0;
                 
                 float4 Tex2D0=tex2D(_MainTex,(IN.uv_MainTex.xyxy).xy);
                 float4 Multiply0=Tex2D0 * IN.color;
                 float4 Subtract0=Tex2D0.aaaa - _alpha_threshold.xxxx;
                 clip( Subtract0 );
                 o.Albedo = Multiply0;
             }
         ENDCG
     }
     Fallback "Transparent/Cutout/VertexLit"
 }


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Displace and show normals in fragment shader 1 Answer

Setting depth buffer per-fragment 2 Answers

What is the meaning of a vertex shader for a post-processing shader? 1 Answer

HLSL Post Process Shader Fixing UV/Texcoord 1 Answer

Why doesn't this shader work when using it with as a custom effect on the post processing stack 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges