Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Share Thread:
Reddit Facebook Twitter
AutoUV shaders [updated: 05/13/2020]
12-04-2015, 04:21 AM
Post: #22
RE: AutoUV shaders [updated: 10/29/2015]
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

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. Tongue 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...
Reply


Messages In This Thread
RE: AutoUV shaders - tkbd - 10-25-2015, 02:18 AM
RE: AutoUV shaders - micheus - 10-25-2015, 01:14 PM
RE: AutoUV shaders - dgud - 10-26-2015, 10:43 AM
RE: AutoUV shaders - micheus - 10-26-2015, 03:47 PM
RE: AutoUV shaders - dgud - 10-26-2015, 06:59 PM
RE: AutoUV shaders - tkbd - 10-27-2015, 12:59 PM
RE: AutoUV shaders - Nova - 10-27-2015, 09:21 PM
RE: AutoUV shaders - micheus - 10-28-2015, 12:46 AM
RE: AutoUV shaders [updated: 10/29/2015] - Kagehi - 12-04-2015 04:21 AM
New texture shader: Image Mixer - micheus - 05-13-2020, 10:31 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)