18
Mar
08

Tiling Textures

Different repeating texture options.

Spherical Harmonics GLSL Lit Textured 01Spherical Harmonics GLSL Lit Textured 02
Spherical Harmonics GLSL Lit Textured 03Spherical Harmonics GLSL Lit Textured 04
Spherical Harmonics GLSL Lit Textured 05

Advertisements

2 Responses to “Tiling Textures”


  1. 1 hob
    March 18, 2008 at 1:12 pm

    How did you do this?

  2. 2 toneburst
    March 18, 2008 at 1:43 pm

    it’s a really simple bit of code in the Fragment Shader.

    Declare 2 uniform variables to accept the texture tile input and a control for the size of the tile

    uniform float TileSize; // Range 0.0 > 1.0
    uniform sampler2D TileImg;

    Then within the main loop of the Frag Shader

    vec2 xy = gl_TexCoord[0].xy;
    vec2 phase = fract(xy / TileSize);
    vec4 texTile = texture3D(TileImg,phase);

    Then, to combine the texture image with lighting results etc.

    gl_FragColor = Color * Lighting * TexTile;

    [where ‘lighting’ is a vec4 result of lighting calculations]

    The tile should be a square image with a white background and darker foreground. In this example, I had six different tiles, and switches between them with a multiplexer before piping them into the shader.

    Hope this helps a bit.

    alx


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Twitter

March 2008
M T W T F S S
« Feb   Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Links

Blog Stats

  • 474,731 hits

%d bloggers like this: