Rename 'skin...' shaders to 'texturedCube...'

This commit is contained in:
miku-666
2024-09-21 12:51:04 +02:00
parent 838421602a
commit 9339a60545
8 changed files with 145 additions and 136 deletions

View File

@@ -651,11 +651,11 @@
<None Include="Resources\shader\framebufferVertexShader.glsl" />
<None Include="Resources\shader\plainColorFragmentShader.glsl" />
<None Include="Resources\shader\plainColorVertexShader.glsl" />
<None Include="Resources\shader\skinGeometryShader.glsl" />
<None Include="Resources\shader\texturedCubeGeometryShader.glsl" />
<None Include="Resources\shader\skyboxFragmentShader.glsl" />
<None Include="Resources\shader\skyboxVertexShader.glsl" />
<None Include="Resources\skybox_texture.png" />
<None Include="Resources\shader\skinVertexShader.glsl" />
<None Include="Resources\shader\texturedCubeVertexShader.glsl" />
<None Include="Resources\TexturePackIcon.png" />
<None Include="Resources\binka\binkawin.asi" />
<None Include="Resources\fileTemplates\1.91_colours.col" />
@@ -712,7 +712,7 @@
<None Include="Resources\atlases\particles.png" />
<None Include="Resources\atlases\paintings.png" />
<Content Include="Resources\atlases\terrain.png" />
<None Include="Resources\shader\skinFragmentShader.glsl" />
<None Include="Resources\shader\texturedCubeFragmentShader.glsl" />
<None Include="Resources\armor.png" />
<None Include="Resources\external\trello.png" />
<None Include="Resources\icons\file_copy.png" />

View File

