float3 getNewVertPos(float3 pos){ float4 hoge = float4(0,0,0,0); hoge.y = _Amp+_Amp*sin( (pos.x*_Detail.x+pos.z*_Detail.z) *3.1415 + _Time.y*4 ); hoge.y *= step(0,pos.y);//マイナスyは無効化する return pos + hoge; } float3 getNewNormal(float3 pos, float3 normal, float3 tangent){ float3 vertPosition = getNewVertPos( pos ); // calculate the bitangent (sometimes called binormal) from the cross product of the normal and the tangent float3 bitangent = cross( normal, tangent ); // how far we want to offset our vert position to calculate the new normal float vertOffset = 0.01; float3 v1 = getNewVertPos( pos + tangent * vertOffset ); float3 v2 = getNewVertPos( pos + bitangent * vertOffset ); // now we can create new tangents and bitangents based on the deformed positions float3 newTangent = v1 - vertPosition; float3 newBitangent = v2 - vertPosition; float3 outNormal = cross(newTangent,newBitangent); return outNormal; }