helmut.bressler Posted May 16, 2013 Posted May 16, 2013 Hello, I have started to investigate the problem https://developer.unigine.com/forum/topic/2027-terrain-decal-and-deferred-decal-ignores-normals-of-terrain/ from the shader side and it seems that in the \data\core\shaders\default\decal\vertex_terrain.shader the tangent space basis is the same for the whole decal: cbuffer shader_decal_parameters { float3 s_decal_normal; float3 s_decal_tangent; float3 s_decal_binormal; what I'am trying to do is to pass the world normal texture generated by the terrain to the vertex shader and use that normal encoded there as normal for the decal per vertex. In my project setup the players modelview matrix serves as view matrix which I can use to determine the texture coordinates for the world normal texture. I don't know if that is a general valid assumption though. I have two questions: The most important: Has this any chance to work? The second question: At the moment the problem seems to be that the vertex shader cannot read the texture correctly, its very likely that it reads just a uniform color. I declared it in my modified vertex_terrain.shader file: Texture2D s_texture_0 : register(t0); I also added the texture into the material: <texture name="normal_terrain" unit="0" pass="deferred,ambient,light_spot,light_omni,light_proj,light_world" filter="bilinear" anisotropy="1">alignex_unigine/normal_terrain.dds</texture> The fragment shader seems to be able to read it, as it correctly shows up on the screen as diffuse texture. I should mention that my material inherits from the decal_terrain_base. The only changes are the replacement of the vertex shader for all passes and I added some shader parameters in order to provide the additional transformation matrices I need and the normal_terrain texture. Thanks, Helmut
frustum Posted July 3, 2013 Posted July 3, 2013 There is no information regarding tangent basis in the terrain vertices. The normal map source for terrain and terrain decals is texture. Terrain decals should refer to corresponded terrain normal texture.
helmut.bressler Posted July 4, 2013 Author Posted July 4, 2013 Thank you, I'm perfectly happy with the update for the deferred decals, I don't have the need to modify the shader source any more :D
frustum Posted August 8, 2013 Posted August 8, 2013 The normal texture slot will be removed from "decal_terrain_base" material. The terrain normal will be automatically passed to the decal shader. So DecalTerrainOrtho with combination of "decal_terrain_base" material is an ideal pair for additional terrain detail textures.
Recommended Posts