|
フラグメントシェーダー 青海波模様
青海波模様です。
DIM ST(2),C(3),T1(2),T2(2),T3(2)
ASK BITMAP SIZE XSIZE,YSIZE
SET COLOR MODE "NATIVE"
SET POINT STYLE 1
SET WINDOW -XSIZE/MIN(XSIZE,YSIZE),XSIZE/MIN(XSIZE,YSIZE),-YSIZE/MIN(XSIZE,YSIZE),YSIZE/MIN(XSIZE,YSIZE)
CALL VEC2(T1,1,-.5)
CALL VEC2(T2,0,0)
CALL VEC2(T3,1,.5)
FOR YY=0 TO YSIZE-1
FOR XX=0 TO XSIZE-1
LET X=(XX*2-XSIZE)/MIN(XSIZE,YSIZE)
LET Y=(YY*2-YSIZE)/MIN(XSIZE,YSIZE)
CALL VEC2(ST,X,Y)
MAT ST=5*ST
FOR I=1 TO 2
LET ST(I)=FRACT(ST(I))
NEXT I
MAT ST=2*ST
LET INDEX=0
LET INDEX=INDEX+STEP(1,MOD(ST(1),2))
LET INDEX=INDEX+STEP(1,MOD(ST(2),2))*2
FOR I=1 TO 2
LET ST(I)=FRACT(ST(I))
NEXT I
IF INDEX=1 OR INDEX=3 THEN
LET ST(1)=1-ST(1)
END IF
LET D=DISTANCE(T1,ST)
LET T=0
IF D<1 THEN
LET T=ABS(COS(D*2.65*PI))
END IF
LET D=DISTANCE(T2,ST)
IF D<1 AND T=0 THEN
LET T=ABS(COS(D*2.65*PI))
END IF
LET D=DISTANCE(T3,ST)
IF T=0 THEN
LET T=ABS(COS(D*2.65*PI))
END IF
IF T>.5 THEN
CALL VEC3(C,0.,.5,1)
ELSE
CALL VEC3(C,1,1,1)
END IF
CALL SETCOLOR(C)
PLOT POINTS:X,Y
NEXT XX
NEXT YY
END
EXTERNAL SUB SETCOLOR(COL())
SET COLOR COLORINDEX(CLAMP(COL(1),0,1),CLAMP(COL(2),0,1),CLAMP(COL(3),0,1))
END SUB
EXTERNAL FUNCTION DISTANCE(A(),B())
LET DISTANCE=SQR((B(1)-A(1))^2+(B(2)-A(2))^2)
END FUNCTION
EXTERNAL FUNCTION FRACT(X)
LET FRACT=X-INT(X)
END FUNCTION
EXTERNAL FUNCTION STEP(A,X)
IF X0 THEN
LET SIGN=1
ELSE
LET SIGN=0
END IF
END FUNCTION
|
|