#I m sorry to sway off from your question

1 messages · Page 1 of 1 (latest)

tranquil dragon
#

But if there is a way to say, generate another scene and render it separately, that'd also be good. I'm also curious now what the whole 'commandbuffer' approach to rendering is actually doing.

bitter terrace
#

A system I used to use was to instantiate the prefab in the current scene and use a camera set to only render a specific layer. Move the prefab's renderer's onto that and then write the camera's view into a texture

tranquil dragon
#

That's kind of what I was thinking of doing if I couldn't get this to work. My requirements were not to mess with the current scene but if nothing else is possible, that's what I'll do.

That said, I am interested now in the particular route I've taken and how I'd make that work.
I can see ways to set multiple render targets on the CommandBuffer object and I think that would explain what's going on here - only the diffuse channel is being rendered. However, they need special names and I don't know how to set them up, if that's the case. The other alternative would be to ensure it's all forward rendering but where to set that up?

drifting raptor
#

Deferred complicates things, so if your shader also supports forward, that will make things easier. You can specify which pass to use in the CommandBuffer.DrawRenderer method, but you'll either have to know what number it is or use Material.FindPass to find it by name. In URP, it should be named "ForwardLit".

#

But I should say that I've never had to do this, so I don't know if it works.

tranquil dragon
#

Ah,great I'll give that a go. I'm tying myself in knots right now trying to understand 'RenderTargetSetup' object that takes 'RenderBuffers' that don't appear to have texture like constructors. I know from experience that you have to get these things exactly right or they don't work at all and this isn't my engine and I can't find examples.

tranquil dragon
#

Great, I can get lighting now on some of my materials. I have some that implement their own lighting that are causing problems though and there's no shadows - any idea how to set shadow maps up this way?

drifting raptor
# tranquil dragon Great, I can get lighting now on some of my materials. I have some that implemen...

There's nothing automatic when you're drawing things manually like this. You'll have to render a shadow map and pass it to the shader with all the right properties set. You can get some idea of what is required for URP shaders from this file:
https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl

GitHub

Unity Graphics - Including Scriptable Render Pipeline - Graphics/Shadows.hlsl at master · Unity-Technologies/Graphics

tranquil dragon
#

Thanks 🙂
That's what I was figuring, I'll need to create a shadow buffer, render to it using the right pass and set up all the object->shadow space matrices. No worries, I can do it without shadows to make my sprint and then refine it later. I know getting the depth values right can be fiddly.

tranquil dragon
#

@drifting raptor sorry to bother you but although I had this working yesterday, today something has changed and my functions to set up the lights seem to have no effect.

I get grey lighting like this now.

here's the code I use to set up the lights:

LightConstantBuffer._WorldSpaceLightPos0= Shader.PropertyToID("_WorldSpaceLightPos0");
           LightConstantBuffer._LightColor0 = Shader.PropertyToID("_LightColor0");
           LightConstantBuffer._MainLightPosition = Shader.PropertyToID("_MainLightPosition");
           LightConstantBuffer._MainLightColor = Shader.PropertyToID("_MainLightColor");

cmd.SetGlobalVector(LightConstantBuffer._WorldSpaceLightPos0, lightPos);
           cmd.SetGlobalVector(LightConstantBuffer._LightColor0, lightColor);

           cmd.SetGlobalVector(LightConstantBuffer._MainLightPosition, lightPos);
           cmd.SetGlobalVector(LightConstantBuffer._MainLightColor, lightColor);
#

I'm using two alternative names for the lights as I found both whilst searching for the correct names - it was working yesterday, now changing the light direction and colour has no effect, the eyes are black and the diffuse appears to be missing.

#

I don't know what I've changed or if this is some state based issue where it only worked by accident before.