attempting to rotate my sdfs

This commit is contained in:
spatialfree 2022-01-02 08:15:19 -05:00
parent 297442dc88
commit 26d84b7f6a
3 changed files with 12 additions and 4 deletions

View file

@ -8,6 +8,7 @@ float _ypos;
float3 _dimensions;
float3 _center;
float _crown;
float4x4 _matrix;
Texture2D tex; // : register(t0);
SamplerState tex_s; // : register(s0);
@ -50,9 +51,6 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
o.uv = input.uv;
o.color = input.col;
// float lighting = dot(o.norm, normalize(float3(-0.3, 0.6, 0.1)));
// lighting = (clamp(lighting, 0, 1) * 0.8) + 0.2;
// o.color.rgb = o.color.rgb * lighting; // * sk_inst[id].color;
return o;
}
@ -107,6 +105,8 @@ float oriel(float3 ro, float3 rd) {
return dist;
}
float map(float3 pos) {
// pos.x = _center.x + pos.x;
// pos.y = _center.y + pos.y;
@ -122,7 +122,9 @@ float map(float3 pos) {
// d.y = _height;
// float orielCrown = sdBoxFrame(pos - _center, d, 0.000);
float box = sdBox(pos - _center, float3(0.1, 0.1, 0.1));
// float box = sdBox(pos, float3(0.1, 0.1, 0.1));
float box = sdBox((float3)mul(float4(pos, 1), _matrix), float3(0.1, 0.1, 0.1));
// return lerp(sphere, octo, time);
float plane = sdPlane(pos + float3(0, 1.5, 0), float3(0, 1, 0), 0);
@ -204,6 +206,7 @@ psOut ps(psIn input) {
dif *= ao * sh;
col = float3(0.1, 0.5, 0.3) * amb + float3(0.6, 0.8, 0.3) * dif;
// if (sdBox(pos - _center, _dimensions / 2) == 0.0) {

View file

@ -5,6 +5,7 @@ SKSettings settings = new SKSettings {
appName = "oriels",
assetsFolder = "add",
depthMode = DepthMode.D32,
disableUnfocusedSleep = true,
};
if (!SK.Initialize(settings))
Environment.Exit(1);

View file

@ -69,6 +69,10 @@ public class Oriel {
data.time = (float)Time.Total;
buffer.Set(data);
Matrix matrix = Matrix.TR(bounds.center + Vec3.Up * (float)Math.Sin(Time.Elapsedf), Quat.FromAngles(0, Time.Elapsedf * 60, 0)).Inverse;
// matrix. = (float)Math.Sin(Time.Elapsedf);
mat.SetMatrix("_matrix", matrix);
// circle around center
// bounds.center = Quat.FromAngles(0, 0, Time.Totalf * 60) * Vec3.Up * 0.3f;
// bounds.dimensions = _dimensions * (1f + (MathF.Sin(Time.Totalf * 3) * 0.3f));