some new things, mostly not working or finished
This commit is contained in:
24
math/mandelbrot.hlsl
Normal file
24
math/mandelbrot.hlsl
Normal file
@@ -0,0 +1,24 @@
|
||||
cbuffer ViewportBuffer : register(b0)
|
||||
{
|
||||
float xmin;
|
||||
float xmax;
|
||||
float ymin;
|
||||
float ymax;
|
||||
int max_iter;
|
||||
};
|
||||
|
||||
struct PS_IN { float4 pos : SV_POSITION; };
|
||||
|
||||
float4 PSMain(PS_IN input) : SV_TARGET
|
||||
{
|
||||
float2 uv = input.pos.xy * 0.5 + 0.5; // [-1,1] -> [0,1]
|
||||
float2 c = float2(xmin,ymin) + uv * float2(xmax-xmin, ymax-ymin);
|
||||
float2 z = c;
|
||||
int i;
|
||||
for(i=0;i<max_iter;i++){
|
||||
if(dot(z,z)>4) break;
|
||||
z = float2(z.x*z.x - z.y*z.y, 2*z.x*z.y)+c;
|
||||
}
|
||||
float t = i/(float)max_iter;
|
||||
return float4(t,0.5*t,1.0-t,1);
|
||||
}
|
||||
Reference in New Issue
Block a user