Skip to content

Commit

Permalink
feat: update to .NET 8 and fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Rikarin committed Feb 18, 2024
1 parent 6661d3c commit 64d5ebe
Show file tree
Hide file tree
Showing 66 changed files with 1,145 additions and 115 deletions.
16 changes: 16 additions & 0 deletions Examples/Project1/Assets/Shaders/Common/Base.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[vk::image_format("rgba8")]]
RWBuffer<float4> Buf;

[[vk::binding(12)]]
Texture2D texture2D42l;

[[vk::image_format("rg16f")]]
RWTexture2D<float2> Tex;

[[vk::binding(6)]]
RWTexture2D<float2> Tex2; // Works like before

struct aasdf {
float4x4 foobar;
};
[[vk::binding(2,2)]] ConstantBuffer<aasdf> u_aasdf;
89 changes: 89 additions & 0 deletions Examples/Project1/Assets/Shaders/Quad.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
shader "Common/Quad" {
properties {
_MainTex ("Texture", 2D) = "white"
}

subshader {
tags { "RenderType" = "Opaque" }
LOD 100

pass {
HLSLPROGRAM
struct Camera {
[[vk::location(0)]]
float4x4 ViewProjectionMatrix;
};

struct VSInput {
[[vk::location(0)]]
float3 a_Position : POSITION0;

[[vk::location(1)]]
float2 a_TexCoord : TEXCOORD0;
};

struct VSOutput {
float4 Position : SV_POSITION;

[[vk::location(0)]]
float2 TexCoord : TEXCOORD0;
};

class PushConstants {
float4x4 Transform;
};

class Settings {
float Scale;
float Size;
};

class Fill1 { float palceholder; };
class Fill2 { float palceholder; };

[[vk::binding(0, 0)]]
ConstantBuffer<Fill1> _fill1;

[[vk::binding(0, 1)]]
ConstantBuffer<Fill2> _fill2;

[[vk::binding(0, 2)]]
ConstantBuffer<Camera> u_Camera;

[[vk::push_constant]]
ConstantBuffer<PushConstants> u_Renderer;

[[vk::push_constant]]
ConstantBuffer<Settings> u_Settings;

VSOutput vert(VSInput input) {
VSOutput output = (VSOutput)0;
output.Position = float4(input.a_Position, 1.0) * u_Renderer.Transform * u_Camera.ViewProjectionMatrix;
output.TexCoord = input.a_TexCoord;

return output;
}

struct InputFromFrag {
[[vk::location(0)]]
float2 TexCoord;
};

float grid(float2 st, float res) {
float2 grid = frac(st);
return step(res, grid.x) * step(res, grid.y);
}

float4 frag(in InputFromFrag input) : COLOR {
float x = grid(input.TexCoord * 16.025, 0.025);
float4 color = float4(float3(0.2), 0.5) * (1.0 - x);

if (color.a == 0.0)
discard;

return color;
}
ENDHLSL
}
}
}
85 changes: 85 additions & 0 deletions Examples/Project1/Assets/Shaders/Quad_copy.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
shader "Common/Quad" {
properties {
_MainTex ("Texture", 2D) = "white"
}

subshader {
tags { "RenderType" = "Opaque" }
LOD 100

pass {
HLSLPROGRAM

struct Camera {
[[vk::location(0)]]
float4x4 Position;

[[vk::location(1)]]
float3 Test123;
};

struct Camera2 {
[[vk::location(0)]]
float4x4 Position;

[[vk::location(1)]]
float3 Test123;
};

struct VSInput {
[[vk::location(0)]]
float3 a_Position : POSITION0;

[[vk::location(1)]]
float2 a_TexCoord : TEXCOORD0;
};

struct VSOutput {
float4 Pos : SV_POSITION;

[[vk::location(0)]]
float2 TexCoord : TEXCOORD0;
};

struct PushConstants {
uint calculateNormals;
float someVariable;
float4x4 someMatrix;
};


// [[vk::binding(0)]]
// RWTexture2D<float> u_Texture;

[[vk::binding(0, 0)]]
ConstantBuffer<Camera2> u_RandomFloat;

[[vk::binding(0, 1)]]
ConstantBuffer<Camera> u_Camera;

[[vk::push_constant]]
ConstantBuffer<PushConstants> pushConstants;


VSOutput vert(VSInput input) {
VSOutput output = (VSOutput)0;
output.Pos = float4(input.a_Position.xy, 0, 1.0);
output.Pos = float4(u_RandomFloat.Test123, pushConstants.calculateNormals);
output.Pos = float4(u_Camera.Test123.x, 0, pushConstants.someVariable, u_RandomFloat.Test123.x);
output.TexCoord = input.a_TexCoord;

return output;
}

struct InputFromFrag {
float2 TexCoord;
};

float4 frag(in InputFromFrag input) : COLOR {
return float4(0,0,0,0);
// return texture(u_Texture, input.TexCoord);
}
ENDHLSL
}
}
}
50 changes: 50 additions & 0 deletions Examples/Project1/Assets/Shaders/RenderShader.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
shader "Common/RenderShader" {
properties {
_MainTex ("Texture", 2D) = "white"
}

subshader {
tags { "RenderType" = "Opaque" }
LOD 100

pass {
HLSLPROGRAM

struct VSInput {
[[vk::location(0)]]
float3 a_Position : POSITION0;

[[vk::location(1)]]
float2 a_TexCoord : TEXCOORD0;
};

struct VSOutput {
float4 Pos : SV_POSITION;

[[vk::location(0)]]
float2 TexCoord : TEXCOORD0;
};

VSOutput vert(VSInput input) {
VSOutput output = (VSOutput)0;
output.Pos = float4(input.a_Position.xy, 0, 1.0);
output.TexCoord = input.a_TexCoord;

return output;
}

[[vk::binding(0)]]
RWTexture2D<float> u_Texture;

struct InputFromFrag {
float2 TexCoord;
};

float4 frag(in InputFromFrag input) : COLOR {
return float4(0,0,0,0);
// return texture(u_Texture, input.TexCoord);
}
ENDHLSL
}
}
}
12 changes: 12 additions & 0 deletions Examples/Project1/Assets/Shaders/Shader.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#version 330 core

