A Shader code for a flat surface?

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

A Shader code for a flat surface?

Post by jinxtengu »

Hi,

So I have a specific question.
I have a map that is made of a flat cube with a texture stretched to a size of x 212 and z 212 (or approximately) there is no Y width.

when the map scrolls, the texture looks, "irksome" at the furthest extremities of the view. This is no fault of Z game, it's just what happens
without some kind of filter, or more specifically a shader. So I need a shader code that can be applied to a single surface, that either blurs the texture, or fades it to a set color, when it is far away from the player.
I have some codes that do this, but they are relative to the position of the model, and so they don't work if used on one massive model that makes up part of the map.
I know I ask alot of questions on here, but er, can anyone help me out here?
:)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: A Shader code for a flat surface?

Post by Kjell »

Hi jinxtengu,
jinxtengu wrote: Wed Feb 08, 2023 2:10 pmSo I need a shader code that can be applied to a single surface, that either blurs the texture, or fades it to a set color, when it is far away from the player.
You don't necessarily need a shader to do that. In some cases you might be able to get away with simply manipulating the texture coordinates of a second texture. Attached is a simple example ( use the arrow keys to control ) :wink:

K
Attachments
Kart.zgeproj
(69.88 KiB) Downloaded 125 times
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Re: A Shader code for a flat surface?

Post by jinxtengu »

Thanks for the prompt response Kjell!
It looks like that method you posted would work for what I was aiming for. I Tried implementing it but I ran into a problem,
that is
as soon as a secondary material texture is added (the fog circle) to my ground material, the ground becomes completely invisible when ingame.

It isn't invisible in the preview window though, and it actually looks like the fog would smooth the graininess of the texture on the edges, but in the game,
the ground is not displayed. I tried changing the render order to depthsorted, and removing the Zbuffer on the material, I even tried removing the other objects from the game to see if it's displaying at all, but yeah it's invisible, but when the secondary texture is removed it becomes visible again.
So I'm not exactly sure what property is being changed. :?
Post Reply