ephtracy / ephtracy.github.io

2.65k stars 288 forks source link

[MagicaVoxel / Bug] Some Shader not working on integrated GPUs #242

Closed superfrantv closed 2 years ago

superfrantv commented 2 years ago

Hello,

i found a bug that on my integrated gpu (AMD Radeon RX Vega 11 Graphics) most shaders working wrong, best example is the mandelbulb shader. This makes a big program to notebooks..

Jamburro commented 2 years ago

Hi! I am not very well versed in these technical issues, but I have found a way to solve the problem. I copied the mandelbulb from version 0.99.6.2 and renamed it to mandelbulb2, so I moved it to the shader folder of version 0.99.7.0, and going to shader now I use mandelbulb 2. I hope I was helpful ^^

PS: the problem is not in your Graphic Card

flowbirdsafebird commented 2 years ago

Hey. I have actually been having this same problem. I have tried the solution suggested above but it doesn't seem to work for me. I have a Intel Core i5 GPU. Not really sure what the problem is.

AnoyRC commented 2 years ago

use the shader mand of 0.99.4.2, working for me mand.txt

FredySandoval commented 2 years ago

use the shader mand of 0.99.4.2, working for me mand.txt

Is Working fine for me too on Linux. Just copy the file into the shaders folder

ephtracy commented 2 years ago

it's a shader compilation issue. to fix it, change powern(vec3(u), n) to powern(u, n) in the shader

FredySandoval commented 2 years ago

"it's a shader compilation issue. to fix it, change powern(vec3(u), n) to powern(u, n)" It works


vec3 powern( vec3 v, float n ) {
float r = length( v );
float phi = atan( v.y, v.x );
float theta = atan( length( v.xy ), v.z );
r = pow( r, n );
phi *= n;
theta *= n;

return r * vec3(
    sin( theta ) * vec2( cos( phi ), sin( phi ) ),
    cos( theta )
);

}

// generate a new voxel color index [0, 255] at position v ( v is at the center of voxel, such as vec3( 1.5, 2.5, 4.5 ) ) float map( vec3 v ) { float n = max( m_degree, 4.0 );

vec3 center = i_volume_size * 0.5;

float size = min( min( center.x, center.y ), center.z );

vec3 u = ( v - center ) / size * 1.1;

for ( int i = 0; i < 8; i++ ) {
    u = powern( u, n ) + u;
}

return i_color_index * step( length( u ), 2.0 );

}

ayliv commented 2 years ago

Hi, I use MagicaVoxel version 0.99.6.4 for windows. I tried to use mand shader version 0.99.4.2 but nothing happened. Does anyone have any idea why? Thanks

FredySandoval commented 2 years ago

Hi, I use MagicaVoxel version 0.99.6.4 for windows. I tried to use mand shader version 0.99.4.2 but nothing happened. Does anyone have any idea why? Thanks

Compare it with mine's, if is still not working, yeah, maybe a GPU issue.

// console commands
// 'xs mand [n]' : e.g. 'xs mand 8'

// shader inputs
// uniform vec3     iVolumeSize;    // volume size [1-126]
// uniform float    iColorIndex;    // current color index [1-255]
// uniform vec3     iMirror;        // current mirror mode [0-1]
// uniform vec3     iAxis;          // current axis mode [0-1]

// uniform float    iFrame;         // current anim frame index
// uniform float    iNumFrames;     // total num of anim frames

// uniform float    iIter;          // current iteration index

// uniform vec4     iRand;          // random number

// uniform float    iArgs[8];       // user args

// built-in functions
// float voxel( vec3 v );           // get voxel color index at position v

vec3 powern( vec3 v, float n ) {
    float r = length( v );
    float phi = atan( v.y, v.x );
    float theta = atan( length( v.xy ), v.z );

    r = pow( r, n );
    phi *= n;
    theta *= n;

    return r * vec3(
        sin( theta ) * vec2( cos( phi ), sin( phi ) ),
        cos( theta )
    );
}

// generate new voxel color index at position v
float map( vec3 v ) {
    float n = max( iArgs[0], 4.0 );

    vec3 center = iVolumeSize * 0.5;

    float size = min( min( center.x, center.y ), center.z );

    vec3 u = ( v + 0.5 - center ) / size * 1.1;

    for ( int i = 0; i < 8; i++ ) {
        u = powern( u, n ) + u;
    }

    return iColorIndex * step( length( u ), 2.0 );
}
ayliv commented 2 years ago

Hi, thanks for your quick answer! I copied yours, and here is what I got. My GPU is Nvidia Geforce RTX 3080 Capture d’écran 2022-05-20 134348

ayliv commented 2 years ago

Does someone have any idea why I have this result?

Carloscruzvalencia commented 1 year ago

Resources

Program: MagicaVoxel-0.99.7.0-win64 Graphic card: NVIDIA GTX 1660 ti Shader file: mand.txt

The default Mandelbulb and the "mand.txt" shader file do not work for me, but with some changes I have managed to make it work somewhat.

Solution

  1. First, I add the shader file: 1

  2. After applying the shader file, nothing changes except for some squares appearing: 2

  3. I then press "Reverse Empty Space" and it appears, but not quite right, it has too many holes: 3

  4. I press the "1/2" button to halve the size and fix it, but it becomes too small: 4

  5. It just needs to be scaled and it would be ready: 5

It will still have holes in the interior, but not as many as in example 3.