Skip to content

Commit

Permalink
singl
Browse files Browse the repository at this point in the history
Tetronamecronicus committed Jul 13, 2024
1 parent 2930f19 commit 8cdb97b
Showing 6 changed files with 296 additions and 15 deletions.
35 changes: 34 additions & 1 deletion Content.Client/Singularity/SingularityOverlay.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using System.Numerics;
using Robust.Shared.Timing;


namespace Content.Client.Singularity
{
@@ -38,6 +40,7 @@ public SingularityOverlay()
private readonly Vector2[] _positions = new Vector2[MaxCount];
private readonly float[] _intensities = new float[MaxCount];
private readonly float[] _falloffPowers = new float[MaxCount];
private readonly float[] _energys = new float[MaxCount];
private int _count = 0;

protected override bool BeforeDraw(in OverlayDrawArgs args)
@@ -47,7 +50,34 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)
if (_xformSystem is null && !_entMan.TrySystem(out _xformSystem))
return false;

//_count = 0;
//
//var query = _entMan.EntityQueryEnumerator<SingularityComponent, TransformComponent>();
//while (query.MoveNext(out var uid, out var singulo, out var xform))
//{
// if (xform.MapID != args.MapId)
// continue;
//
// var mapPos = _xformSystem.GetWorldPosition(uid);
//
// // is the distortion in range?
// if ((mapPos - args.WorldAABB.ClosestPoint(mapPos)).LengthSquared() > MaxDistance * MaxDistance)
// continue;
//
// // To be clear, this needs to use "inside-viewport" pixels.
// // In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
// var tempCoords = args.Viewport.WorldToLocal(mapPos);
// tempCoords.Y = args.Viewport.Size.Y - tempCoords.Y; // Local space to fragment space.
//
// _energys[_count] = singulo.Energy;
// _count++;
//
// if (_count == MaxCount)
// break;
//}

_count = 0;

var query = _entMan.EntityQueryEnumerator<SingularityDistortionComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var distortion, out var xform))
{
@@ -65,11 +95,13 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)
var tempCoords = args.Viewport.WorldToLocal(mapPos);
tempCoords.Y = args.Viewport.Size.Y - tempCoords.Y; // Local space to fragment space.


_positions[_count] = tempCoords;
_intensities[_count] = distortion.Intensity;
_falloffPowers[_count] = distortion.FalloffPower;
_energys[_count] = distortion.Energy;
_count++;

//
if (_count == MaxCount)
break;
}
@@ -84,6 +116,7 @@ protected override void Draw(in OverlayDrawArgs args)

_shader?.SetParameter("renderScale", args.Viewport.RenderScale * args.Viewport.Eye.Scale);
_shader?.SetParameter("count", _count);
_shader?.SetParameter("energy", _energys);//new float[]{250,500,1000,1500,2000});
_shader?.SetParameter("position", _positions);
_shader?.SetParameter("intensity", _intensities);
_shader?.SetParameter("falloffPower", _falloffPowers);
8 changes: 8 additions & 0 deletions Content.Server/Singularity/EntitySystems/SingularitySystem.cs
Original file line number Diff line number Diff line change
@@ -86,6 +86,11 @@ public override void Update(float frameTime)
var curTime = _timing.CurTime;
if (singularity.NextUpdateTime <= curTime)
Update(uid, curTime - singularity.LastUpdateTime, singularity);
if(TryComp(uid, out SingularityDistortionComponent? sinDist)){
sinDist.Energy = singularity.Energy;
Dirty(uid,sinDist);

}
}
}

