the_lab_renderer icon indicating copy to clipboard operation
the_lab_renderer copied to clipboard

Cookies

Open fznmeatpopsicle opened this issue 8 years ago • 6 comments

Supporting light cookies with a Valve Realtime Light would be a nice addition, unless there's currently a way to do it and I'm missing it.

fznmeatpopsicle avatar Aug 21 '16 23:08 fznmeatpopsicle

Have you tried uncommenting this section in the shader?

//[branch] if ( g_vLightShadowIndex_vLightParams[ i ].y != 0 ) // If has a light cookie
//{
//  // Light cookie
//  float4 vPositionTextureSpace = mul( float4( vPositionWs.xyz, 1.0 ), g_matWorldToLightCookie[ i ] );
//  vPositionTextureSpace.xyz /= vPositionTextureSpace.w;
//  vSpotAtten.rgb = Tex3DLevel( g_tVrLightCookieTexture, vPositionTextureSpace.xyz, 0.0 ).rgb;
//}

https://github.com/ValveSoftware/the_lab_renderer/blob/master/Assets/TheLabRenderer/Shaders/vr_lighting.cginc#L320-L326

betavr avatar Sep 12 '16 08:09 betavr

Okay, I just tried that now, and all I get is everything going pink, and the following errors:

Shader error in 'Valve/vr_standard': undeclared identifier 'g_tVrLightCookieTexture' at Assets/TheLabRenderer/Shaders/vr_lighting.cginc(325) (on d3d11)

Shader error in 'Valve/vr_photogrammetry': undeclared identifier 'g_tVrLightCookieTexture' at Assets/TheLabRenderer/Shaders/vr_lighting.cginc(325) (on d3d11)

fznmeatpopsicle avatar Sep 12 '16 09:09 fznmeatpopsicle

You can try to add this line to the top of the file, below g_tOverrideLightmap:

sampler3D g_tVrLightCookieTexture;

betavr avatar Sep 12 '16 09:09 betavr

Now it's just giving the same errors, but with "Tex3DLevel" instead. I tried the same thing as your last suggestion, and it's saying 'Tex3DLevel': identifier represents a variable, not a function.

fznmeatpopsicle avatar Sep 12 '16 12:09 fznmeatpopsicle

Tex3DLevel is probably a macro similar to Tex2DLevel, which is defined at the beginning of the shader:

#define Tex2DLevel( name, uv, flLevel ) name.SampleLevel( sampler##name, ( uv ).xy, flLevel )

But anyway after looking at the code a little more, I think ValveCamera.cs is also missing important stuff.

betavr avatar Sep 12 '16 14:09 betavr

Ah, I see. Thanks for trying.

fznmeatpopsicle avatar Sep 12 '16 23:09 fznmeatpopsicle