layout(location = 0) out vec4 color;

in vec3 v_Position;
in vec4 v_Color;

void main()
{
color = vec4(v_Position * 0.5 + 0.5, 1.0);
color = v_Color;
}
1 change: 1 addition & 0 deletions Examples/Project1/Assets/Shaders/Shader.frag~.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Meta TODO
19 changes: 19 additions & 0 deletions Examples/Project1/Assets/Shaders/Shader.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#version 330 core

layout(location = 0) in vec3 a_Position;
//layout(location = 1) in vec4 a_Color;

uniform vec4 u_Color;
uniform mat4 u_ViewProjection;
uniform mat4 u_Transform;

out vec3 v_Position;
out vec4 v_Color;

void main()
{
v_Position = a_Position;
v_Color = u_Color;
// gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 1.0);
gl_Position = vec4(a_Position, 1.0);
}
83 changes: 83 additions & 0 deletions Examples/Project1/Assets/Shaders/Test copy.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
shader "Common/FoobarShader" {
properties {
_MainTex ("Texture", 2D) = "white" {}
}

subshader {
tags { "RenderType" = "Opaque" }
LOD 100

pass {
vertexEntry vertex
fragmentEntry frament
computeEntry compute

HLSLPROGRAM
#include "Common/Base"

struct Particle {
float4 pos;
float4 vel;
float4 uv;
float4 normal;
float pinned;
};

[[vk::binding(0)]]
StructuredBuffer<Particle> particleIn;
[[vk::binding(1)]]
RWStructuredBuffer<Particle> particleOut;


struct PushConstants {
uint calculateNormals;
float someVariable;
float4x4 someMatrix;
};



struct ScreenData {
float2 InvFullResolution;
float2 FullResolution;
float2 InvHalfResolution;
float2 HalfResolution;
};
[[vk::binding(2,2)]] ConstantBuffer<ScreenData> u_ScreenData;

cbuffer MyContantBuffer : register(b2, space6)
{
float4x4 matW;
}

struct VSInput
{
[[vk::location(0)]]float2 Pos : POSITION0;
[[vk::location(1)]]float2 UV : TEXCOORD0;
};

struct VSOutput
{
float4 Pos : SV_POSITION;
float2 test;
[[vk::location(4)]]float2 UV : TEXCOORD0;
};

[[vk::push_constant]]
ConstantBuffer<PushConstants> pushConstants;

void compute() {}

VSOutput main(VSInput input)
{
VSOutput output = (VSOutput)0;
output.Pos = float4(input.Pos, pushConstants.calculateNormals, 1.0);
output.UV = input.UV;
output.test = u_ScreenData.FullResolution;

return output;
}
ENDHLSL
}
}
}
Loading

0 comments on commit 64d5ebe

Please sign in to comment.