@@ -135,6 +140,9 @@ public void SetEnergy(EntityUid uid, float value, SingularityComponent? singular
return;

singularity.Energy = value;



SetLevel(uid, value switch
{
>= 5000 when HasEatenSM => 6,
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@ public sealed partial class SingularityDistortionComponent : Component
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public float Intensity = 31.25f;

[DataField("energy"), AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public float Energy = 150f;

[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public float FalloffPower = MathF.Sqrt(2f);
}
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Fun/toys.yml
Original file line number Diff line number Diff line change
@@ -1125,6 +1125,7 @@
state: singularitytoy
- type: SingularityDistortion
intensity: 2000
energy: 5
falloffPower: 2.6
- type: Item
size: Normal
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@
minSpeed: 1.875
- type: SingularityDistortion
falloffPower: 2.529822
energy: 180
intensity: 3645
- type: RadiationSource
slope: 0.2 # its emit really far away
@@ -80,23 +81,29 @@
sprite: Structures/Power/Generation/Singularity/singularity_1.rsi
state: singularity_1
scale: 1.0,1.0
visible: false
2:
sprite: Structures/Power/Generation/Singularity/singularity_2.rsi
state: singularity_2
scale: 1.0,1.0
visible: false
3:
sprite: Structures/Power/Generation/Singularity/singularity_3.rsi
state: singularity_3
scale: 1.0,1.0
visible: false
4:
sprite: Structures/Power/Generation/Singularity/singularity_4.rsi
state: singularity_4
scale: 1.0,1.0
visible: false
5:
sprite: Structures/Power/Generation/Singularity/singularity_5.rsi
state: singularity_5
scale: 1.5,1.5
visible: false
6:
sprite: Structures/Power/Generation/Singularity/singularity_6.rsi
state: singularity_6
scale: .9,.9
visible: false
257 changes: 243 additions & 14 deletions Resources/Textures/Shaders/singularity.swsl
Original file line number Diff line number Diff line change
@@ -3,43 +3,272 @@
uniform sampler2D SCREEN_TEXTURE;
uniform highp vec2 renderScale;
uniform highp float maxDistance;

uniform lowp int count;

uniform highp float[5] falloffPower;
uniform highp float[5] intensity;
uniform highp vec2[5] position;
// the `5`s in the array lengths correspond to the upper limit on the simultaneous distortion sources that can be present on screen at a time.
uniform highp float[5] energy;
// the `5`s in the array lengths correspond to the upper limit on the simultaneous distortion sources that can be present on screen at a time.
// If you want to change this, make sure to change all of them here, in the for loop, and, in whatever overlay assigns the uniforms
// (apparently #define is an unknown preprocessor directive)


void fragment() {

highp vec2 finalCoords = FRAGCOORD.xy;
highp vec2 delta;
highp float distance;
highp float deformation;

highp vec2 coord = FRAGCOORD.xy * SCREEN_PIXEL_SIZE.xy;
highp vec4 blackCol = vec4(1,1,1,1);
highp vec4 addCol = vec4(0);
//highp float timesin = 0;
//highp float timecos = 0;

highp vec4 ringColor = vec4(1.0, 0.0, 0.0, 15.0);
highp vec4 ringCloseColor = vec4(1.0, 0.0, 0.0, 1.0);
highp vec4 ringRandomColor = vec4(1.0, 0.9843, 0.0, 5.0);
highp vec4 ringRandomCloseColor = vec4(0.0, 0.0, 0.0, 1.0);
highp float ringDencity = 5;
highp float ringCloseFallOff = 0.02;
highp float ringScale = 2;
highp float ringSpeed = 5;
highp float ringMinDis = 0.03;
highp float ringMaxDis = 0.1;
highp float deformationPower = 1;
highp float intensityPower = 3645;
highp float falofPower = sqrt(6.4);
highp float avarageDistance;
highp float avarageClose;
highp float testEnergy = 2950;
highp vec2 dif;



for (int i = 0; i < 5 && i < count; i++) {

delta = FRAGCOORD.xy - position[i];
testEnergy = energy[i];

if(testEnergy<150){
ringColor = mix(vec4(0),vec4(1.0, 0.0, 0.0, 15.0) ,(testEnergy)/150);
ringCloseColor = mix(vec4(0),vec4(1.0, 0.0, 0.0, 1.0) ,(testEnergy)/150);
ringRandomColor = mix(vec4(0),vec4(1.0, 0.9843, 0.0, 5.0) ,(testEnergy)/150);
ringRandomCloseColor = mix(vec4(0),vec4(0.0, 0.0, 0.0, 1.0) ,(testEnergy)/150);
ringDencity = mix(0,4 ,(testEnergy)/150);
ringCloseFallOff = mix(0,0.02 ,(testEnergy)/150);
ringScale = mix(0,2 ,(testEnergy)/150);
ringSpeed = mix(0,3 ,(testEnergy)/150);
ringMinDis = mix(0,0.03 ,(testEnergy)/150);
ringMaxDis = mix(0,0.1 ,(testEnergy)/150);
deformationPower = mix(0,1 ,(testEnergy)/150);
intensityPower = mix(0,3645 ,(testEnergy)/150);
falofPower = mix(sqrt(6.4),sqrt(6.4) ,(testEnergy)/150);
}else if(testEnergy>=150&&testEnergy<250){
ringColor = mix(vec4(1.0, 0.0, 0.0, 15.0),vec4(0.8, 0.6, 0.0, 15.0) ,(testEnergy-150)/100);
ringCloseColor = mix(vec4(1.0, 0.0, 0.0, 1.0),vec4(1.0, 0.0, 0.0, 3.0) ,(testEnergy-150)/100);
ringRandomColor = mix(vec4(1.0, 0.9843, 0.0, 5.0),vec4(1.0, 1.0, 1.0, 15.0) ,(testEnergy-150)/100);
ringRandomCloseColor = mix(vec4(0.0, 0.0, 0.0, 1.0),vec4(0.0, 0.1, 0.0, 1.0) ,(testEnergy-150)/100);
ringDencity = mix(4,5 ,(testEnergy-150)/100);
ringCloseFallOff = mix(0.02,0.03 ,(testEnergy-150)/100);
ringScale = mix(2,2.2 ,(testEnergy-150)/100);
ringSpeed = mix(2,2.5 ,(testEnergy-150)/100);
ringMinDis = mix(0.03,0.1 ,(testEnergy-150)/100);
ringMaxDis = mix(0.1,0.25 ,(testEnergy-150)/100);
deformationPower = mix(1,2 ,(testEnergy-150)/100);
intensityPower = mix(3645,103680 ,(testEnergy-150)/100);
falofPower = mix(sqrt(6.4),sqrt(7.0) ,(testEnergy-150)/100);
}else if(testEnergy>=250&&testEnergy<300){
ringColor = mix(vec4(0.8, 0.6, 0.0, 15.0),vec4(0.4, 0.7, 1.0, 15.0) ,(testEnergy-250)/50);
ringCloseColor = mix(vec4(1.0, 0.0, 0.0, 3.0),vec4(0.2, 0.1, 1.0, 1.0) ,(testEnergy-250)/50);
ringRandomColor = mix(vec4(1.0, 1.0, 1.0, 15.0),vec4(1.0, 0.0, 1.0, 5.0) ,(testEnergy-250)/50);
ringRandomCloseColor = mix(vec4(0.0, 0.1, 0.0, 1.0),vec4(0.0, 1.1, 0.0, 1.0) ,(testEnergy-250)/50);
ringDencity = mix(5,5.2 ,(testEnergy-250)/50);
ringCloseFallOff = mix(0.03,0.05 ,(testEnergy-250)/50);
ringScale = mix(2.2,2.2 ,(testEnergy-250)/50);
ringSpeed = mix(2.5,3 ,(testEnergy-250)/50);
ringMinDis = mix(0.1,0.1 ,(testEnergy-250)/50);
ringMaxDis = mix(0.25,0.35 ,(testEnergy-250)/50);
deformationPower = mix(2,2.2 ,(testEnergy-250)/50);
intensityPower = mix(103680,113680 ,(testEnergy-250)/50);
falofPower = mix(sqrt(7.0),sqrt(7.2) ,(testEnergy-250)/50);
}else if(testEnergy>=300&&testEnergy<950){
ringColor = mix(vec4(0.4, 0.7, 1.0, 15.0),vec4(0.1, 0.0, 1.0, 15.0) ,(testEnergy-300)/650);
ringCloseColor = mix(vec4(0.2, 0.1, 1.0, 1.0),vec4(0.3, 0.0, 1.0, 1.0) ,(testEnergy-300)/650);
ringRandomColor = mix(vec4(1.0, 0.0, 1.0, 5.0),vec4(0.8, 1.0, 0.4, 5.0) ,(testEnergy-300)/650);
ringRandomCloseColor = mix(vec4(0.0, 1.1, 0.0, 1.0),vec4(0.0, 0.2, 0.0, 1.0) ,(testEnergy-300)/650);
ringDencity = mix(5.2,2.6 ,(testEnergy-300)/650);
ringCloseFallOff = mix(0.05,0.07 ,(testEnergy-300)/650);
ringScale = mix(2.2,2.2 ,(testEnergy-300)/650);
ringSpeed = mix(3,3.5 ,(testEnergy-300)/650);
ringMinDis = mix(0.1,0.17 ,(testEnergy-300)/650);
ringMaxDis = mix(0.35,0.5 ,(testEnergy-300)/650);
deformationPower = mix(2.2,3 ,(testEnergy-300)/650);
intensityPower = mix(113680,1113920 ,(testEnergy-300)/650);
falofPower = mix(sqrt(7.2),sqrt(8.0) ,(testEnergy-300)/650);
}else if(testEnergy>=950&&testEnergy<1000){
ringColor = mix(vec4(0.1, 0.0, 1.0, 15.0),vec4(0.1, 0.0, 0.5, 5.0) ,(testEnergy-950)/50);
ringCloseColor = mix(vec4(0.3, 0.0, 1.0, 1.0),vec4(0.1725, 0.0, 0.4157, 5.0) ,(testEnergy-950)/50);
ringRandomColor = mix(vec4(0.8, 1.0, 0.4, 5.0),vec4(1.0, 3.0, 0.5, 15.0) ,(testEnergy-950)/50);
ringRandomCloseColor = mix(vec4(0.0, 0.2, 0.0, 1.0),vec4(0.3, 1.2, 0.7, 3.0) ,(testEnergy-950)/50);
ringDencity = mix(6,6 ,(testEnergy-950)/50);
ringCloseFallOff = mix(0.07,0.1 ,(testEnergy-950)/50);
ringScale = mix(2.2,2.3 ,(testEnergy-950)/50);
ringSpeed = mix(3.5,5 ,(testEnergy-950)/50);
ringMinDis = mix(0.17,0.25 ,(testEnergy-950)/50);
ringMaxDis = mix(0.5,0.6 ,(testEnergy-950)/50);
deformationPower = mix(3,4 ,(testEnergy-950)/50);
intensityPower = mix(1113920,16200000 ,(testEnergy-950)/50);
falofPower = mix(sqrt(8.0),sqrt(10.0) ,(testEnergy-950)/50);
}else if(testEnergy>=1000&&testEnergy<1950){
ringColor = mix(vec4(0.1, 0.0, 0.5, 5.0),vec4(1.0, 0.0, 0.0, 15.0) ,(testEnergy-1000)/950);
ringCloseColor = mix(vec4(0.1725, 0.0, 0.4157, 5.0),vec4(0.9294, 0.2, 0.0, 1.0) ,(testEnergy-1000)/950);
ringRandomColor = mix(vec4(1.0, 3.0, 0.5, 15.0),vec4(1.0, 1.0, 0.0, 15.0) ,(testEnergy-1000)/950);
ringRandomCloseColor = mix(vec4(0.3, 1.2, 0.7, 3.0),vec4(1.0, 1.0, 1.0, 15.0) ,(testEnergy-1000)/950);
ringDencity = mix(6,6 ,(testEnergy-1000)/950);
ringCloseFallOff = mix(0.1,0.15 ,(testEnergy-1000)/950);
ringScale = mix(2.3,2.5 ,(testEnergy-1000)/950);
ringSpeed = mix(5,6 ,(testEnergy-1000)/950);
ringMinDis = mix(0.25,0.3 ,(testEnergy-1000)/950);
ringMaxDis = mix(0.6,0.9 ,(testEnergy-1000)/950);
deformationPower = mix(4,5 ,(testEnergy-1000)/950);
intensityPower = mix(16200000,180000000 ,(testEnergy-1000)/950);
falofPower = mix(sqrt(10.0),sqrt(12.0) ,(testEnergy-1000)/950);
}else if(testEnergy>=1950&&testEnergy<2950){
ringColor = mix(vec4(1.0, 0.0, 0.0, 15.0),vec4(0.0, 2.0, 1.0, 15.0) ,(testEnergy-1950)/1000);
ringCloseColor = mix(vec4(0.9294, 0.2, 0.0, 1.0),vec4(1.0, 0.0, 1.0, 5.0) ,(testEnergy-1950)/1000);
ringRandomColor = mix(vec4(1.0, 1.0, 0.0, 15.0),vec4(1.0, 1.0, 2.0, 5.0) ,(testEnergy-1950)/1000);
ringRandomCloseColor = mix(vec4(1.0, 1.0, 1.0, 15.0),vec4(0.0, 0.0, 0.0, 1.0) ,(testEnergy-1950)/1000);
ringDencity = mix(6,7 ,(testEnergy-1950)/1000);
ringCloseFallOff = mix(0.15,0.2 ,(testEnergy-1950)/1000);
ringScale = mix(2.5,2.7 ,(testEnergy-1950)/1000);
ringSpeed = mix(6,8 ,(testEnergy-1950)/1000);
ringMinDis = mix(0.3,0.35 ,(testEnergy-1950)/1000);
ringMaxDis = mix(0.9,1 ,(testEnergy-1950)/1000);
deformationPower = mix(5,6 ,(testEnergy-1950)/1000);
intensityPower = mix(180000000,280000000 ,(testEnergy-1950)/1000);
falofPower = mix(sqrt(12.0),sqrt(12.0) ,(testEnergy-1950)/1000);
}else{
ringColor = vec4(0.0, 2.0, 1.0, 15.0);
ringCloseColor = vec4(1.0, 0.0, 1.0, 5.0);
ringRandomColor =vec4(1.0, 1.0, 2.0, 5.0);
ringRandomCloseColor = vec4(0.0, 0.0, 0.0, 1.0);
ringDencity = 7;
ringCloseFallOff = 0.2;
ringScale = 2.7;
ringSpeed = 8;
ringMinDis = 0.35;
ringMaxDis = 1;
deformationPower = 6;
intensityPower = 280000000;
falofPower = sqrt(12.0);
}



delta = position[i]-FRAGCOORD.xy;
distance = length(delta / renderScale);
avarageDistance = (distance)/(maxDistance); // 5 / 15
avarageClose = abs(avarageDistance-1);
deformation = intensityPower / pow(distance, falofPower);

deformation = intensity[i] / pow(distance, falloffPower[i]);

// ensure deformation goes to zero at max distance
// avoids long-range single-pixel shifts that are noticeable when leaving PVS.

if (distance >= maxDistance) {
deformation = 0.0;
} else {
deformation *= (1.0 - pow(distance/maxDistance, 4.0));
deformation *= (1 - pow(distance/maxDistance, 1.0));
//if(distance<intensity[i]/300){

//timecos = (cos((TIME)*(deformation/10000)+i));
//addCol+= (pow(zFBM((coord+vec2(timesin*2,timecos*2))*deformation * 1 )+0.5,5)*(sqrt(intensity[i])/10000))*pow((maxDistance-distance)/maxDistance,4) *pow((distance-maxDistance),4);//pow((distance-intensity[i]/300)*(distance-intensity[i]/300)/100000,2);
//}
//addCol *= ( pow((distance+1)/maxDistance, 1.0)) ;
}

if(deformation > 0.8)
deformation = pow(deformation, 0.3);

finalCoords -= deformation * delta;


if(deformation > 1.1){
blackCol=vec4(0,0,0,1);//
deformation = pow(deformation, 0.1);
finalCoords += deformation*(FRAGCOORD.xy-position[i]);
//blackCol = vec4(0,0,0,1);
//}//else if(deformation > 0.9){
// addCol=vec4(15,15,15,1);//
// //deformation = -pow(deformation, 0.1);
// //finalCoords += deformation*(FRAGCOORD.xy-position[i]);
// //blackCol = vec4(0,0,0,1);
}else{
finalCoords += deformation*delta;
}
if(avarageDistance < ringMaxDis && avarageDistance > ringMinDis){
//addCol = vec4(0.5);
////dif = finalCoords.st - 0.5;
//timesin = sin(TIME);
//timecos = cos(TIME);
//addCol = vec4(vec3(octavePerlinNoise(polarCoordinate(vec3(FRAGCOORD,TIME)))),1);//vec3(zFBM(vec2(polarCoordinate(vec3(delta.xy,15)))/100)),1);
//addCol = vec4(vec3(zFBM(vec2(avarageDistance/15,atan(FRAGCOORD.y+position[i].x,FRAGCOORD.x+position[i].y)/57.3248)*150)),1);
//highp vec2 uv = FRAGCOORD/SCREEN_PIXEL_SIZE.xy;
//highp vec2 cuv = (FRAGCOORD.xy/SCREEN_PIXEL_SIZE.xy - vec2(0.5)) * 2;

//highp float spiral = atan(cuv.x, cuv.y) / 6.283185307 * 6 - TIME + length(cuv) * 3;
//highp float falloff = (1 - length(cuv));
//addCol = vec4(vec3(vec3((1. - abs(0.5 - mod(spiral, 1.))) + falloff) * falloff),1);
//addCol = vec4(vec3(zFBM(vec2(avarageDistance,atan(delta.y,delta.x)))),1);
highp float ringFallOff = pow((avarageDistance<ringMinDis+ringCloseFallOff?(avarageDistance-ringMinDis)*1/ringCloseFallOff:(avarageClose-(1-ringMaxDis))/(ringMaxDis-ringCloseFallOff-ringMinDis)),3);
highp float perlinNoicePolarCoords;// = zFBM(vec2((sqrt(deformation)/5+TIME/550*ringSpeed),(abs(0.5-mod(atan(delta.y,delta.x)/3.14159265359,1))+TIME/1.0*ringSpeed)/157.3248)*50*vec2(ringScale/5,ringScale/2));
perlinNoicePolarCoords = zFBM(rotateUV(rotateUV(UV,avarageClose*15,vec2(delta)), -TIME *5 ,vec2(delta))/888*ringScale);//avarageClose*3-atan(timecos,timesin)*ringSpeed
//perlinNoicePolarCoords = zFBM(vec2(avarageDistance,atan(delta.y, delta.x)/150));
addCol += (vec4(vec3(pow(perlinNoicePolarCoords,3)),1)*ringFallOff*
mix(mix(ringCloseColor,ringRandomCloseColor,pow(perlinNoicePolarCoords-0.2,2)), mix(ringColor,ringRandomColor,pow(perlinNoicePolarCoords-0.2,2)), ringFallOff))*ringDencity*mix(mix(ringCloseColor,ringRandomCloseColor,pow(perlinNoicePolarCoords-0.2,2)).w, mix(ringColor,ringRandomColor,pow(perlinNoicePolarCoords-0.2,2)).w, ringFallOff);//*(((avarageClose+(avarageClose-1))))////(avarageDistance-ringMinDis)/ringMinDis:(avarageClose+avarageClose/(ringMinDis+0.1))*ringMaxDis
}
//deformation = min(deformation,0);//0.2 -0.1 = 0.1 /0.1 = 10 0.8 0.2 - 0.1 = 0.1 / 0.1 = 1 0.8

}

COLOR = zTextureSpec(SCREEN_TEXTURE, finalCoords*SCREEN_PIXEL_SIZE );
addCol = vec4(round(addCol.xyz * 25.0) / 25.0, addCol.w);
//addCol = vec4(0);
//addCol = vec4(round(20.0 * FRAGCOORD.xyz) / 20.0, addCol.w);

//vec4(round(color.xyz * 10.0) / 10.0, color.w)
//finalCoords = min(finalCoords,315);



highp vec4 color = (zTextureSpec(SCREEN_TEXTURE, finalCoords*SCREEN_PIXEL_SIZE )+vec4(vec3(addCol),addCol.w))*blackCol;
COLOR = color;//vec4(vec2(rotaUV(UV, TIME, delta.xy)),0,1);//color;
}


//highp float atan2(in highp float y, in highp float x)
//{
// bool s = (abs(x) > abs(y));
// return mix(3.14159265359/2.0 - atan(x,y), atan(y,x), s);
//}
//
//highp vec3 polarCoordinate(highp vec3 p){
// highp float r=length(p);
// highp float theta1=atan(p.x,p.z);
// highp float theta2=atan(p.y,p.z);
// return vec3(r,theta1,theta2);
//}
highp vec2 rotateUV(highp vec2 uv, highp float rotation, highp vec2 mid)
{
highp float cosAngle = cos(rotation);
highp float sinAngle = sin(rotation);
highp vec2 p = uv - mid;
return vec2(
cosAngle * p.x + sinAngle * p.y + mid.x,
cosAngle * p.y - sinAngle * p.x + mid.y
);
}
//
//highp vec2 rotaUV(highp vec2 uv2, highp float angle, highp vec2 pivot){
// //highp vec2 uv2 = UV;
// //highp float angle = TIME*2.0;
// highp float s = sin(angle);
// highp float c = cos(angle);
// highp mat2 rotationMatrix = mat2( c, s, -s, c);
// //highp vec2 pivot = vec2( 0.5, 0.5);
// return rotationMatrix * (uv2 - pivot) + pivot;
//}

0 comments on commit 8cdb97b

Please sign in to comment.