Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shader (for macos) #4

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/Framework/Rendering/OpenGL/CubismShader_OpenGLCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ enum ShaderNames

// SetupMask
static const csmChar* VertShaderSrcSetupMask =
"#version 150 core\n"
"#version 150\n"
"in vec4 a_position;"
"in vec2 a_texCoord;"
"out vec2 v_texCoord;"
Expand All @@ -76,7 +76,7 @@ static const csmChar* VertShaderSrcSetupMask =
"v_texCoord.y = 1.0 - v_texCoord.y;"
"}";
static const csmChar* FragShaderSrcSetupMask =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;"
"in vec4 v_myPos;"
"uniform sampler2D s_texture0;"
Expand All @@ -91,12 +91,12 @@ static const csmChar* FragShaderSrcSetupMask =
"* step(v_myPos.x/v_myPos.w, u_baseColor.z)"
"* step(v_myPos.y/v_myPos.w, u_baseColor.w);"

"fragColor = u_channelFlag * texture2D(s_texture0 , v_texCoord).a * isInside;"
"fragColor = u_channelFlag * texture(s_texture0 , v_texCoord).a * isInside;"
"}";
//----- バーテックスシェーダプログラム -----
// Normal & Add & Mult 共通
static const csmChar* VertShaderSrc =
"#version 150 core\n"
"#version 150\n"
"in vec4 a_position;" //v.vertex
"in vec2 a_texCoord;" //v.texcoord
"out vec2 v_texCoord;" //v2f.texcoord
Expand All @@ -110,7 +110,7 @@ static const csmChar* VertShaderSrc =

// Normal & Add & Mult 共通(クリッピングされたものの描画用)
static const csmChar* VertShaderSrcMasked =
"#version 150 core\n"
"#version 150\n"
"in vec4 a_position;"
"in vec2 a_texCoord;"
"out vec2 v_texCoord;"
Expand All @@ -128,7 +128,7 @@ static const csmChar* VertShaderSrcMasked =
//----- フラグメントシェーダプログラム -----
// Normal & Add & Mult 共通
static const csmChar* FragShaderSrc =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;" //v2f.texcoord
"uniform sampler2D s_texture0;" //_MainTex
"uniform vec4 u_baseColor;" //v2f.color
Expand All @@ -137,7 +137,7 @@ static const csmChar* FragShaderSrc =
"out vec4 fragColor;"
"void main()"
"{"
"vec4 texColor = texture2D(s_texture0 , v_texCoord);"
"vec4 texColor = texture(s_texture0 , v_texCoord);"
"texColor.rgb = texColor.rgb * u_multiplyColor.rgb;"
"texColor.rgb = texColor.rgb + u_screenColor.rgb - (texColor.rgb * u_screenColor.rgb);"
"vec4 color = texColor * u_baseColor;"
Expand All @@ -146,7 +146,7 @@ static const csmChar* FragShaderSrc =

// Normal & Add & Mult 共通 (PremultipliedAlpha)
static const csmChar* FragShaderSrcPremultipliedAlpha =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;" //v2f.texcoord
"uniform sampler2D s_texture0;" //_MainTex
"uniform vec4 u_baseColor;" //v2f.color
Expand All @@ -155,15 +155,15 @@ static const csmChar* FragShaderSrcPremultipliedAlpha =
"out vec4 fragColor;"
"void main()"
"{"
"vec4 texColor = texture2D(s_texture0 , v_texCoord);"
"vec4 texColor = texture(s_texture0 , v_texCoord);"
"texColor.rgb = texColor.rgb * u_multiplyColor.rgb;"
"texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb);"
"fragColor = texColor * u_baseColor;"
"}";

// Normal & Add & Mult 共通(クリッピングされたものの描画用)in
static const csmChar* FragShaderSrcMask =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;"
"in vec4 v_clipPos;"
"uniform sampler2D s_texture0;"
Expand All @@ -175,20 +175,20 @@ static const csmChar* FragShaderSrcMask =
"out vec4 fragColor;"
"void main()"
"{"
"vec4 texColor = texture2D(s_texture0 , v_texCoord);"
"vec4 texColor = texture(s_texture0 , v_texCoord);"
"texColor.rgb = texColor.rgb * u_multiplyColor.rgb;"
"texColor.rgb = texColor.rgb + u_screenColor.rgb - (texColor.rgb * u_screenColor.rgb);"
"vec4 col_formask = texColor * u_baseColor;"
"col_formask.rgb = col_formask.rgb * col_formask.a ;"
"vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"vec4 clipMask = (1.0 - texture(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;"
"col_formask = col_formask * maskVal;"
"fragColor = col_formask;"
"}";

// Normal & Add & Mult 共通(クリッピングされて反転使用の描画用)
static const csmChar* FragShaderSrcMaskInverted =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;"
"in vec4 v_clipPos;"
"uniform sampler2D s_texture0;"
Expand All @@ -200,20 +200,20 @@ static const csmChar* FragShaderSrcMaskInverted =
"out vec4 fragColor;"
"void main()"
"{"
"vec4 texColor = texture2D(s_texture0 , v_texCoord);"
"vec4 texColor = texture(s_texture0 , v_texCoord);"
"texColor.rgb = texColor.rgb * u_multiplyColor.rgb;"
"texColor.rgb = texColor.rgb + u_screenColor.rgb - (texColor.rgb * u_screenColor.rgb);"
"vec4 col_formask = texColor * u_baseColor;"
"col_formask.rgb = col_formask.rgb * col_formask.a ;"
"vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"vec4 clipMask = (1.0 - texture(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;"
"col_formask = col_formask * (1.0 - maskVal);"
"fragColor = col_formask;"
"}";

// Normal & Add & Mult 共通(クリッピングされたものの描画用、PremultipliedAlphaの場合)
static const csmChar* FragShaderSrcMaskPremultipliedAlpha =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;"
"in vec4 v_clipPos;"
"uniform sampler2D s_texture0;"
Expand All @@ -225,19 +225,19 @@ static const csmChar* FragShaderSrcMaskPremultipliedAlpha =
"out vec4 fragColor;"
"void main()"
"{"
"vec4 texColor = texture2D(s_texture0 , v_texCoord);"
"vec4 texColor = texture(s_texture0 , v_texCoord);"
"texColor.rgb = texColor.rgb * u_multiplyColor.rgb;"
"texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb);"
"vec4 col_formask = texColor * u_baseColor;"
"vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"vec4 clipMask = (1.0 - texture(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;"
"col_formask = col_formask * maskVal;"
"fragColor = col_formask;"
"}";

// Normal & Add & Mult 共通(クリッピングされて反転使用の描画用、PremultipliedAlphaの場合)
static const csmChar* FragShaderSrcMaskInvertedPremultipliedAlpha =
"#version 150 core\n"
"#version 150\n"
"in vec2 v_texCoord;"
"in vec4 v_clipPos;"
"uniform sampler2D s_texture0;"
Expand All @@ -249,11 +249,11 @@ static const csmChar* FragShaderSrcMaskInvertedPremultipliedAlpha =
"out vec4 fragColor;"
"void main()"
"{"
"vec4 texColor = texture2D(s_texture0 , v_texCoord);"
"vec4 texColor = texture(s_texture0 , v_texCoord);"
"texColor.rgb = texColor.rgb * u_multiplyColor.rgb;"
"texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb);"
"vec4 col_formask = texColor * u_baseColor;"
"vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"vec4 clipMask = (1.0 - texture(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;"
"float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;"
"col_formask = col_formask * (1.0 - maskVal);"
"fragColor = col_formask;"
Expand Down
Loading