Dear all,
I am trying to transfer our self written vertex and fragment shaders from Max to Unity. I use the HLSL-shader language for unity. The shader is divided into vertex and fragment shader code. No surface lighting is part of the shader, as I just want to display a completely baked scene in unity, with all light information stored in textures.
When it comes to blend the prebaked lightmap (from Vray) with the diffuseMap, the result is clamped in intensity, even if I imported an exr-lightmap with intensities larger than 1.0.
Is there a way to tell Unity that this external lightmap is in a format that supports high dynamic range lighting with intensities larger then 1.0?
We didn’t code the intensities in the alpha channel and I didn’t touch the internal lightmap-array from Unity so far.
Thank you much for your help.
Robert
And here is the fragment shader that just blends an 8bit diffuse texture (png) with a 32bit OpenExr-Texture. Any ideas?
Shader “FXShader_Robert/TextureShader”
{
Properties
{
_DiffuseTex(“DiffuseMap”, 2D) = “white” { }
_LightTex (“LightMap”, 2D) = “white” { }
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
//The target directive defines the hardware requirements to support the shader.
#pragma target 3.0
#include “UnityCG.cginc”
sampler2D _DiffuseTex;
sampler2D _LightTex;
//same as struct VSIn in DG and Max
struct vertexInput
{
float4 vertex : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
};
struct fragmentInput
{
float4 position : SV_POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
};
//vertexToFragment-function
fragmentInput vert(vertexInput i)
{
fragmentInput o;
o.position = mul (UNITY_MATRIX_MVP, i.vertex);
o.texcoord0 = i.texcoord0;
o.texcoord1 = i.texcoord1;
return o;
}
//fragment-function
fixed4 frag (fragmentInput i) : SV_Target
{
fixed4 diffuseColor = tex2D (_DiffuseTex, i.texcoord0);
fixed4 lightColor = tex2D (_LightTex, i.texcoord1);
return (lightColor * diffuseColor);
}
ENDCG
}
}
}