Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by Stijn500 · May 28 at 06:46 PM · shadersspherenormalsprojectionbumpmap

Artifacts on applying bump map to sphere

I'm making a planet generator. This generator creates multiple textures, including 1 for the terrain and 1 for the bumpmap. These textures are then applied to an icosahedron. However when applying the bump map I get an artifact at the top of the sphere.

alt text

alt text

When only using the terrain texture I don't get this same artifact and so everything seems normal. I'm not sure what causes this only to happen when using a bump map.

To generate the bump map I use the following compute shader.

 [numthreads( 8, 8, 1 )]
 void ComputeNormal( uint3 id : SV_DispatchThreadID )
 {
     float3 pos = GetPosition( id.x, id.y );
     float3 xLeftPos = GetPosition( id.x - 1, id.y );
     float3 xRightPos = GetPosition( id.x + 1, id.y );
     float3 yUpPos = GetPosition( id.x, id.y + 1 );
     float3 yDownPos = GetPosition( id.x, id.y - 1 );
 
     fnl_state noise_compute = fnlCreateState();
     noise_compute.seed = _TerrainFrequency;
     noise_compute.noise_type = FNL_NOISE_OPENSIMPLEX2;
     noise_compute.fractal_type = FNL_FRACTAL_FBM;
     noise_compute.frequency = _TerrainFrequency;
     noise_compute.octaves = _TerrainOctaves;
     noise_compute.gain = _TerrainPersistence;
     noise_compute.lacunarity = _TerrainLacunarity;
 
 
     float n = fnlGetNoise3D( noise_compute, pos.x, pos.y, pos.z );
     float strength = n < 0.3f ? 0.1f : _NormalStrength;
 
     float xLeft = fnlGetNoise3D( noise_compute, xLeftPos.x, xLeftPos.y, xLeftPos.z ) * strength;
     float xRight = fnlGetNoise3D( noise_compute, xRightPos.x, xRightPos.y, xRightPos.z ) * strength;
     float yUp = fnlGetNoise3D( noise_compute, yUpPos.x, yUpPos.y, yUpPos.z ) * strength;
     float yDown = fnlGetNoise3D( noise_compute, yDownPos.x, yDownPos.y, yDownPos.z ) * strength;
 
     float xDelta = ((xLeft - xRight) + 1) * 0.5f;
     float yDelta = ((yUp - yDown) + 1) * 0.5f;
 
     float4 col = float4(xDelta, yDelta, 1.0f, yDelta);
 
     _Noise[indexFromCoord( id.x, id.y )] = col;
 }

Which is called by the following method.

     void CreateNormal() {
         int kernel = PlanetCompute.FindKernel("ComputeNormal");
 
         Color[] colors = ExecuteComputeShader(kernel);
 
         Texture2D texture = new Texture2D(Width, Height, TextureFormat.ARGB32, true);
         texture.SetPixels(colors);
         texture.wrapMode = TextureWrapMode.Clamp;
         texture.Apply();
 
         Material.SetTexture("_BumpMap", texture);
     }

The ExecuteComputeShader method simply sets some properties and dispatches the compute shader.

 PlanetCompute.Dispatch(kernel, Width / m_ComputeNumThreads, Height / m_ComputeNumThreads, 1);


artifact-wireframe.png (316.8 kB)
artifact.png (259.7 kB)
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

166 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to calculate the surface normal Vector3 between two Vector3's on a Sphere. 1 Answer

Shader: blending between normals not working 1 Answer

Displace and show normals in fragment shader 1 Answer

Shader for distorting a texture as if it were on a sphere 3 Answers

Normal from _CameraDepthNormals to screen space angle 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