Jump to content

  • Log In with Google      Sign In   
  • Create Account


dxCUDA

Member Since 12 Feb 2012
Offline Last Active Jun 16 2013 03:42 PM

Posts I've Made

In Topic: Per object lighting transformation error?

02 June 2012 - 05:44 AM

Ok, So I think I have fixed every issue under the sun relating to all my previous issues. One issue remains however, there is a very stark contrast between a lit area and the falloff with the lighting.

I've been heavily experimenting and nothing I do seems to have an impact. As I move in the scene the dark area moves towards me and I cannot illuminate this area with the spotlight.

Posted Image


Thanks

In Topic: Per object lighting transformation error?

01 June 2012 - 02:44 PM

Progress, but now the world is black,

I was setting

m_LightVec[lightNum]->pLightVar = pBasicEffect->GetVariableByName( "pLight" );
m_LightVec[lightNum]->pLightVar->SetRawValue(&m_LightVec[lightNum]->pointLight, 0, sizeof(pointLight));

to:

m_LightVec[lightNum]->pLightVar = pBasicEffect->GetVariableByName( "pLight" );
m_LightVec[lightNum]->pLightVar->SetRawValue(&m_LightVec[lightNum]->directionalLight, 0, sizeof(DirectionalLight));

Now I am sure the issue is in my shader to do with the position of the light. I was generating the image above when I by accident, used the directional light pos(dir).

else if (pLightType == 1)
{
  lightIntensity = saturate(dot(bumpNormal, +pLight.pos));

  // Determine the final diffuse color based on the diffuse color and the amount of light intensity.
  color = saturate(material.Kd * lightIntensity);

  // The vector from the surface to the light.
  float3 lightVec = pLight.pos - input.p;

  // The distance from surface to light.
  float d = length(lightVec);

//if( d > pLight.range )
  //return float4(0.0f, 0.0f, 0.0f, 0.0f);

// Normalize the light vector.
  lightVec /= d;

//color = color / dot(pLight.att, float3(1.0f, d, d*d))  * textureColor;
  color = color  * textureColor;

specularPower1 = 5.0f;//Need to make this modifiable outside of the shader
  if(lightIntensity > 0.0f)
  {
   //Calculate the reflection vector based on the light intensity, normal vector and light direction
   reflection = normalize(2 * lightIntensity * bumpNormal +pLight.pos);
  
  // Determine the amount of specular light based on the reflection vector, viewing direction, and specular power.
   specular = pow(saturate(dot(reflection, lightVec)), specularPower1);
  
// Use the specular map to determine the intensity of specular light at this pixel.
   specular = specular * specularIntensity;
	
// Add the specular component last to the output color.
   color = saturate(color + specular);
  }
   //calculate lighting
  I = calcBlinnPhongLighting( material, pLight.color, input.n, -pLight.pos, input.h );

I am still receiving the per-object light error as before still however!

In Topic: OpenGL ASM Experiment

28 May 2012 - 05:56 AM

It works now, thanks for the help, even though the triangle is a little bit weird. Here's the code for any future searches:

include gl.inc
include glu.inc


.data

_neg15 dd -1.5f  ;
_neg6 dd -6.0f
_pos1 dd 1.0f
_neg1 dd -1.0f
_20	 dd 20.0f


.code

ASMrender proc


sub rsp, 32h
mov ecx, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
call glClear
add rsp, 32h

call glLoadIdentity

sub rsp, 32h
movss xmm2, dword ptr [_neg15]
xorps   xmm1,xmm1
movss xmm0,  dword ptr [_neg1]
call glTranslatef
add rsp, 32h

sub rsp, 32h
mov ecx, GL_TRIANGLES
call glBegin
add rsp, 32h


sub rsp, 32h
xorps   xmm2,xmm2
movss xmm1, dword ptr [_pos1]
xorps   xmm0,xmm0
call glVertex3f
add rsp, 32h

sub rsp, 32h
movss xmm2, dword ptr [_neg1]
movss xmm1, dword ptr [_neg1]
xorps   xmm0,xmm0
call glVertex3f
add rsp, 32h


sub rsp, 32h
movss xmm2, dword ptr [_pos1]
movss xmm1, dword ptr [_neg1]
xorps   xmm0,xmm0
call glVertex3f
add rsp, 32h

call glEnd


ret

ASMrender endp
end

In Topic: OpenGL ASM Experiment

28 May 2012 - 05:03 AM

Thanks Mozeiko

That's a good direction to take after this learning exercise. I didn't quite understand from the other post initially about the SEE2 registers, but I do now and it works..

Would asm be viable in a runtime situation whereby we have an if -else statement, we could then do this in asm and avoid the doubled call each frame, as it would remove half the calling?. I could see it being better than C++ in such a situation, or would I still be wrong?

In Topic: OpenGL ASM Experiment

27 May 2012 - 07:21 PM

Well I check the value of _m15 which equated to 0BFC00000h so I created _neg15 dd -1.5f to be more clear on the value and this was also 0BFC00000h .

I'm entirely certain that everything is working accordingly, as if I just chose to contain glClear and glLoadIdentity within the asm function, in conjunction with triangle drawing C++ side, and it works. So it must be incorrect data parsed in asm to the gl procedures.

PARTNERS