@@ -815,16 +815,26 @@ namespace PckStudio.Properties {
}
/// <summary>
/// Looks up a localized string similar to // TODO: Add parent detection
///
///{
/// Looks up a localized string similar to {
/// &quot;bat&quot;: {
/// &quot;textureLocations&quot;: [
/// &quot;res/mob/bat&quot;
/// ],
/// &quot;parents&quot;: {
/// &quot;rightEar&quot;: &quot;head&quot;,
/// &quot;leftEar&quot;: &quot;head&quot;
/// &quot;root&quot;: {
/// &quot;head&quot;: [
/// &quot;rightEar&quot;,
/// &quot;leftEar&quot;
/// ],
/// &quot;body&quot;: [
/// {
/// &quot;rightWing&quot;: [
/// &quot;rightWingTip&quot;
/// ],
/// &quot;leftWing&quot;: [
/// &quot;leftWingTip&quot;
/// ]
/// }
/// ]
/// }
/// },
/// &quot;bed&quot;: {
@@ -836,14 +846,9 @@ namespace PckStudio.Properties {
/// &quot;textureLocations&quot;: [
/// &quot;res/mob/fire&quot;
/// ]
///
/// },
/// &quot;boat&quot;: {
/// &quot;textureLocations&quot;: [
/// &quot;res/item/boat/boat_acacia&quot;,
/// &quot;res/item/boat/boat_birch&quot;,
/// &quot;res/item/boat/boat_darkoak&quot;,
/// &quot;res/item/boat/boat [rest of string was truncated]&quot;;.
/// [rest of string was truncated]&quot;;.
/// </summary>
public static string modelMetaData {
get {
@@ -1161,61 +1166,6 @@ namespace PckStudio.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
///layout(location = 0) out vec4 color;
///
///uniform sampler2D u_Texture;
///
///in vec2 o_TillingFactor;
///in vec2 o_TexCoord;
///
///void main()
///{
/// color = texture(u_Texture, o_TexCoord * o_TillingFactor);
///};.
/// </summary>
public static string skinFragmentShader {
get {
return ResourceManager.GetString("skinFragmentShader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
///layout (triangles) in;
///layout (triangle_strip, max_vertices=3) out;
///
///uniform vec2 u_TexSize;
///
///out vec2 o_TexCoord;
///out vec2 o_TillingFactor;
///
///in geometryData
///{
/// vec2 TexCoord;
///} dataIn[];
///
///void FixUV()
///{
/// bool isXBad =
/// dataIn[0].TexCoord.x &gt;= u_TexSize.x &amp;&amp;
/// dataIn[1].TexCoord.x &gt;= u_TexSize.x &amp;&amp;
/// dataIn[2].TexCoord.x &gt;= u_TexSize.x;
///
/// gl_Position = gl_in[0].gl_Position;
/// o_TexCoord = dataIn[0].TexCoord;
/// if (isXBad)
/// o_TexCoord.x = mod(o_TexCoord.x, u_TexSiz [rest of string was truncated]&quot;;.
/// </summary>
public static string skinGeometryShader {
get {
return ResourceManager.GetString("skinGeometryShader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -1226,32 +1176,6 @@ namespace PckStudio.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
///layout(location = 0) in vec3 vertexPosition;
///layout(location = 1) in vec2 texCoord;
///
///uniform mat4 u_ViewProjection;
///uniform mat4 u_Transform;
///
///out geometryData
///{
/// vec2 TexCoord;
///} dataOut;
///
///void main()
///{
/// dataOut.TexCoord = texCoord;
/// gl_Position = u_ViewProjection * u_Transform * vec4(vertexPosition, 1.0);
///};.
/// </summary>
public static string skinVertexShader {
get {
return ResourceManager.GetString("skinVertexShader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
@@ -1325,6 +1249,87 @@ namespace PckStudio.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
///layout(location = 0) out vec4 color;
///
///uniform sampler2D u_Texture;
///
///in vec2 o_TillingFactor;
///in vec2 o_TexCoord;
///
///void main()
///{
/// color = texture(u_Texture, o_TexCoord * o_TillingFactor);
///};.
/// </summary>
public static string texturedCubeFragmentShader {
get {
return ResourceManager.GetString("texturedCubeFragmentShader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
///layout (triangles) in;
///layout (triangle_strip, max_vertices=3) out;
///
///uniform vec2 u_TexSize;
///
///out vec2 o_TexCoord;
///out vec2 o_TillingFactor;
///
///in geometryData
///{
/// vec2 TexCoord;
///} dataIn[];
///
///void FixUV()
///{
/// bool isXBad =
/// dataIn[0].TexCoord.x &gt;= u_TexSize.x &amp;&amp;
/// dataIn[1].TexCoord.x &gt;= u_TexSize.x &amp;&amp;
/// dataIn[2].TexCoord.x &gt;= u_TexSize.x;
///
/// gl_Position = gl_in[0].gl_Position;
/// o_TexCoord = dataIn[0].TexCoord;
/// if (isXBad)
/// o_TexCoord.x = mod(o_TexCoord.x, u_TexSiz [rest of string was truncated]&quot;;.
/// </summary>
public static string texturedCubeGeometryShader {
get {
return ResourceManager.GetString("texturedCubeGeometryShader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #version 330 core
///
///layout(location = 0) in vec3 vertexPosition;
///layout(location = 1) in vec2 texCoord;
///
///uniform mat4 u_ViewProjection;
///uniform mat4 u_Transform;
///
///out geometryData
///{
/// vec2 TexCoord;
///} dataOut;
///
///void main()
///{
/// dataOut.TexCoord = texCoord;
/// gl_Position = u_ViewProjection * u_Transform * vec4(vertexPosition, 1.0);
///};.
/// </summary>
public static string texturedCubeVertexShader {
get {
return ResourceManager.GetString("texturedCubeVertexShader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -379,11 +379,11 @@
<data name="Replace" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons\Replace.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="skinVertexShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\skinVertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
<data name="texturedCubeVertexShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\texturedCubeVertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="skinFragmentShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\skinFragmentShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
<data name="texturedCubeFragmentShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\texturedCubeFragmentShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="DefaultSkyTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\skybox_texture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@@ -394,8 +394,8 @@
<data name="skyboxVertexShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\skyboxVertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="skinGeometryShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\skinGeometryShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
<data name="texturedCubeGeometryShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\texturedCubeGeometryShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="framebufferFragmentShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shader\framebufferFragmentShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>

View File

@@ -96,7 +96,6 @@ namespace PckStudio.Rendering
public SceneViewport() : base()
{
VSync = true;
RefreshRate = _refreshRate;
_stopwatch = new Stopwatch();
_timer = new Timer();
_timer.Tick += TimerTick;
@@ -106,6 +105,7 @@ namespace PckStudio.Rendering
_stopwatch.Start();
}
RefreshRate = _refreshRate;
Camera = new PerspectiveCamera(60f, new Vector3(0f, 0f, 0f));
_shaderLibrary = new ShaderLibrary();
_initialized = false;

View File

@@ -309,11 +309,16 @@ namespace PckStudio.Rendering
private void InitializeSkinData()
{
head ??= new CubeMeshCollection("Head") { FlipZMapping = true };
ModelPartSpecifics.PositioningInfo headInfo = ModelPartSpecifics.GetPositioningInfo("HEAD");
head ??= new CubeMeshCollection("Head", headInfo.Translation.ToOpenTKVector(), headInfo.Pivot.ToOpenTKVector())
{
FlipZMapping = true
};
head.AddNamed("DefaultHead", new(-4, -8, -4), new(8, 8, 8), new(0, 0));
head.AddNamed("DefaultHeadOverlay", new(-4, -8, -4), new(8, 8, 8), new(32, 0), OverlayScale * 2);
body ??= new CubeMeshCollection("Body");
ModelPartSpecifics.PositioningInfo bodyInfo = ModelPartSpecifics.GetPositioningInfo("BODY");
body ??= new CubeMeshCollection("Body", bodyInfo.Translation.ToOpenTKVector(), bodyInfo.Pivot.ToOpenTKVector());
body.AddNamed("DefaultBody",new(-4, 0, -2), new(8, 12, 4), new(16, 16));
body.AddNamed("DefaultBodyOverlay", new(-4, 0, -2), new(8, 12, 4), new(16, 32), OverlayScale);
@@ -405,15 +410,15 @@ namespace PckStudio.Rendering
// Skin shader
{
var skinShader = ShaderProgram.Create(
new ShaderSource(ShaderType.VertexShader, Resources.skinVertexShader),
new ShaderSource(ShaderType.FragmentShader, Resources.skinFragmentShader),
new ShaderSource(ShaderType.GeometryShader, Resources.skinGeometryShader)
var cubeShader = ShaderProgram.Create(
new ShaderSource(ShaderType.VertexShader, Resources.texturedCubeVertexShader),
new ShaderSource(ShaderType.FragmentShader, Resources.texturedCubeFragmentShader),
new ShaderSource(ShaderType.GeometryShader, Resources.texturedCubeGeometryShader)
);
skinShader.Bind();
skinShader.SetUniform1("u_Texture", 0);
skinShader.Validate();
AddShader("SkinShader", skinShader);
cubeShader.Bind();
cubeShader.SetUniform1("u_Texture", 0);
cubeShader.Validate();
AddShader("CubeShader", cubeShader);
GLErrorCheck();
armorTexture = new Texture2D(0);
@@ -865,10 +870,10 @@ namespace PckStudio.Rendering
Matrix4 transform = Matrix4.Identity;
ShaderProgram skinShader = GetShader("SkinShader");
skinShader.Bind();
skinShader.SetUniformMat4("u_ViewProjection", ref viewProjection);
skinShader.SetUniform2("u_TexSize", new Vector2(TextureSize.Width, TextureSize.Height));
ShaderProgram cubeShader = GetShader("CubeShader");
cubeShader.Bind();
cubeShader.SetUniformMat4("u_ViewProjection", ref viewProjection);
cubeShader.SetUniform2("u_TexSize", new Vector2(TextureSize.Width, TextureSize.Height));
skinTexture.Bind();
@@ -910,16 +915,16 @@ namespace PckStudio.Rendering
armLeftMatrix = LeftArmMatrix * armLeftMatrix;
}
RenderBodyPart(skinShader, Matrix4.Identity, transform, "HEAD", "HEADWEAR");
RenderBodyPart(skinShader, Matrix4.Identity, transform, "BODY", "JACKET");
RenderBodyPart(skinShader, armRightMatrix, transform, "ARM0", "SLEEVE0");
RenderBodyPart(skinShader, armLeftMatrix, transform, "ARM1", "SLEEVE1");
RenderBodyPart(skinShader, legRightMatrix, transform, "LEG0", "PANTS0");
RenderBodyPart(skinShader, legLeftMatrix, transform, "LEG1", "PANTS1");
RenderBodyPart(cubeShader, Matrix4.Identity, transform, "HEAD", "HEADWEAR");
RenderBodyPart(cubeShader, Matrix4.Identity, transform, "BODY", "JACKET");
RenderBodyPart(cubeShader, armRightMatrix, transform, "ARM0", "SLEEVE0");
RenderBodyPart(cubeShader, armLeftMatrix, transform, "ARM1", "SLEEVE1");
RenderBodyPart(cubeShader, legRightMatrix, transform, "LEG0", "PANTS0");
RenderBodyPart(cubeShader, legLeftMatrix, transform, "LEG1", "PANTS1");
if (_capeImage is not null)
{
skinShader.SetUniform2("u_TexSize", new Vector2(64, 32));
cubeShader.SetUniform2("u_TexSize", new Vector2(64, 32));
capeTexture.Bind();
// Defines minimum Angle(in Degrees) of the cape
float capeMinimumRotationAngle = 7.5f;
@@ -931,43 +936,42 @@ namespace PckStudio.Rendering
Matrix4 partMatrix =
Matrix4.CreateRotationY(MathHelper.DegreesToRadians(180f)) *
Matrix4.CreateRotationX(MathHelper.DegreesToRadians(capeRotation));
RenderPart(skinShader, cape, partMatrix, transform);
RenderPart(cubeShader, cape, partMatrix, transform);
}
// Armor rendering
if (ShowArmor && !ANIM.GetFlag(SkinAnimFlag.ALL_ARMOR_DISABLED))
{
armorTexture.Bind();
//skinShader.SetUniform4("u_Color", Color.FromArgb(0xff << 24 | Color.White.ToArgb() - _outlineColor.ToArgb()));
skinShader.SetUniform2("u_TexSize", new Vector2(64, 64));
cubeShader.SetUniform2("u_TexSize", new Vector2(64, 64));
if (!ANIM.GetFlag(SkinAnimFlag.HEAD_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_HEAD_ARMOR))
RenderPart(skinShader, offsetSpecificMeshStorage["HELMET"], Matrix4.Identity, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["HELMET"], Matrix4.Identity, transform);
if (!ANIM.GetFlag(SkinAnimFlag.BODY_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_BODY_ARMOR))
RenderPart(skinShader, offsetSpecificMeshStorage["CHEST"], Matrix4.Identity, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["CHEST"], Matrix4.Identity, transform);
if (!ANIM.GetFlag(SkinAnimFlag.RIGHT_ARM_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_RIGHT_ARM_ARMOR))
RenderPart(skinShader, offsetSpecificMeshStorage["SHOULDER0"], RightArmMatrix * armRightMatrix, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["SHOULDER0"], RightArmMatrix * armRightMatrix, transform);
if (!ANIM.GetFlag(SkinAnimFlag.LEFT_ARM_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_LEFT_ARM_ARMOR))
RenderPart(skinShader, offsetSpecificMeshStorage["SHOULDER1"], LeftArmMatrix * armLeftMatrix, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["SHOULDER1"], LeftArmMatrix * armLeftMatrix, transform);
bool showRightLegArmor = !ANIM.GetFlag(SkinAnimFlag.RIGHT_LEG_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_RIGHT_LEG_ARMOR);
if (showRightLegArmor)
{
RenderPart(skinShader, offsetSpecificMeshStorage["PANTS0"], legRightMatrix, transform);
RenderPart(skinShader, offsetSpecificMeshStorage["BOOT0"], legRightMatrix, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["PANTS0"], legRightMatrix, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["BOOT0"], legRightMatrix, transform);
}
bool showLeftLegArmor = !ANIM.GetFlag(SkinAnimFlag.LEFT_LEG_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_LEFT_LEG_ARMOR);
if (showLeftLegArmor)
{
RenderPart(skinShader, offsetSpecificMeshStorage["PANTS1"], legLeftMatrix, transform);
RenderPart(skinShader, offsetSpecificMeshStorage["BOOT1"], legLeftMatrix, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["PANTS1"], legLeftMatrix, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["BOOT1"], legLeftMatrix, transform);
}
if (showRightLegArmor && showLeftLegArmor)
RenderPart(skinShader, offsetSpecificMeshStorage["WAIST"], Matrix4.Identity, transform);
RenderPart(cubeShader, offsetSpecificMeshStorage["WAIST"], Matrix4.Identity, transform);
}
if (showWireFrame)