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 issue #332: Immediate, watches and vector watch is not able to extract columns from matrix using mat[<column>]-operator #333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ariaci
Copy link

@ariaci ariaci commented Jan 24, 2025

Description

Extract single columns by using glsl-matrix-array-operator is not working in general. Shader is executed in right way but debugging matrices doesn't work under all circumstances.

Read out the whole matrix (using tooltip, watches or immediate) is working perfectly and without problems.

This PR addresses a part of issue #332 - the vector part is solved with the commit dfranx/SPIRV-VM@1f653d0 ...

Example

#version 450

uniform vec2 iResolution;
uniform vec2 iMouse;
uniform mat4 iView;
uniform sampler2D iChannel0;

out vec4 fragColor;

#define PI 3.14159265

const float hfovDegrees = 60.0;
const float vfovDegrees = 30.0;

void main()
{
    vec2 uv = gl_FragCoord.xy * 2./iResolution.xy - 1.;
    vec2 surfaceSize = vec2(-tan(radians(.5 * hfovDegrees)), tan(radians(.5 * vfovDegrees)));
    
    vec3 camDir = normalize(vec3(uv.xy * surfaceSize, 1.0));
    
    const vec2 angle = vec2(radians(-90), radians(0));
    
    mat4 modelViewX;
    modelViewX[0] = vec4(cos(angle.x), 0.0, sin(angle.x), 0.0);
    modelViewX[1] = vec4(0.0, 1.0, 0.0, 0.0);
    modelViewX[2] = vec4(-sin(angle.x), 0.0, cos(angle.x), 0.0);
    modelViewX[3] = vec4(0.0, 0.0, 0.0, 1.0);
    
    mat4 modelViewY;
    modelViewY[0] = vec4(1.0, 0.0, 0.0, 0.0);
    modelViewY[1] = vec4(0.0, cos(angle.y), -sin(angle.y), 0.0);
    modelViewY[2] = vec4(0.0, sin(angle.y), cos(angle.y), 0.0);
    modelViewY[3] = vec4(0.0, 0.0, 0.0, 1.0);
    
    vec3 rd = (modelViewX * modelViewY * vec4(camDir, 1.0)).xyz;
    vec2 texCoord = vec2(atan(rd.z, rd.x) + PI, acos(-rd.y)) / vec2(2.0 * PI, PI);
    
    fragColor = texture(iChannel0, texCoord);
}

Using for example modelViewX[0] in immediate, watches or vector watch is not working and results in vec4(0.0,0.0,0.0,0.0)

Changes

This PR solves the usage of matrix-array-operator. Furthermore this PR adds vcpkg.json to SHADERed to add support for vcpkg in manifest mode. This greatly enhances building SHADERed by your own.

@ariaci ariaci changed the title Immediate, watches and vector watch is not able to extract columns from matrix using mat[<column>]-operator Fix issue #332: Immediate, watches and vector watch is not able to extract columns from matrix using mat[<column>]-operator Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants