that mod doesn't work at all, but it's beautiful ?:
what did u change ?
but even so, if u look carefully, all light circles are full, not halves;
that mod doesn't work at all, but it's beautiful ?:
what did u change ?
but even so, if u look carefully, all light circles are full, not halves;
@ddlox Hi! ?
ddlox said:
that mod doesn't work at all, but it's beautiful ?:
What GPU do you use? I use AMD RX 560… Some problem on Intel HD, I don't know about nVidia
ddlox said:
all light circles are full, not halves;
This is Debug's Drawing of Light's Source Geometry's ? - Sprites:
see: \DeferredLighting\App.cpp line 570.
void App::drawLightParticles(const vec3 &dx, const vec3 &dy){
dlox said:
what did u change ?
I try to rewtite code to modern OpenGL -3.x 4.x Core Profile, without FF matrix Stack.
I use matrix transformation in modified shaders.
see Source\DeferredLighting\App.cpp line 838:
#if 1 // will Work
glMatrixMode(GL_MODELVIEW);
outGLError();
// TO DO !!!!! Why does it need ?
//glLoadTransposeMatrixfARB(modelviewMatrix);
glLoadMatrixf(transpose(modelviewMatrix));
outGLError();
#endif
I Can't undestrand:
1) why still need glLoadMatrixf, because I send matrix to Vertex shader and do transformation myself
2) Why we see the same problem in this case ?
Thank you for you help!
3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms
ddlox said:
all light circles are full, not halves;
This is Debug's Drawing of Light's Source Geometry's ? - Sprites:
see: \DeferredLighting\App.cpp line 570.
void App::drawLightParticles(const vec3 &dx, const vec3 &dy){
3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms
This is Debug's Drawing of Light's Source Geometry's ? - Sprite
ah yes of course they are ?
why still need glLoadMatrixf, because I send matrix to Vertex shader and do transformation myself
ok comment it out again, but do not transform in cpp, just send the matrix as is and in the shader try and change the order of multiplication:
so for example if u had:
mul(matrix , vertex)
try this:
mul(vertex, matrix)
u can also try using Type Modifier as well:
// hlsl
row_major matrix matViewProjection
// default is "column_major"
mul(matViewProjection, inPos);
so try all sorts of combinations and see what happens;
btw, i tested on a nvidia gtx 1060
see how it goes ?
ddlox said:
just send the matrix as is and in the shader try and change the order of multiplication:
…DeferredLighting\lightingLIDefer.shd:
vVec = (ModelViewMatrix * POSITION).xyz; → vVec = (POSITION * ModelViewMatrix ).xyz;
we see no lighting at all…
projectSpace = ModelViewProjectionMatrix * POSITION → projectSpace = POSITION * ModelViewProjectionMatrix;
3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms
ok it looks like u need to get back to some basics (respectfully), don't do Deferred for now , try basic Phong in HLSL (not GLSL).
The point will be to make sure that both cpp and shader code are talking the same language (for example start all with Row major calculations), then:
Then switch cpp and HLSL to all Column major and:
when this is done, then u will be able to tell how to update the Defer shader. So keep it simple at first …
Until then ?
Hi @ddlox
ddlox said:
The point will be to make sure that both cpp and shader code are talking the same language (for example start all with Row major calculations), then: Make sure that Phong lighting works Then switch cpp and HLSL to all Column major and: Make sure Phong still works
I try the same in glsl,
DeferredLighting\lightingLIDefer.shd:
vVec = (ModelViewMatrix * POSITION).xyz; → vVec = (POSITION * ModelViewMatrix ).xyz;
projectSpace = ModelViewProjectionMatrix * POSITION → projectSpace = POSITION * ModelViewProjectionMatrix;
cpp:
mat4 ProjectionMatrix = transpose(projectionMatrix);
mat4 ModelviewMatrix = transpose(modelviewMatrix);
mat4 ModelviewMatrixProjMatrix = projectionMatrix * modelviewMatrix;
//renderer->setShaderConstant4x4f("ModelViewProjectionMatrix", modelviewMatrixProjMatrix);
//renderer->setShaderConstant4x4f("ModelViewMatrix", ModelviewMatrix);
renderer->setShaderConstant4x4f("ModelViewProjectionMatrix", ModelviewMatrixProjMatrix);
renderer->setShaderConstant4x4f("ModelViewMatrix", ModelviewMatrix);
Yes, it Works with the same problem:
3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms
here:
this is what happens when u drink too much beer ?
i get this result when i move the light vector from the center in the shader:
// Get the vector from the light center to the surface
vec3 lightVec = lightViewPos.xyz - vVec;
lightVec += -10.5; <------------------------- test translation !!!
so your problem is related to what is in lightViewPos and in vVec;
looking at the code, both these values depend on modelviewMatrix:
here:
... IN THE MAIN APP ...
void App::updateBitMaskedLightTextures()
{
....
for (int i =0; i<MAX_LIGHT_TOTAL; i++){
// Move position into view space
vec4 viewSpace = modelviewMatrix * vec4(lightDataArray[i].position, 1.0);
...
}
and here:
.... IN THE VERTEX SHADER ....
// Calculate the view vector in view space
vVec = (ModelViewMatrix * gl_Vertex).xyz;
so if modelviewMatrix is not right then vVec and light positions will not be right;
look at this example, see how transpose( ) is used: http://www.codinglabs.net/tutorial_simple_def_rendering.aspx
and look at these tutorials 35,36,37 as well: http://ogldev.atspace.co.uk/index.html
u can download sources and verify;
u can also try changing the attenuation in the shader:
float atten = 1.0; // saturate(1.0 - dot(lVec, lVec));
u can do this to check if your light positions are at the center;
i don't think i can help any better, because it means digging in further, that's an exercise that i leave for u to do ?
have fun ?
@ddlox Hi, Thank you very much. I think you have given me enough information!
Anyway, why glLoadMatrix fix light's center position - this is very strange for me…
Later, I will check your suggestion and let you know about any result!
3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms
@ddlox Hi, I have fixed bug(with help of my colleague)
Need to use normal in View space. Original Demo uses bump mapping, my demo doesn't use bumpmapping, so we need to transfpm normal to view space:
shadowReceiverVS.hlsl:
Out.normal = Normal; → Out.normal = mul(Normal, (float3x3)ViewMatrix);
3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms