Terrain Editor

Announcements and news updates to your projects using Urho3D.
Forum rules
If you have images or videos, you can attach them in the showcase post. Please use small thumbnail as link to original media resources.
When you post in this forum, you have to agree that Urho3D main website as well as the Facebook page have the permission to republish your post with all the related images or videos. The original images must have width larger than 890px for best viewing result in all the supported viewports by main website.

Re: Terrain Editor

PostPosted by JTippetts » 05 Jul 2015, 13:34

The project repo ( https://github.com/JTippetts/U3DTerrainEditor ) now has an 8-terrain shader that works for D3D9, D3D11 and GLSL. It successfully builds against the latest Urho3D (pulled yesterday, 7-4). Since I walked away from the project for so long, I'm not really sure where it stands, refactor-wise. I'll probably eliminate most of the experimental shaders I was tinkering with for simplicity, and try to add flexibility to the ones in existence. Additionally, I have a tri-planar shader I'm working on. I'll try to build a new terrain dialog that gives control over shader choice to make it easier to play with.

Edit:
The repo now has the HLSL and GLSL versions of the 8-detail triplanar shader. It's pretty heavyweight, but even on my potato it's still functional in the editor. The tri-planar shader uses the detail blending between layers described in previous posts, along with normal-mapping (enabled by the BUMPMAP option). You can see the difference between the tri-planar shader and the normal shader:

Normal:
Image

Triplanar:
Image
User avatar
JTippetts
Active user
Active user
 
Posts: 129
Joined: 26 Jan 2014, 23:41
Location: United States

Re: Terrain Editor

PostPosted by vivienneanthony » 08 Jul 2015, 18:58

Is this correct?
Code: Select all
<material>
<technique name="Techniques/TerrainBlend8EditTriplanar.xml" />
<texture unit="1" name="Textures/TerrainBlend4/Grass0126_2_S.jpg"/>
<texture unit="2" name="Textures/TerrainBlend4/Desert2.jpg" />
<texture unit="3" name="Textures/TerrainBlend4/Cliff2.jpg" />
<texture unit="4" name="Textures/TerrainBlend4/Cliff3.jpg" />
<parameter name="MatSpecColor" value="0 0 0 1" />
<parameter name="DetailTiling" value="1024 1024" />
<parameter name="BumpStrength" value="128" />
<parameter name="PackTexFactors" value="0.25 0.5 512 9" />
</material>


I asked because I'm getting this response.
Code: Select all
[Wed Jul  8 14:55:51 2015] ERROR: Failed to compile pixel shader TerrainBlend8EditDetailTriplanar(BUMPMAP DIRLIGHT PERPIXEL):
0(1021) : error C7506: OpenGL does not define the global function mul



Image
Office Youtube Page -https://www.youtube.com/user/cgprojectsfx
Official Blog -http://cgprojectsfx.wordpress.com/
Official Deviant -http://cgprojectsfx.deviantart.com

Existence Source
https://sourceforge.net/projects/proteusgameengine/files/Existence/
User avatar
vivienneanthony
Have many posts
Have many posts
 
Posts: 546
Joined: 12 May 2014, 13:21
Location: United States

Re: Terrain Editor

PostPosted by Mike » 09 Jul 2015, 07:32

mul(x, y) should be replaced by x * y in OpenGL
User avatar
Mike
Moderator
Moderator
 
Posts: 353
Joined: 16 Jan 2014, 20:35
Location: France

Re: Terrain Editor

PostPosted by vivienneanthony » 09 Jul 2015, 15:07

Mike wrote:mul(x, y) should be replaced by x * y in OpenGL


The line I see in the glsl file is. Are you refering to that?

Code: Select all
      vec3 normal=normalize(mul((bump1*b1+bump2*b2+bump3*b3+bump4*b4+bump5*b5+bump6*b6+bump7*b7+bump8*b8)/bsum,tbn));
      
Office Youtube Page -https://www.youtube.com/user/cgprojectsfx
Official Blog -http://cgprojectsfx.wordpress.com/
Official Deviant -http://cgprojectsfx.deviantart.com

Existence Source
https://sourceforge.net/projects/proteusgameengine/files/Existence/
User avatar
vivienneanthony
Have many posts
Have many posts
 
Posts: 546
Joined: 12 May 2014, 13:21
Location: United States

Re: Terrain Editor

PostPosted by Mike » 09 Jul 2015, 16:07

Yes, replace by:
Code: Select all
vec3 normal = normalize(tbn * (bump1*b1+bump2*b2+bump3*b3+bump4*b4+bump5*b5+bump6*b6+bump7*b7+bump8*b8) / bsum);
User avatar
Mike
Moderator
Moderator
 
Posts: 353
Joined: 16 Jan 2014, 20:35
Location: France

Re: Terrain Editor

PostPosted by JTippetts » 09 Jul 2015, 21:46

I pushed the changes as Mike suggested. Mike: Is there a chance that some implementations of GLSL might, in fact, provide mul()? I'm no expert at that sort of thing, but I never encountered any errors with the use of mul() while doing my own testing.

Is this correct?

Code: Select all
<material>
<technique name="Techniques/TerrainBlend8EditTriplanar.xml" />
<texture unit="1" name="Textures/TerrainBlend4/Grass0126_2_S.jpg"/>
<texture unit="2" name="Textures/TerrainBlend4/Desert2.jpg" />
<texture unit="3" name="Textures/TerrainBlend4/Cliff2.jpg" />
<texture unit="4" name="Textures/TerrainBlend4/Cliff3.jpg" />
<parameter name="MatSpecColor" value="0 0 0 1" />
<parameter name="DetailTiling" value="1024 1024" />
<parameter name="BumpStrength" value="128" />
<parameter name="PackTexFactors" value="0.25 0.5 512 9" />
</material>



GLSL compilation errors aside, that isn't the correct usage of the shader. Perhaps a bit more explanation of it is in order.

The shader (either 8Detail or 8DetailTriplanar) only uses 3, 4 or 5 texture units. The number used depends on whether or not BUMPMAP and USEMASKTEXTURE are specified as options.

Slot 0: Weight map for terrain types 0,1,2 and 3
Slot 1: Weight map for terrain types 4,5,6 and 7
Slot 2: Terrain texture atlas (more on its format/layout in a bit)
Slot 3: Normal map of terrain texture atlas
Slot 4: Mask texture (provided to allow for visualization of the editing mask in the terrain editor).

The weight maps are straightforward: a value of 0 for a given component corresponding to a terrain type means that terrain type provides no contribution, a value of 1 means it provides full contribution. All weights are balanced in the shader so they add up to 1.

The terrain texture atlas is constructed as an atlas of 8 terrain types. Each type provides the diffuse color in RGB and the height of the texture in A. The height channel is used to alter the blending weight as described earlier in the thread, achieving the effect of terrain such as raised stones more realistically combining with terrain such as dirt, so that dirt tends to fill in the cracks around the stones rather than just simply fading from one to the other. The terrain texture provided with the editor can be found in Bin/TerrainEditorData/Textures/diff.png with the normal map at normal.png. It is laid out in a 4x2 pattern of textures (4 across, 2 down), and each texture is 512 pixels in size. This is important. The PackTexFactors passed to the shader as a float4/vec4 describes this layout, and must be edited if the layout is changed. The first float, 0.25, describes the width of a single terrain texture in comparison to the entire texture. ie, 0.25 (1/4, given that the texture is 4 terrain types wide). The second float, 0.5, describes the height of a single terrain texture in relation to the height of the whole texture. In this case, 0.5 given that the texture is 2 terrain types high. The third float is the size, in pixels, of a single terrain type texture. The final float is the exponential size, of the top level terrain texture dimensions. ie, 9 in this case, given that 2^9=512. This exponent is used in the calculation of the mip-map level in a custom fashion described earlier in the thread.

The mask texture specifies a texture that is mapped across the entire terrain. The red channel is currently the only mask channel used, though I might provide for the ability to use up to 4 mask layers in a layer iteration of the editor. The mask value is used to mix between the final diffuse texture color and a reddish mask color, to give a visual indicator of where your mask is applied. The mask texture only really makes sense in the context of the editor, and in a real game usage should probably be omitted.

The BumpStrength shader uniform is a bit of legacy cruft that is no longer used, and can safely be omitted.
User avatar
JTippetts
Active user
Active user
 
Posts: 129
Joined: 26 Jan 2014, 23:41
Location: United States

Re: Terrain Editor

PostPosted by Mike » 10 Jul 2015, 06:10

I'm not expert either, I'm using this sheet for reference. Maybe 'mul' has been added recently to GLSL.

BTW, I've sent a PR to fix the issue reported by rogerdv when building with LuaJit enabled.
User avatar
Mike
Moderator
Moderator
 
Posts: 353
Joined: 16 Jan 2014, 20:35
Location: France

Re: Terrain Editor

PostPosted by krstefan42 » 10 Jul 2015, 23:04

GLSL doesn't have a function called "mul". Some compilers may allow it, but it's not in the GLSL specification, so don't expect it to work on every computer.
User avatar
krstefan42
Have some posts
Have some posts
 
Posts: 24
Joined: 28 Jun 2015, 06:16

Re: Terrain Editor

PostPosted by Lichi » 22 Feb 2016, 22:31

I updated terraineditUIOriginal.lua to work in Urho 1.5
(Only need edit to the lines that use GetPtr function) :)
http://pastebin.com/qCENVAyD
User avatar
Lichi
Have some posts
Have some posts
 
Posts: 30
Joined: 25 Nov 2014, 20:56

Re: Terrain Editor

PostPosted by George » 23 Feb 2016, 12:41

Hi
Can you post a sample project using this?

thanks
User avatar
George
Some active
Some active
 
Posts: 54
Joined: 02 Aug 2015, 05:49

PreviousNext

Return to Showcase

Who is online

Users browsing this forum: No registered users and 0 guests

cron