Page 1 of 1
How do you make Textures tile ?
Posted: Mon Aug 24, 2009 2:35 pm
by Frame
looking at the native Coriolis station, I'm trying to figure how
to tile my textures in Oolite... however...
My attempts so far are not going very well, I tried several different
things by using educated guessing while looking at the Coriolis dat file. But
either my result is Equal to a non tiled version or they get stretched...
So if anyone knows how to then you are much welcome to tell me how exactly. from wings or 3dmax, to the finished product in Oolite Please
..
Thanks in advance...
Cheers Frame..
Posted: Mon Aug 24, 2009 5:29 pm
by JensAyton
Textures in Oolite use CLAMP or CLAMP_TO_EDGE mode (depending on availability) by default. To enable tiling, you need to use a
texture specifier with
repeat_s and
repeat_t set to true. (The built-in Coriolis doesn’t tile the texture. Texture specifiers are a test release feature.)
Posted: Mon Aug 24, 2009 5:54 pm
by Frame
Ahruman wrote:Textures in Oolite use CLAMP or CLAMP_TO_EDGE mode (depending on availability) by default. To enable tiling, you need to use a
texture specifier with
repeat_s and
repeat_t set to true. (The built-in Coriolis doesn’t tile the texture. Texture specifiers are a test release feature.)
Welcome back Big A.
& Thanks
not tiled Really ?, gotta have to take a 2nd look, because I could swear they are... Doh.. ofcourse it just dawned at me how it was made to appear that way.. manual projection pr side.
oh dear,repeat_t and _s I actually knew/know of this, but when I read this the first time, I had 1.72.2, So I forgot about it.
I just wonder about the texture entries In new_coriolis.dat then..
Code: Select all
TEXTURES
back_metal.png 256 256 0.000000 0.000000 0.000000 128.000000 128.000000 0.000000
back_metal.png 256 256 128.000000 256.000000 0.000000 128.000000 0.000000 256.000000
bottom_metal.png 256 256 128.000000 256.000000 128.000000 0.000000 0.000000 128.000000
bottom_metal.png 256 256 128.000000 256.000000 256.000000 128.000000 128.000000 0.000000
back_metal.png 256 256 128.000000 0.000000 256.000000 128.000000 256.000000 0.000000
back_metal.png 256 256 256.000000 256.000000 256.000000 128.000000 128.000000 256.000000
bottom_metal.png 256 256 128.000000 0.000000 0.000000 128.000000 128.000000 256.000000
bottom_metal.png 256 256 128.000000 0.000000 128.000000 256.000000 256.000000 128.000000
back_metal.png 256 256 128.000000 0.000000 0.000000 128.000000 0.000000 0.000000
back_metal.png 256 256 0.000000 256.000000 0.000000 128.000000 128.000000 256.000000
bottom_metal.png 256 256 256.000000 128.000000 0.000000 128.000000 128.000000 0.000000
bottom_metal.png 256 256 256.000000 128.000000 128.000000 256.000000 0.000000 128.000000
back_metal.png 256 256 128.000000 0.000000 256.000000 0.000000 256.000000 128.000000
back_metal.png 256 256 256.000000 128.000000 256.000000 256.000000 128.000000 256.000000
back_metal.png 256 256 0.000000 128.000000 120.064000 103.936000 120.064000 152.064000
back_metal.png 256 256 128.000000 0.000000 120.064000 103.936000 0.000000 128.000000
back_metal.png 256 256 0.000000 128.000000 120.064000 152.064000 128.000000 256.000000
back_metal.png 256 256 120.064000 103.936000 128.000000 0.000000 135.936000 103.936000
back_metal.png 256 256 135.936000 152.064000 128.000000 256.000000 120.064000 152.064000
back_metal.png 256 256 256.000000 128.000000 135.936000 103.936000 128.000000 0.000000
back_metal.png 256 256 128.000000 256.000000 135.936000 152.064000 256.000000 128.000000
back_metal.png 256 256 135.936000 103.936000 256.000000 128.000000 135.936000 152.064000
bottom_metal.png 256 256 0.000000 128.000000 128.000000 0.000000 256.000000 128.000000
bottom_metal.png 256 256 0.000000 128.000000 256.000000 128.000000 128.000000 256.000000
bottom_metal.png 256 256 0.000000 128.000000 256.000000 128.000000 128.000000 0.000000
bottom_metal.png 256 256 0.000000 128.000000 128.000000 256.000000 256.000000 128.000000
END
I would have expected values of less than 1 and the second and third token "256 256" ,seems to be indifferent, at least when you read the python script, that defaults to just put 1.0 1.0.. ("which ofcourse i modified to try at archive tiling"
Posted: Mon Aug 24, 2009 6:11 pm
by JensAyton
Frame wrote:I would have expected values of less than 1 and the second and third token "256 256" ,seems to be indifferent, at least when you read the python script, that defaults to just put 1.0 1.0.
These things are related. The second and third column specify the t and s scales of the texture coordinates, so the coordinates on, say, the first line are (0/256, 0/256), (0/256, 128/256), (128/256, 0/256).
Posted: Mon Aug 24, 2009 7:23 pm
by Griff
Here's a simple shader that tiles a brick texture over a cobraIII
http://www.box.net/shared/uclv4m2lkm
Oddly enough, i just found this bit of code the other day in an example shader in AMD's Rendermonkey, they were using it there to tile a small 256x256 pixel normal map over the surface of a car model to create to 2tone metallic paint effect, i couldn't really follow all their code but the tiling the texture part seems suspiciously easy, you just have to multiply the texture co-oords from the vertex shader by a big number, the bigger the number the small each texture tile is
eg, this is done in line 28 of the fragment shader in the oxp i uploaded, i'm multiplying the texcoords by 8
Code: Select all
vec4 colorMap = texture2D(tex0, texCoord.st * 8.0); // multiply the texcoords by 8.0 to tile them, experiment with different values, bigger numbers make smaller tiles
It's a floating point number so don't forget to put a decimal point in it otherwise the shader will assume it's an integer and it will fail to compile.
edit: oops, that stuff with the texcoords in the dat file wasn't there when i posted this, now i look like a twit
Posted: Mon Aug 24, 2009 9:06 pm
by Frame
Ahh Thanks Griff. nice find, and thank you for posting.
That was exactly what I was looking for.. It looks way better now.... had to scale it down a bit to 0.5, see the station is twice as large as the standard Coriolis station. Naturally the texture got more strechted so i wanted to prevent that
However, then we are back to this would only work on machines that support shaders. ( catch up intel dammit)
Tiling should really also be possible via materials, and I find it difficult
to getting Oolite it to accept tiling via materials using repeat S & t
like this...
Code: Select all
materials =
{
"back_metal.png" =
{
shininess = 1;
specular = (1.0, 1.0, 1.0, 1.0);
textures =
(
{
name = "back_metal.png";
repeat_s = "yes";
repeat_t = "yes";
}
);
};
};
The models uv map is setup to be tiled too, but still it looks like it is getting clamped when using the texture specifier in materials
Ofcourse my tiresome eyes did'nt catch this on the wiki
The following attributes are only supported if shader support is active:
Edit.. I'm confused
texture specifies appears in both the non shader dependant section
and shader dependant section..
so does texture specifiers need shader support ?
because look here
http://wiki.alioth.net/index.php/Materi ... ctionaries
Posted: Mon Aug 24, 2009 9:23 pm
by JensAyton
Right, for non-shader mode you want to use diffuse_map = {} if you need to set texture properties.
Posted: Mon Aug 24, 2009 9:42 pm
by Frame
so are you telling me that it can be done via materials ?
if so please show how, as I tried and tried, and cannot come up with
a solution..
Posted: Mon Aug 24, 2009 11:32 pm
by JensAyton
In full:
Code: Select all
materials =
{
"back_metal.png" =
{
shininess = 1;
specular = (1.0, 1.0, 1.0, 1.0);
diffuse_map =
{
// name = "back_metal.png"; // This is implicit
repeat_s = "yes";
repeat_t = "yes";
};
};
};
If you only want to set the texture properties, this short form should work:
Code: Select all
materials =
{
"back_metal.png" =
{
repeat_s = "yes";
repeat_t = "yes";
};
};
Posted: Tue Aug 25, 2009 3:16 pm
by Frame
"should" is correct, as I still get stretched textures as if they are clamped
Only the portion of the uv map that is inside s>0 & s <=1.0 and t>0.0 & t <=1.0 is projected correctly as expected
Everything outside texture box, is seeming to be clamped still..
the uv map looks like this, the grey portion is back_metal.jpg
This is the texture data
Code: Select all
TEXTURES
back_metal.png 1.00000 1.00000 0.50000 0.37566 0.09509 0.37972 -0.65457 -0.57603
back_metal.png 1.00000 1.00000 -0.65457 1.57603 0.09506 0.62006 0.50000 0.62425
back_metal.png 1.00000 1.00000 0.90484 0.37968 0.50000 0.37566 1.65457 -0.57603
back_metal.png 1.00000 1.00000 0.90493 0.62006 1.65457 1.57603 0.50000 0.62425
back_metal.png 1.00000 1.00000 1.43984 1.65457 0.43320 0.50000 1.43984 -0.65457
back_metal.png 1.00000 1.00000 1.65457 1.57603 -0.65457 1.57603 0.50000 0.62425
back_metal.png 1.00000 1.00000 -0.60030 -0.57842 1.43984 -0.65457 0.43320 0.50000
back_metal.png 1.00000 1.00000 0.43320 0.50000 1.43984 1.57603 -0.60030 1.57603
back_metal.png 1.00000 1.00000 1.43983 -0.57603 0.43320 0.50000 -0.54352 -0.57603
back_metal.png 1.00000 1.00000 -0.43983 -0.65457 1.54352 -0.60769 0.56680 0.50000
back_metal.png 1.00000 1.00000 -0.60030 -0.57842 0.43320 0.50000 -0.60028 1.57842
back_metal.png 1.00000 1.00000 -0.57842 1.57603 0.50000 0.50160 1.57842 1.57603
back_metal.png 1.00000 1.00000 1.65457 -0.57603 0.50000 0.37566 -0.65457 -0.57603
back_metal.png 1.00000 1.00000 -0.43983 -0.65457 0.56680 0.50000 -0.43984 1.65457
back_metal.png 1.00000 1.00000 -0.60028 1.57842 0.43320 0.50000 1.43984 1.65457
back_metal.png 1.00000 1.00000 -0.43984 1.57603 0.56680 0.50000 1.60028 1.57603
back_metal.png 1.00000 1.00000 -0.43984 1.65457 0.56680 0.50000 1.52184 1.65453
back_metal.png 1.00000 1.00000 1.52184 -0.57602 0.56680 0.50000 -0.43984 -0.57603
back_metal.png 1.00000 1.00000 1.52184 -0.57602 1.60028 1.57603 0.56680 0.50000
back_metal.png 1.00000 1.00000 0.50000 0.50160 -0.57842 1.57603 -0.65453 -0.57602
back_metal.png 1.00000 1.00000 1.60769 -0.57603 1.57842 1.57603 0.50000 0.50160
back_metal.png 1.00000 1.00000 -0.54352 -0.57603 0.43320 0.50000 -0.60030 1.57603
back_metal.png 1.00000 1.00000 0.56680 0.50000 -0.43984 1.57603 -1.33792 0.62006
back_metal.png 1.00000 1.00000 0.56680 0.50000 -1.33785 0.37968 -0.43984 -0.57603
back_metal.png 1.00000 1.00000 0.56680 0.50000 -1.32901 0.62006 -1.33785 0.37968
back_metal.png 1.00000 1.00000 0.43320 0.50000 2.33792 0.62006 1.43984 1.57603
back_metal.png 1.00000 1.00000 0.43320 0.50000 1.43983 -0.57603 2.33784 0.37972
back_metal.png 1.00000 1.00000 0.43320 0.50000 2.33784 0.37972 2.33792 0.62006
back_metal.png 1.00000 1.00000 1.54352 -0.60769 1.52184 1.65453 0.56680 0.50000
back_metal.png 1.00000 1.00000 1.60769 -0.57603 0.50000 0.50160 -0.65453 -0.57602
END
Finally the shipdata.plist entry
Code: Select all
"Big_coriolis" =
{
ai_type = "stationAI.plist";
cargo_type = "CARGO_NOT_CARGO";
energy_recharge_rate = 100;
forward_weapon_type = "WEAPON_NONE";
frangible = 0;
has_ecm = yes;
has_escape_pod = no;
has_scoop = no;
max_energy = 25000;
max_flight_pitch = 8;
max_flight_roll = 8;
max_flight_speed = 0;
model = "camfer.dat";
name = "My Coriolis Station";
roles = "coriolis mystation station";
rotating = yes;
smooth = yes;
subentities =
(
"camfer-dock 0 0 0 1 0 0 0",
);
materials =
{
"back_metal.png" =
{
shininess = 1;
specular = (1.0, 1.0, 1.0, 1.0);
diffuse_map =
{
// name = "back_metal.png"; // This is implicit
repeat_s = "yes";
repeat_t = "yes";
};
};
};
thrust = 100;
weapon_energy = 0;
};
camfer-dock =
{
ai_type = "nullAI.plist";
model = "camferdock.dat";
name = "Docking Slit (Vertical)";
roles = "docking-slit-vertical";
};
}
this is the result
Edit 1:forgot to mention, that the short form comes up with the same result..
Posted: Sun Aug 30, 2009 2:36 pm
by Frame
well i modified the shader to also tile normal maps
Like this on my octagon station..
the code for that looks like this...
Posted: Sun Aug 30, 2009 2:41 pm
by Griff
That looks great Frame, a really clever solution to allow us to fly right up to the station walls without the graphics getting all blocky.
Posted: Sun Aug 30, 2009 7:12 pm
by DaddyHoggy
Griff wrote:That looks great Frame, a really clever solution to allow us to fly right up to the station walls without the graphics getting all blocky.
Definitely very cool idea. Brilliant.