Bladeren bron

more parameters!

Lucas Stadler 10 jaren geleden
bovenliggende
commit
79aaac32ec
1 gewijzigde bestanden met toevoegingen van 7 en 5 verwijderingen
  1. 7 5
      glsl/raymarching.js

+ 7 - 5
glsl/raymarching.js

@ -71,7 +71,7 @@ float DistanceEstimator(vec3 pos);
71 71
float trace(vec3 from, vec3 direction) {
72 72
	float totalDistance = 0.0;
73 73
  int stepsDone = 0;
74
	for (int steps=0; steps < MaximumRaySteps; steps++) {
74
	for (int steps = 0; steps < MaximumRaySteps; steps++) {
75 75
		vec3 p = from + totalDistance * direction;
76 76
		float distance = DistanceEstimator(p);
77 77
		totalDistance += distance;
@ -85,13 +85,13 @@ float DistanceEstimator(vec3 pos) {
85 85
  return length(pos) - 1.0;
86 86
}
87 87
88
/*uniform int MaxIterations; //#slider[1,50,200]
88 89
const float bailout = 4.0;
89
const int MaxIterations = 50;
90 90
const float power = 8.0;
91 91
const float phaseX = 0.0;
92 92
const float phaseY = 0.0;
93 93
94
/*float DistanceEstimator(vec3 z0) {
94
float DistanceEstimator(vec3 z0) {
95 95
	vec3 c = z0;
96 96
	vec3 z = z0;
97 97
	float pd = power - 1.0; // power for derivative
@ -151,7 +151,9 @@ mat3 setCamera( in vec3 ro, in vec3 ta, float cr ) {
151 151
}
152 152
153 153
uniform vec3 origin; //#slider[(-10.0,1.0,10.0),(-10.0,2.0,10.0),(-10.0,-1.0,10.0)]
154
uniform vec3 angle; //#slider[(-3.0,0.0,3.0),(-3.0,0.0,3.0),(-3.0,0.0,3.0)]
154 155
uniform vec3 color; //#slider[(0.0, 1.0, 1.0),(0.0,0.0,1.0),(0.0,0.0,1.0)]
156
uniform float colorMix; //#slider[0.0,0.9,1.0]
155 157
156 158
void main() {
157 159
  vec2 q = gl_FragCoord.xy / iResolution.xy;
@ -164,7 +166,7 @@ void main() {
164 166
  // camera	
165 167
  //vec3 ro = vec3(1.0, 2.0, -1.0); //vec3( -0.5+3.2*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 3.2*sin(0.1*time + 6.0*mo.x) );
166 168
  vec3 ro = origin;
167
  vec3 ta = vec3(0.0); //vec3( -0.5, -0.4, 0.5 );
169
  vec3 ta = angle; //vec3(0.0); //vec3( -0.5, -0.4, 0.5 );
168 170
169 171
  // camera-to-world transformation
170 172
  mat3 ca = setCamera( ro, ta, 0.0 );
@ -176,7 +178,7 @@ void main() {
176 178
  float dist = trace(ro, rd);
177 179
  vec3 col = vec3(dist, dist, dist);
178 180
179
  col = mix(color, col, 0.9);
181
  col = mix(color, col, colorMix);
180 182
  //col = pow( col, vec3(0.4545));
181 183
182 184
  gl_FragColor = vec4( col, 1.0 );