Jump to content

Idea for terrain shader implementation


Niosop
 Share

Recommended Posts

Just an idea that was bouncing around in my head as I fell asleep last night, figured I should write it down in case it has any merit.

 

In order to be able to use more textures on a terrain you could split stuff up like this:

 

Use texture atlases (I think that's the right term) of 4096x4096 split into 16 1024x1024 sections. Up to 4 atlas materials could be used, each material consisting of a diffuse texture and a normal texture.

 

Can choose a standard material to be the base texture for the whole terrain (like it is currently).

Red/Green/Blue high 4 bits (16 possible values) determines which texture of the active atlas is in use.

Red/Green/Blue low 4 bits determines opacity of that layer (you loose opacity resolution, not sure how noticeable it would be)

Alpha channel is split up into 3 2-bit fields (last 2 bits unused). Each of those fields determines the active atlas (0-3) for a Channel. First 2 bits would be for red channel, second 2 for green, third for blue.

 

This would mean that you could only blend between 4 texture layers on a given terrain grid point (base + 3 instead of base + 4 currently), but you would be able to use up to 65 textures on your terrain. 1 base texture and 16 textures per atlas sheet, 4 atlas sheets. It would best if these atlas sheets were generated by the editor so you could just pick up to 65 materials in the editor and it would build the needed sheets.

 

I haven't looked at how the rotation and slope limiting code works to ensure this wouldn't interfere with that, but I'm guessing it wouldn't.

 

I wouldn't mind modifying the terrain shader to use the data, but w/o a custom editor it would be hard to test.

 

Comments/suggestions welcome.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

Any feedback on this Josh? Think it would be usable for mainline LE or should I look at writing my own terrain painting app to write out the data? The output should be usable in LE w/ no modifications (except the shader) you just couldn't paint in the editor w/o messing up your terrain.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

Well the existing one is 5 textures with 8 bit opacity per layer. Hmm, once I finish up w/ these little existing projects I'll see how 4 bit opacity looks and if it's good enough for blending.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

That's all nice, I've been around the intanced models thread, but what use is it here if there's no editor to paint a terrain this way? unless texture atlases become somehow handled internally, exposed from the engine, and sets become selectable in the editor... wich leads us back to feature requests ;]

Desktop:

Intel 2600K - Gigabyte Z68X-UD3H-B3 - 16GB G.Skill Sniper - EVGA 580 gtx - Raid0 OCZ Vertex 3 SSD - Win7 64bit.

Link to comment
Share on other sites

Well, this implementation would require no engine changes at all, just a replacement shader and editor support. I may write an external terrain painter system that would generate the proper atlases and the shader just as a proof of concept and to see how well 4 bits of opacity resolution works, but the terrain would appear all screwed up in the sandbox editor and you would have to make sure you didn't do any terrain painting in the sandbox or it would jack up your texture. But you could still do terrain height editing.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...