I want to make an infinite cave in my 3d game using flash stage3d. But I got no idea about how to build that cave. Can anyone can give me some solution or hint?
update:
I've tried agal fragment shader like squeae tunnel in shadertoy
code:
var fragmentProgramCode:String =
AGALUtils.build()
.mov("ft0","v0")
.div("ft1","ft0.xy","fc3.xy")
.mul("ft2","fc6.x","ft1")
.sub("ft3","ft2","fc5.x")//vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
.mul("ft1","ft3.x","ft3.x")
.mul("ft2","ft3.y","ft3.y")
.pow("ft4","ft1","fc6.z")//float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 );
.pow("ft5","ft2","fc6.z")
.add("ft1","ft4","ft5")
.pow("ft4","ft1","fc6.w")
.mov("ft5","fc5")//uv
.sub("ft1","fc7.x","ft4")
.add("ft5.x","fc7.x","ft1")//uv.x = .5*time + 0.5/r;
.mov("ft6","fc0")//for atan
.atan2("ft5.y","ft3.y","ft3.x",new <String>["fc7.y","fc5.x","fc7.z","fc7.w","fc8.x","fc8.y","fc8.z","fc8.w","fc9.x","fc9.y"],"ft6")
.tex("ft0","ft5","fs0","repeat","linear","nomip")//tex
.mul("ft1","ft4","ft4")
.mul("ft2","ft1","ft4")//r*r*r
.mul("ft1","ft0.xyz","ft2")
.mov("ft0.w","fc5.x")
.mov("oc","ft1").toString()
it can only apply one material,but my project requires different types of material (like floor,ceilling).
so ,I create a 3d model
Is there anyway to make that 3d model render like "infinity cave"? use agal to make each side of cave's texture move?
thanks for your help
update again:
I tried glsl to make a cube,when using color It looks good,but when I don't know how to apply texture's transform. It's really hard for me to accomplish this,haven't 3d experience before,thanks for your time !
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 resolution;
uniform float time;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D tex3;
vec4 p1 = vec4(0.0, 1.0, 0.0, 1.3);//down
vec4 p2 = vec4(0.0, - 1.0, 0.0, 1.3);//up
vec4 p3 = vec4(1.0, 0.0, 0.0, 1.3);//left
vec4 p4 = vec4(-1.0, 0.0, 0.0, 1.3);//right
vec4 p5 = vec4(0.0, 0.0, 1.0, 1.3);//center
void main(){
vec2 uv = -1.0 + 2.0*gl_FragCoord.xy/resolution.xy;
uv.x *= resolution.x/resolution.y;
vec3 o = vec3(0.0, 0.0, 2.3);
vec3 rd = normalize(vec3(uv, -1.0));
vec3 lp = vec3(sin(time), sin(time), cos(time));
float li = 2.0;
vec3 co;
float tm = 10000.0;
float t=- (dot(p1.xyz, o)+p1.w)/dot(p1.xyz,rd);
if(t>0.0&&t<tm){
co =vec3(.2);//down
tm=t;
}
t=- (dot(p2.xyz, o)+p2.w)/dot(p2.xyz,rd);
if (t>0.0&&t<tm){
co =vec3(.3);//top
tm = t;
}
t=- (dot(p3.xyz, o)+p3.w)/dot(p3.xyz,rd);
if (t>0.0&&t<tm){
co =vec3(.4);//left
tm = t;
}
t=- (dot(p4.xyz, o)+p4.w)/dot(p4.xyz,rd);
if (t>0.0&&t<tm){
co =vec3(.5);//right
tm = t;
}
t=- (dot(p5.xyz, o)+p5.w)/dot(p5.xyz,rd);
if (t>0.0&&t<tm){
co =vec3(.6); //center
tm=t;
}
gl_FragColor = vec4(co, 1.0);
}

