PDA

View Full Version : Animating Texture



john_connor
04-09-2017, 05:36 AM
hi everyone,

my goal is to render the sun. my question is: how to do it ?

currently i'm trying to get it done with transform feedback and a double-bufferd sphere:
captured vertex type:

struct Vertex_PT {
vec3 Position;
vec2 TexCoord;
};
the image i'm using look like that:
http://www.solarsystemscope.com/assets/texture_pack/pl_sun.jpg

i'm stuck, i dont know how to do it, what texture parameters are useful, what approach is "best" ...


1. i could use 2 (or more) versions of the texture, and just (linear) interpolate the color between them depending on the passed time

2. i could use 1 texture, but do some calculations with the texcoords, BUT the trick is that thesehave to be repetitive ! i mean that after some time, the have to return ALL to their original texcoord (or somwhere near them), otherwise the image gets distorted / visually "tears apart"

3. dont use texture at all, do some calculation like:
vec4 fragmentcolor = basecolor + timedependentcolor;
but the trick here is to make "timedependentcolor" continuously, in respect to time and fragcoords

any suggestions / solutions are welcome !! :)

GClements
04-09-2017, 06:32 AM
my goal is to render the sun. my question is: how to do it ?

However you want ...

Realistically, it would be better to tell us the specific problem(s) you're trying to solve.

For rendering a sphere, you can render a mesh (a common approach is to start with a Platonic solid, subdivide it, then normalise the interpolated points), or you can ray-trace a sphere in the fragment shader.

For texture coordinates, I'd suggest using a cube map, as that avoids singularities and seams.

Your texture looks a lot like fractal noise with a red-orange-yellow palette. Fractal noise has a lot of useful properties which mean that you can create vast textures which never repeat, or animations which don't repeat. And it's reasonably fast, and easy to ensure that it wraps without discontinuity (either in space or time or both).

So I'd suggest generating your texture algorithmically and animating it by varying the generation parameters.

As a short-cut, you can generate one fractal noise texture then add (or average) several copies of it together, each with a different orientation. This should probably be done before the palette is applied.