12-04-2015, 04:21 AM
Yeah. Tried a different and much more interesting one.
http://glslsandbox.com/e#29078.0
Rechecked the ones you used and replaced the resolution bit with the auv one that you used, set up the time as a slider (though I have no clue whether time runs from 0.0 to 1.0, or if its like seconds passed, but I tried just replacing it with 0.1 at one point...
Yeah.. Have no clue what I am screwing up... Will post the modded code here, maybe you can figure out what is bugged, and we can both learn something. lol
Obviously, the two things missing here that you normally have with code is a) error checking, and b) reports on crashes/what is actually happening. :p This is like.. throwing things at a black box and wondering, "WTF?" lol
In any case, both my attempts to do this resulted in -- totally blank textures, as in no image and 100% transparent. Just weird...
http://glslsandbox.com/e#29078.0
Rechecked the ones you used and replaced the resolution bit with the auv one that you used, set up the time as a slider (though I have no clue whether time runs from 0.0 to 1.0, or if its like seconds passed, but I tried just replacing it with 0.1 at one point...
Yeah.. Have no clue what I am screwing up... Will post the modded code here, maybe you can figure out what is bugged, and we can both learn something. lol
Code:
uniform float time; %% Tried just setting this to 0.1, but current version uses a slider.
uniform vec2 auv_texsz; %%Replaced here so it uses the Wings native resolution thing?
vec3 roty(vec3 p,float a){return p*mat3(cos(a),0,-sin(a),0,1,0,sin(a),0,cos(a));}
float map(in vec3 p) {
float res=0.;vec3 c = p;
for (int i = 0; i < 10; i++) {
p =0.9*abs(p)/dot(p,p) -.7;
p.yz= vec2(p.y*p.y-p.z*p.z,2.*p.y*p.z);
res += exp(-20. * abs(dot(p,c)));}
return res/2.0;}
vec3 raymarch(vec3 ro, vec3 rd){
float t = 4.0;
vec3 col=vec3(0.);float c=0.;
for( int i=0; i<64; i++ ){
t+=0.02*exp(-2.0*c);
c = map(ro+t*rd);
col += vec3(c/2.0,c*c*c,c)/10.0;}
return col;}
void main(){
vec2 p = (gl_FragCoord.xy-auv_texsz.xy/2.0)/(auv_texsz.y);
vec3 ro = roty(vec3(3.),time*0.3);
vec3 uu = normalize( cross(ro,vec3(0.0,1.0,0.0) ) );
vec3 vv = normalize( cross(uu,ro));
vec3 rd = normalize( p.x*uu + p.y*vv -ro*0.3 );
gl_FragColor.rgb = 0.5*log(1.0+raymarch(ro,rd));}
Code:
{name, "Test"}. % The name in the shader selector
{vertex_shader, "standard.vs"}. % Vertex shader used
{fragment_shader, "test_shader.fs"}. % Fragment shader used
{auv, auv_texsz}. % vec2 width and height
{uniform, {slider,0.0,4.0}, "time", 0.1, "Time"}.
Obviously, the two things missing here that you normally have with code is a) error checking, and b) reports on crashes/what is actually happening. :p This is like.. throwing things at a black box and wondering, "WTF?" lol
In any case, both my attempts to do this resulted in -- totally blank textures, as in no image and 100% transparent. Just weird...